8b88365fe12395f62cc061af8d1aad66d8c3427f
[gentoo.git] / net-dialup / ppp / ppp-2.4.7-r7.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 inherit linux-info multilib pam toolchain-funcs
7
8 PATCH_VER="7"
9 DESCRIPTION="Point-to-Point Protocol (PPP)"
10 HOMEPAGE="https://ppp.samba.org/"
11 SRC_URI="https://download.samba.org/pub/ppp/${P}.tar.gz
12         https://dev.gentoo.org/~polynomial-c/${P}-patches-${PATCH_VER}.tar.xz
13         http://www.netservers.net.uk/gpl/ppp-dhcpc.tgz"
14
15 LICENSE="BSD GPL-2"
16 SLOT="0/${PV}"
17 KEYWORDS="alpha amd64 arm ~arm64 hppa ia64 ~mips ppc ppc64 ~riscv ~s390 ~sh sparc x86"
18 IUSE="activefilter atm dhcp eap-tls gtk ipv6 libressl pam radius"
19
20 DEPEND="
21         activefilter? ( net-libs/libpcap )
22         atm? ( net-dialup/linux-atm )
23         pam? ( virtual/pam )
24         gtk? ( x11-libs/gtk+:2 )
25         !libressl? ( dev-libs/openssl:0= )
26         libressl? ( dev-libs/libressl:= )
27 "
28 RDEPEND="${DEPEND}"
29 PDEPEND="net-dialup/ppp-scripts"
30
31 src_prepare() {
32         mv "${WORKDIR}/dhcp" "${S}/pppd/plugins" || die
33
34         if ! use eap-tls ; then
35                 rm "${WORKDIR}"/patch/8?_all_eaptls-* || die
36         fi
37         eapply "${WORKDIR}"/patch
38
39         if use atm ; then
40                 einfo "Enabling PPPoATM support"
41                 sed -i '/^#HAVE_LIBATM=yes/s:#::' \
42                         pppd/plugins/pppoatm/Makefile.linux || die
43         fi
44
45         if ! use activefilter ; then
46                 einfo "Disabling active filter"
47                 sed -i '/^FILTER=y/s:^:#:' pppd/Makefile.linux || die
48         fi
49
50         if use pam ; then
51                 einfo "Enabling PAM"
52                 sed -i '/^#USE_PAM=y/s:^#::' pppd/Makefile.linux || die
53         fi
54
55         if use ipv6 ; then
56                 einfo "Enabling IPv6"
57                 sed -i '/#HAVE_INET6/s:#::' pppd/Makefile.linux || die
58                 echo "+ipv6" >> etc.ppp/options || die
59         fi
60
61         einfo "Enabling CBCP"
62         sed -i '/^#CBCP=y/s:#::' pppd/Makefile.linux || die
63
64         if use dhcp ; then
65                 einfo "Adding ppp-dhcp plugin files"
66                 sed \
67                         -e '/^SUBDIRS :=/s:$: dhcp:' \
68                         -i pppd/plugins/Makefile.linux || die
69         fi
70
71         # Set correct libdir
72         sed -i -e "s:/lib/pppd:/$(get_libdir)/pppd:" \
73                 pppd/{pathnames.h,pppd.8} || die
74
75         if use radius ; then
76                 #set the right paths in radiusclient.conf
77                 sed -e "s:/usr/local/etc:/etc:" \
78                         -e "s:/usr/local/sbin:/usr/sbin:" \
79                         -i pppd/plugins/radius/etc/radiusclient.conf || die
80                 #set config dir to /etc/ppp/radius
81                 sed -i -e "s:/etc/radiusclient:/etc/ppp/radius:g" \
82                         pppd/plugins/radius/{*.8,*.c,*.h} \
83                         pppd/plugins/radius/etc/* || die
84         else
85                 einfo "Disabling radius"
86                 sed -i -e '/+= radius/s:^:#:' pppd/plugins/Makefile.linux || die
87         fi
88
89         # Respect our pkg-config settings.
90         sed -i \
91                 -e 's:pkg-config:$(PKG_CONFIG):' \
92                 contrib/pppgetpass/Makefile.linux || die
93         sed -i \
94                 -e '/^LIBS/{s:-L/usr/local/ssl/lib::;s:-lcrypto:`$(PKG_CONFIG) --libs libcrypto`:}' \
95                 pppd/Makefile.linux || die
96
97         eapply_user #549588
98 }
99
100 src_compile() {
101         tc-export AR CC PKG_CONFIG
102         emake COPTS="${CFLAGS} -D_GNU_SOURCE"
103
104         # build pppgetpass
105         cd contrib/pppgetpass || die
106         if use gtk ; then
107                 emake -f Makefile.linux
108         else
109                 emake pppgetpass.vt
110         fi
111 }
112
113 src_install() {
114         local i
115         for i in chat pppd pppdump pppstats ; do
116                 doman ${i}/${i}.8
117                 dosbin ${i}/${i}
118         done
119         fperms u+s-w /usr/sbin/pppd
120
121         # Install pppd header files
122         emake -C pppd INSTROOT="${D}" install-devel
123
124         dosbin pppd/plugins/rp-pppoe/pppoe-discovery
125
126         dodir /etc/ppp/peers
127         insinto /etc/ppp
128         insopts -m0600
129         newins etc.ppp/pap-secrets pap-secrets.example
130         newins etc.ppp/chap-secrets chap-secrets.example
131
132         insopts -m0644
133         doins etc.ppp/options
134
135         pamd_mimic_system ppp auth account session
136
137         local PLUGINS_DIR="/usr/$(get_libdir)/pppd/${PV}"
138         # closing " for syntax coloring
139         insinto "${PLUGINS_DIR}"
140         insopts -m0755
141         doins pppd/plugins/minconn.so
142         doins pppd/plugins/passprompt.so
143         doins pppd/plugins/passwordfd.so
144         doins pppd/plugins/winbind.so
145         doins pppd/plugins/rp-pppoe/rp-pppoe.so
146         doins pppd/plugins/pppol2tp/openl2tp.so
147         doins pppd/plugins/pppol2tp/pppol2tp.so
148         if use atm ; then
149                 doins pppd/plugins/pppoatm/pppoatm.so
150         fi
151         if use dhcp ; then
152                 doins pppd/plugins/dhcp/dhcpc.so
153         fi
154         if use radius ; then
155                 doins pppd/plugins/radius/rad{ius,attr,realms}.so
156
157                 #Copy radiusclient configuration files (#92878)
158                 insinto /etc/ppp/radius
159                 insopts -m0644
160                 doins pppd/plugins/radius/etc/{dictionary*,issue,port-id-map,radiusclient.conf,realms,servers}
161
162                 doman pppd/plugins/radius/pppd-rad{ius,attr}.8
163         fi
164
165         insinto /etc/modprobe.d
166         insopts -m0644
167         newins "${FILESDIR}/modules.ppp" ppp.conf
168
169         dodoc PLUGINS README* SETUP Changes-2.3 FAQ
170         dodoc "${FILESDIR}/README.mpls"
171
172         dosbin scripts/p{on,off,log}
173         doman scripts/pon.1
174
175         # Adding misc. specialized scripts to doc dir
176         insinto /usr/share/doc/${PF}/scripts/chatchat
177         doins scripts/chatchat/*
178         insinto /usr/share/doc/${PF}/scripts
179         doins scripts/*
180
181         if use gtk ; then
182                 dosbin contrib/pppgetpass/{pppgetpass.vt,pppgetpass.gtk}
183                 newsbin contrib/pppgetpass/pppgetpass.sh pppgetpass
184         else
185                 newsbin contrib/pppgetpass/pppgetpass.vt pppgetpass
186         fi
187         doman contrib/pppgetpass/pppgetpass.8
188 }
189
190 pkg_postinst() {
191         if linux-info_get_any_version && linux_config_src_exists ; then
192                 echo
193                 ewarn "If the following test report contains a missing kernel configuration option that you need,"
194                 ewarn "you should reconfigure and rebuild your kernel before running pppd."
195                 CONFIG_CHECK="~PPP ~PPP_ASYNC ~PPP_SYNC_TTY"
196                 local ERROR_PPP="CONFIG_PPP:\t missing PPP support (REQUIRED)"
197                 local ERROR_PPP_ASYNC="CONFIG_PPP_ASYNC:\t missing asynchronous serial line discipline (optional, but highly recommended)"
198                 local WARNING_PPP_SYNC_TTY="CONFIG_PPP_SYNC_TTY:\t missing synchronous serial line discipline (optional; used by 'sync' pppd option)"
199                 if use activefilter ; then
200                         CONFIG_CHECK="${CONFIG_CHECK} ~PPP_FILTER"
201                         local ERROR_PPP_FILTER="CONFIG_PPP_FILTER:\t missing PPP filtering support (REQUIRED)"
202                 fi
203                 CONFIG_CHECK="${CONFIG_CHECK} ~PPP_DEFLATE ~PPP_BSDCOMP ~PPP_MPPE"
204                 local ERROR_PPP_DEFLATE="CONFIG_PPP_DEFLATE:\t missing Deflate compression (optional, but highly recommended)"
205                 local ERROR_PPP_BSDCOMP="CONFIG_PPP_BSDCOMP:\t missing BSD-Compress compression (optional, but highly recommended)"
206                 local WARNING_PPP_MPPE="CONFIG_PPP_MPPE:\t missing MPPE encryption (optional, mostly used by PPTP links)"
207                 CONFIG_CHECK="${CONFIG_CHECK} ~PPPOE ~PACKET"
208                 local WARNING_PPPOE="CONFIG_PPPOE:\t missing PPPoE support (optional, needed by rp-pppoe plugin)"
209                 local WARNING_PACKET="CONFIG_PACKET:\t missing AF_PACKET support (optional, used by rp-pppoe and dhcpc plugins)"
210                 if use atm ; then
211                         CONFIG_CHECK="${CONFIG_CHECK} ~PPPOATM"
212                         local WARNING_PPPOATM="CONFIG_PPPOATM:\t missing PPPoA support (optional, needed by pppoatm plugin)"
213                 fi
214                 check_extra_config
215         fi
216
217         # create *-secrets files if not exists
218         [ -f "${ROOT}/etc/ppp/pap-secrets" ] || \
219                 cp -pP "${ROOT}/etc/ppp/pap-secrets.example" "${ROOT}/etc/ppp/pap-secrets"
220         [ -f "${ROOT}/etc/ppp/chap-secrets" ] || \
221                 cp -pP "${ROOT}/etc/ppp/chap-secrets.example" "${ROOT}/etc/ppp/chap-secrets"
222
223         # lib name has changed
224         sed -i -e "s:^pppoe.so:rp-pppoe.so:" "${ROOT}/etc/ppp/options" || die
225
226         echo
227         elog "Pon, poff and plog scripts have been supplied for experienced users."
228         elog "Users needing particular scripts (ssh,rsh,etc.) should check out the"
229         elog "/usr/share/doc/${PF}/scripts directory."
230 }