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