summaryrefslogtreecommitdiff
blob: b415bf335c72a231ab248e35bc8c40f4db7a0291 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-misc/capi4hylafax/capi4hylafax-01.03.00.3.ebuild,v 1.4 2006/01/21 20:39:00 pylon Exp $

inherit eutils versionator

FAX_SPOOL_DIR="/var/spool/fax"

MY_PV="$(get_version_component_range 1-3)"
MY_PP="$(get_version_component_range 4)"
MY_P="${PN}-${MY_PV}"

DESCRIPTION="capi4hylafax adds a faxcapi modem to the hylafax enviroment."
SRC_URI="http://ftp.debian.org/debian/pool/main/c/capi4hylafax/${MY_P/-/_}.orig.tar.gz
		http://ftp.debian.org/debian/pool/main/c/capi4hylafax/${MY_P/-/_}-${MY_PP}.diff.gz"
HOMEPAGE="http://packages.qa.debian.org/c/capi4hylafax.html"

S="${WORKDIR}/${MY_P}"

IUSE="unicode"

SLOT="0"
LICENSE="GPL-2"
KEYWORDS="amd64 ppc x86"

DEPEND="net-dialup/capi4k-utils
	media-libs/tiff
	media-libs/jpeg
	sys-libs/zlib"

RDEPEND="${DEPEND}
	dev-util/dialog"

src_unpack() {
	unpack ${A}
	mv "${S}.orig" "${S}"
	cd "${S}"

	# apply debian patches + update configs
	epatch "${WORKDIR}/${MY_P/-/_}-${MY_PP}.diff"
	libtoolize --copy --force

	# fix location of fax spool
	for i in config.faxCAPI Readme_src src/defaults.h.in debian/*.1; do
		[ -f "${i}" ] && sed -i -e "s:/var/spool/hylafax:${FAX_SPOOL_DIR}:g" "${i}"
	done

	# fix location of fax config
	sed -i -e "s:/etc/hylafax:${FAX_SPOOL_DIR}/etc:g" setupconffile

	# fix name and location of logfile
	sed -i -e "s:/var/spool/fax/log/capi4hylafax:/var/log/${PN}.log:" config.faxCAPI
	sed -i -e "s:/tmp/capifax.log:/var/log/${PN}.log:" src/defaults.h.in config.faxCAPI

	# patch man pages
	sed -i -e "s:/usr/share/doc/capi4hylafax/:/usr/share/doc/${PF}/html/:g" \
		-e "s:c2send:c2faxsend:g" -e "s:c2recv:c2faxrecv:g" \
		-e "s:CAPI4HYLAFAXCONFIG \"1\":C2FAXADDMODEM \"8\":g" \
		-e "s:capi4hylafaxconfig:c2faxaddmodem:g" debian/*.1
	cp -f debian/capi4hylafaxconfig.1 debian/c2faxaddmodem.8

	# if specified, convert all relevant files from latin1 to UTF-8
	if use unicode; then
		for i in config.faxCAPI; do
			einfo "Converting ${i} to UTF-8"
			iconv -f latin1 -t utf8 -o "${i}~" "${i}" && mv -f "${i}~" "${i}" || rm -f "${i}~"
		done
	fi
}

src_compile() {
	econf --with-hylafax-spooldir="${FAX_SPOOL_DIR}" || die "econf failed"
	emake || die "emake failed"
}

src_install() {
	keepdir "${FAX_SPOOL_DIR}"/{etc,recvq,pollq,log,status}
	fowners uucp:uucp "${FAX_SPOOL_DIR}" "${FAX_SPOOL_DIR}"/{etc,recvq,pollq,log,status}
	fperms 0700 "${FAX_SPOOL_DIR}"

	make DESTDIR="${D}" install || die "make install failed"

	# install setup script
	newsbin setupconffile c2faxaddmodem

	# install sample config
	insinto "${FAX_SPOOL_DIR}/etc"
	newins config.faxCAPI config.faxCAPI.default

	# install docs
	dodoc AUTHORS ChangeLog Readme_src
	newdoc debian/changelog ChangeLog.debian
	dohtml README.html LIESMICH.html

	# install man pages
	doman debian/c2fax*.[18]

	# install examples
	docinto examples
	dodoc sample_faxrcvd faxrcvd
	newdoc debian/faxsend sample_faxsend
	newdoc sample_AVMC4_config.faxCAPI config.faxCAPI_AVMC4
	dodoc config.faxCAPI fritz_pic.tif GenerateFileMail.pl

	# finally install init-script + config
	newinitd "${FILESDIR}/${PN}.initd" ${PN}
	newconfd "${FILESDIR}/${PN}.confd" ${PN}
}

pkg_postinst() {
	einfo "To use capi4hylafax:"
	einfo "Make sure that your isdn/capi devices are owned by"
	einfo "the \"uucp\" user (see udev or devfsd config)."
	einfo "Modify ${FAX_SPOOL_DIR}/etc/config.faxCAPI"
	einfo "to suit your system."

	if [ -f "${FAX_SPOOL_DIR}/etc/config.faxCAPI" ]; then
		einfo
		einfo "If you're upgrading from a previous version"
		einfo "please check for new or changed options."
		einfo "A sample default config is installed as:"
		einfo "${FAX_SPOOL_DIR}/etc/config.faxCAPI.default"
	else
		# install default config
		cp -f "${FAX_SPOOL_DIR}/etc/config.faxCAPI.default" \
			"${FAX_SPOOL_DIR}/etc/config.faxCAPI"
	fi

	einfo
	einfo "You should also check special options in:"
	einfo "/etc/conf.d/${PN}"
	einfo
	einfo "If you want to use capi4hylafax together with"
	einfo "hylafax, then please emerge net-misc/hylafax"
	einfo
	einfo "Then append the following line to your hylafax"
	einfo "config file (${FAX_SPOOL_DIR}/etc/config):"
	einfo "SendFaxCmd:             /usr/bin/c2faxsend"
}