net-dialup/moserial: x86 stable wrt bug #685254
[gentoo.git] / net-dialup / mgetty / mgetty-1.2.1.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5 inherit flag-o-matic toolchain-funcs user
6
7 DESCRIPTION="fax and voice modem programs"
8 HOMEPAGE="http://mgetty.greenie.net/"
9 SRC_URI="ftp://mgetty.greenie.net/pub/mgetty/source/1.2/${P}.tar.gz"
10
11 DEPEND="
12         >=sys-apps/sed-4
13         sys-apps/groff
14         dev-lang/perl
15         sys-apps/texinfo
16         virtual/awk
17         fax? (
18                 !net-misc/efax
19                 !net-misc/hylafax
20         )
21 "
22 RDEPEND="${DEPEND}
23         fax? ( media-libs/netpbm app-text/ghostscript-gpl )
24 "
25
26 SLOT="0"
27 LICENSE="GPL-2"
28 KEYWORDS="alpha amd64 arm hppa ia64 ~mips ppc ppc64 s390 sh sparc x86"
29 IUSE="+fax fidonet"
30
31 pkg_setup() {
32         enewgroup fax
33         enewuser fax -1 -1 /dev/null fax
34 }
35
36 PATCHES=(
37         "${FILESDIR}"/${PN}-1.1.36-callback.patch
38         "${FILESDIR}"/${PN}-1.1.36-tmpfile.patch
39         "${FILESDIR}"/${PN}-1.1.37-qa-fixes.patch
40         "${FILESDIR}"/${PN}-1.2.1-Lucent.c.patch
41         "${FILESDIR}"/${PN}-1.2.1-gentoo.patch
42 )
43
44 src_prepare() {
45         default
46
47         chmod +x mkidirs
48
49         # don't install fax related files - bug #195467
50         use fax || eapply "${FILESDIR}/${PN}-1.1.37-nofax.patch"
51
52         sed -i -e 's:/usr/local/lib/mgetty+sendfax:/etc/mgetty+sendfax:' faxrunq.config || die 'changing mgetty config dir failed'
53         sed -i -e 's:/usr/local/bin/g3cat:/usr/bin/g3cat:' faxrunq.config fax/faxspool.rules || die 'changing g3cat path failed'
54
55         sed -e "/^doc-all:/s/mgetty.asc mgetty.info mgetty.dvi mgetty.ps/mgetty.info/" \
56                 -i doc/Makefile || die 'first sed on doc/Makefile failed'
57
58         sed -i \
59                 -e 's:^CC=:CC?=:g' \
60                 -e 's:^CFLAGS=:CFLAGS?=:g' \
61                 {,*/}Makefile || die
62         sed -i \
63                 -e 's:^AR=:AR?=:g' \
64                 -e 's:^CFLAGS=:CFLAGS+= -I..:g' \
65                 -e 's:^RANLIB=:RANLIB?=:g' \
66                 */Makefile || die
67 }
68
69 src_configure() {
70         tc-export AR CC RANLIB
71         use fidonet && append-cppflags "-DFIDO"
72         append-cppflags "-DAUTO_PPP"
73
74         sed -e 's:var/log/mgetty:var/log/mgetty/mgetty:' \
75                 -e 's:var/log/sendfax:var/log/mgetty/sendfax:' \
76                 -e 's:\/\* \(\#define CNDFILE "dialin.config"\) \*\/:\1:' \
77                 -e 's:\(\#define FAX_NOTIFY_PROGRAM\).*:\1 "/etc/mgetty+sendfax/new_fax":' \
78                 policy.h-dist > policy.h || die 'creating policy.h failed'
79
80         sed -i \
81                 -e "s/\$(CFLAGS) -o newslock/${CFLAGS} ${LDFLAGS} -Wall -o newslock/" \
82                 -e "s/\$(LDLAGS)/${LDFLAGS}/" \
83                 {,fax/}Makefile || die
84 }
85
86 src_compile() {
87         local target
88         for target in mgetty sedscript all vgetty;do
89                 VARTEXFONTS="${T}"/fonts emake prefix=/usr \
90                         CONFDIR=/etc/mgetty+sendfax \
91                         CFLAGS="${CFLAGS} ${CPPFLAGS}" \
92                         LDFLAGS="${LDFLAGS}" \
93                         ${target}
94         done
95 }
96
97 src_install () {
98         # parallelization issue: vgetty-install target fails if install target
99         #                        isn't finished
100         local target
101         for target in install "vgetty-install install-callback"; do
102                 emake prefix="${D}/usr" \
103                         INFODIR="${D}/usr/share/info" \
104                         CONFDIR="${D}/etc/mgetty+sendfax" \
105                         MAN1DIR="${D}/usr/share/man/man1" \
106                         MAN4DIR="${D}/usr/share/man/man4" \
107                         MAN5DIR="${D}/usr/share/man/man5" \
108                         MAN8DIR="${D}/usr/share/man/man8" \
109                         SBINDIR="${D}/usr/sbin" \
110                         BINDIR="${D}/usr/bin" \
111                         VOICE_DIR="${D}/var/spool/voice" \
112                         PHONE_GROUP=fax \
113                         PHONE_PERMS=755 \
114                         spool="${D}/var/spool" \
115                         ${target}
116         done
117
118         keepdir /var/log/mgetty
119
120         #Install mgetty into /sbin (#119078)
121         dodir /sbin && \
122                 mv "${D}"/usr/sbin/mgetty "${D}"/sbin && \
123                 dosym /sbin/mgetty /usr/sbin/mgetty || die "failed to install /sbin/mgetty"
124         #Don't install ct (#106337)
125         rm "${D}"/usr/bin/ct || die "failed to remove useless ct program"
126
127         dodoc BUGS ChangeLog README.1st Recommend THANKS TODO \
128                 doc/*.txt doc/modems.db
129         doinfo doc/mgetty.info
130
131         docinto vgetty
132         dodoc voice/{Readme,Announce,ChangeLog,Credits}
133
134         docinto vgetty/doc
135         dodoc voice/doc/*
136
137         if use fax; then
138                 mv samples/new_fax.all samples_new_fax.all || die "move failed."
139                 docinto samples
140                 dodoc samples/*
141
142                 docinto samples/new_fax
143                 dodoc samples_new_fax.all/*
144         fi
145
146         if ! use fax; then
147                 insinto /usr/share/${PN}/frontends
148                 doins -r frontends/{voice,network}
149         else
150                 insinto /usr/share/${PN}
151                 doins -r frontends
152         fi
153         insinto /usr/share/${PN}
154         doins -r patches
155         insinto /usr/share/${PN}/voice
156         doins -r voice/{contrib,Perl,scripts}
157
158         diropts -m 0750 -o fax -g fax
159         dodir /var/spool/voice
160         keepdir /var/spool/voice/incoming
161         keepdir /var/spool/voice/messages
162         if use fax; then
163                 dodir /var/spool/fax
164                 dodir /var/spool/fax/outgoing
165                 keepdir /var/spool/fax/outgoing/locks
166                 keepdir /var/spool/fax/incoming
167         fi
168 }
169
170 pkg_postinst() {
171         elog "Users who wish to use the fax or voicemail capabilities must be members"
172         elog "of the group fax in order to access files"
173         elog
174         elog "If you want to grab voice messages from a remote location, you must save"
175         elog "the password in /var/spool/voice/.code file"
176 }