%bcond_with ifupdown

%define _tmpfilesdir %{_sysconfdir}/tmpfiles.d

Summary: The PPP (Point-to-Point Protocol) daemon.
Summary(ja): PPP (Point-to-Point Protocol) デーモン
Name: ppp
Version: 2.4.7
Release: 3%{?_dist_release}
License: BSD and LGPLv2+ and GPLv2+ and Public Domain
Group: System Environment/Daemons
URL: http://www.samba.org/ppp

Source0: ftp://ftp.samba.org/pub/ppp/ppp-%{version}.tar.gz
Source1: ppp-pam.conf
Source2: ppp-logrotate.conf
Source3: ppp-tmpfiles.conf
Source4: ip-down
Source5: ip-down.ipv6to4
Source6: ip-up
Source7: ip-up.ipv6to4
Source8: ipv6-down
Source9: ipv6-up
Source10: ifup-ppp
Source11: ifdown-ppp
Source12: ppp-watch.tar.xz

# Fedora-specific
Patch0001: 0001-build-sys-use-gcc-as-our-compiler-of-choice.patch
Patch0002: 0002-build-sys-enable-PAM-support.patch
Patch0003: 0003-build-sys-utilize-compiler-flags-handed-to-us-by-rpm.patch
Patch0004: 0004-doc-add-configuration-samples.patch
Patch0005: 0005-build-sys-don-t-hardcode-LIBDIR-but-set-it-according.patch
Patch0006: 0006-scritps-use-change_resolv_conf-function.patch
Patch0007: 0007-build-sys-don-t-strip-binaries-during-installation.patch
Patch0008: 0008-build-sys-use-prefix-usr-instead-of-usr-local.patch
Patch0009: 0009-pppd-introduce-ipv6-accept-remote.patch
Patch0010: 0010-build-sys-enable-CBCP.patch
Patch0011: 0011-build-sys-don-t-put-connect-errors-log-to-etc-ppp.patch
Patch0012: 0012-pppd-we-don-t-want-to-accidentally-leak-fds.patch
Patch0013: 0013-everywhere-O_CLOEXEC-harder.patch
Patch0014: 0014-everywhere-use-SOCK_CLOEXEC-when-creating-socket.patch
Patch0015: 0015-pppd-move-pppd-database-to-var-run-ppp.patch
Patch0016: 0016-rp-pppoe-add-manpage-for-pppoe-discovery.patch
Patch0017: 0017-pppd-rebase-EAP-TLS-patch-v0.994.patch
Patch0018: 0018-scritps-fix-ip-up.local-sample.patch
Patch0019: 0019-sys-linux-rework-get_first_ethernet.patch
Patch0020: 0020-pppd-put-lock-files-in-var-lock-ppp.patch
Patch0021: 0021-build-sys-compile-pppol2tp-plugin-with-RPM_OPT_FLAGS.patch
Patch0022: 0022-build-sys-compile-pppol2tp-with-multilink-support.patch
Patch0023: 0023-build-sys-install-rp-pppoe-plugin-files-with-standar.patch
Patch0024: 0024-build-sys-install-pppoatm-plugin-files-with-standard.patch
Patch0025: 0025-pppd-install-pppd-binary-using-standard-perms-755.patch

BuildRoot: %{_tmppath}/%{name}-%{version}-root
BuildRequires: glib2-devel, libpcap >= 0.8.3, eudev-libudev-devel, openssl-devel, pam-devel
#Requires: glibc >= 2.0.6, /etc/pam.d/system-auth
Requires: glibc >= 2.0.6, pam >= 1.0
Requires(pre): shadow-utils

Vendor: Project Vine
Distribution: Vine Linux
Packager: daisuke

%description
The ppp package contains the PPP (Point-to-Point Protocol) daemon and
documentation for PPP support.  The PPP protocol provides a method for
transmitting datagrams over serial point-to-point links. PPP is
usually used to dial in to an ISP (Internet Service Provider) or other
organization over a modem and phone line.

%description -l ja
ppp パッケージには PPP (Point-to-Point Protocol) デーモンと
PPP を使う為のドキュメントが収められています．PPP プロトコルを
使うとシリアルな point-to-point 接続上でデータグラムを転送する
事が出来ます．この PPP は一般的には ISP (Internet Service Provider) 等に
モデムを介した電話回線で接続する際に使われます．


%package devel
Summary: Headers for ppp plugin development
SUmmary(ja): ppp プラグイン開発用ヘッダファイル
Group: Development/Libraries

%description devel
This package contains the header files for building plugins for ppp.

%description -l ja devel
このパッケージには ppp のプラグインを開発するためのヘッダファイルが
含まれています。

%prep
%setup  -q
%autopatch -p1

tar -xJf %{SOURCE12}

%build
export RPM_OPT_FLAGS="$RPM_OPT_FLAGS -fPIC -Wall"
%configure
make %{?_smp_mflags}
make -C ppp-watch %{?_smp_mflags}

%install
[ "%{buildroot}" != "/" ] && rm -rf %{buildroot}

%ifarch x86_64
make INSTROOT=%{buildroot} install install-etcppp LIBDIR=$RPM_BUILD_ROOT%{_libdir}/pppd/%{version}
%else
make INSTROOT=%{buildroot} install install-etcppp
%endif

find scripts -type f | xargs chmod a-x

make ROOT=%{buildroot} -C ppp-watch install

# create log files dir
mv -f %{buildroot}/usr/var %{buildroot}/

# install pam config
install -d %{buildroot}%{_sysconfdir}/pam.d
install -m 644 %{SOURCE1} %{buildroot}%{_sysconfdir}/pam.d/ppp

# install logrotate script
install -d %{buildroot}%{_sysconfdir}/logrotate.d
install -m 644 -p %{SOURCE2} %{buildroot}%{_sysconfdir}/logrotate.d/ppp

# install tmpfiles drop-in
install -d %{buildroot}%{_tmpfilesdir}
install -p %{SOURCE3} %{buildroot}%{_tmpfilesdir}/ppp.conf

# install scripts (previously owned by initscripts package)
install -d %{buildroot}%{_sysconfdir}/ppp
%if %{with ifupdown}
install -p %{SOURCE4} %{buildroot}%{_sysconfdir}/ppp/ip-down
install -p %{SOURCE5} %{buildroot}%{_sysconfdir}/ppp/ip-down.ipv6to4
install -p %{SOURCE6} %{buildroot}%{_sysconfdir}/ppp/ip-up
install -p %{SOURCE7} %{buildroot}%{_sysconfdir}/ppp/ip-up.ipv6to4
install -p %{SOURCE8} %{buildroot}%{_sysconfdir}/ppp/ipv6-down
install -p %{SOURCE9} %{buildroot}%{_sysconfdir}/ppp/ipv6-up
%endif

%if %{with ifupdown}
install -d %{buildroot}%{_sysconfdir}/sysconfig/network-scripts/
install -p %{SOURCE10} %{buildroot}%{_sysconfdir}/sysconfig/network-scripts/ifup-ppp
install -p %{SOURCE11} %{buildroot}%{_sysconfdir}/sysconfig/network-scripts/ifdown-ppp
%endif


%clean
rm -rf %{buildroot}


%pre
/usr/bin/getent group dip >/dev/null 2>&1 || /usr/sbin/groupadd -r -g 40 dip >/dev/null 2>&1 || :


%files
%defattr(-,root,root)
%doc FAQ README README.cbcp README.linux README.MPPE README.MSCHAP80 README.MSCHAP81 README.pwfd README.pppoe scripts sample README.eap-tls
%{_sbindir}/*
%{_libdir}/pppd
%{_mandir}/man8/chat.8*
%{_mandir}/man8/ppp-watch.8*
%{_mandir}/man8/pppd.8*
%{_mandir}/man8/pppdump.8*
%{_mandir}/man8/pppstats.8*
%{_mandir}/man8/pppd-radattr.8*
%{_mandir}/man8/pppd-radius.8*
%{_mandir}/man8/pppoe-discovery.8*
%dir /etc/ppp
%config(noreplace) /etc/ppp/*
%config(noreplace) /etc/pam.d/ppp
%config(noreplace) /etc/logrotate.d/ppp
%{_tmpfilesdir}/ppp.conf
%ghost %dir %{_localstatedir}/run/ppp
%ghost %dir %{_localstatedir}/lock/ppp
%attr(700, root, root) %dir %{_localstatedir}/log/ppp

%if %{with ifupdown}
/etc/sysconfig/network-scripts/ifup-ppp
/etc/sysconfig/network-scripts/ifdown-ppp
%endif

%files devel
%defattr(-,root,root)
%{_includedir}/pppd
%doc PLUGINS


%changelog
* Sun Jun 19 2016 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.4.7-3
- changed permissions for /etc/logrotate.d/ppp from 755 to 644.

* Sun May 15 2016 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.4.7-2
- rebuild with openssl-1.0.2

* Tue Aug 19 2014 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.4.7-1
- new upstream release.

* Tue Jun 24 2014 Yoji TOYODA <bsyamato@sea.plala.or.jp> 2.4.6-2
- change BuildRequires: eudev-libudev-devel instead of libudev-devel

* Wed Jun 18 2014 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.4.6-1
- new upstream release.
- replaceed all patches.

* Tue Sep 06 2011 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.4.5-4
- added /var/run/ppp to %%files. (BTS:1215)
- added /var/log/ppp to %%files.

* Mon Apr 25 2011 Daisuke SUZUKI <daisuke@linux.or.jp> 2.4.5-3
- remove include/linux/if_pppol2tp.h to build pppoe plugin
- update License tag

* Fri Apr 08 2011 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.4.5-2
- rebuilt with new toolchain.

* Mon Mar 08 2010 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.4.5-1
- new upstream release.
- replaced all patches with Fedora's.
- replaced 'BuildPreReq:' with 'BuildRequires:'.

* Sun Aug 23 2009 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> 2.4.4-4
- update pam.d/ppp to fix pam-1.0

* Thu Aug 14 2008 Shu KONNO <owa@bg.wakwak.com> 2.4.4-3
- added option LIBDIR at makeinstall for x86_64

* Thu Jul 31 2008 Daisuke SUZUKI <daisuke@linux.or.jp> 2.4.4-2
- add -devel subpackage to develop ppp plugins

* Wed Jun 25 2008 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 2.4.4-1
- update Source1 for pam-1.0.1
- import several patches from Fedora 2.4.4-7

* Sat Jul  7 2007 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 2.4.4-0vl1
- new upstream release
- rebuilt with new toolchain and environment
- added URL (also URL of Source0)

* Fri Nov 17 2006 NAKAMURA Kenta <kenta@vinelinux.org> 2.4.3-0vl2
- use License: instead of Copyright:

* Mon Jan 24 2005 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net> 2.4.3-0vl1
- new upstream release.
- replace patch0.

* Wed Aug 11 2004 Tomohiro 'Tomo-p' KATO <tomop@teamgedoh.net> 2.4.2-0vl0
- new upstream release.
- remove patch 2-4 (no longer needed).

* Sat Mar 15 2003 <ryo1@bc.wakwak.com> 2.4.1-0vl2
- rebuild with new toolchains

* Sun Jun 10 2001 <sagami@vinelinux.org>
- 2.4.1-0vl1: update to 2.4.1

* Thu Jan 25 2001 MATSUBAYASHI 'Shaolin' Kohji <shaolin@rhythmaning.org>
- 2.4.0-2vl1
- based on 2.4.0-2 from Rawhide
- added Japanese summary and description
- Requires: /etc/pam.d/system-auth -> pam >= 0.72
  (for better compatibility with apt for rpm)

* Fri Dec  1 2000 Nalin Dahyabhai <nalin@redhat.com>
- rebuild in new environment

* Thu Nov  9 2000 Nalin Dahyabhai <nalin@redhat.com>
- update to 2.4.0

* Wed Jul 12 2000 Prospector <bugzilla@redhat.com>
- automatic rebuild

* Mon Jun  5 2000 Nalin Dahyabhai <nalin@redhat.com>
- move man pages to %{_mandir}

* Thu Jun  1 2000 Nalin Dahyabhai <nalin@redhat.com>
- change perms using defattr
- modify PAM setup to use system-auth

* Sun Mar 26 2000 Florian La Roche <Florian.La Roche@redhat.com>
- change to root:root perms

* Mon Mar 06 2000 Nalin Dahyabhai <nalin@redhat.com>
- reaper bugs verified as fixed
- check pam_open_session result code (bug #9966)

* Mon Feb 07 2000 Nalin Dahyabhai <nalin@redhat.com>
- take a shot at the wrong reaper bugs (#8153, #5290)

* Thu Feb 03 2000 Nalin Dahyabhai <nalin@redhat.com>
- free ride through the build system (release 2)

* Tue Jan 18 2000 Nalin Dahyabhai <nalin@redhat.com>
- Update to 2.3.11

* Sat Nov 06 1999 Michael K. Johnson <johnsonm@redhat.com>
- Better fix for both problems

* Fri Nov 05 1999 Michael K. Johnson <johnsonm@redhat.com>
- fix for double-dial problem
- fix for requiring a controlling terminal problem

* Sun Sep 19 1999 Preston Brown <pbrown@redhat.com>
- 2.3.10 bugfix release

* Fri Aug 13 1999 Michael K. Johnson <johnsonm@redhat.com>
- New version 2.3.9 required for kernel 2.3.13 and will be required
  for new initscripts.  auth patch removed; 2.3.9 does the same thing
  more readably than the previous patch.

* Thu Jun 24 1999 Cristian Gafton <gafton@redhat.com>
- add pppdump

* Fri Apr 09 1999 Cristian Gafton <gafton@redhat.com>
- force pppd use the glibc's logwtmp instead of implementing its own

* Thu Apr 01 1999 Preston Brown <pbrown@redhat.com>
- version 2.3.7 bugfix release

* Tue Mar 23 1999 Cristian Gafton <gafton@redhat.com>
- version 2.3.6

* Mon Mar 22 1999 Michael Johnson <johnsonm@redhat.com>
- auth patch

* Sun Mar 21 1999 Cristian Gafton <gafton@redhat.com> 
- auto rebuild in the new build environment (release 3)

* Thu Jan 07 1999 Cristian Gafton <gafton@redhat.com>
- build for glibc 2.1

* Fri Jun  5 1998 Jeff Johnson <jbj@redhat.com>
- updated to 2.3.5.

* Tue May 19 1998 Prospector System <bugs@redhat.com>
- translations modified for de

* Fri May  8 1998 Jakub Jelinek <jj@ultra.linux.cz>
- make it run with kernels 2.1.100 and above.

* Fri Apr 24 1998 Prospector System <bugs@redhat.com>
- translations modified for de, fr, tr

* Wed Mar 18 1998 Cristian Gafton <gafton@redhat.com>
- requires glibc 2.0.6 or later

* Wed Mar 18 1998 Michael K. Johnson <johnsonm@redhat.com>
- updated PAM patch to not turn off wtmp/utmp/syslog logging.

* Wed Jan  7 1998 Cristian Gafton <gafton@redhat.com>
- added the /etc/pam.d config file
- updated PAM patch to include session support

* Tue Jan  6 1998 Cristian Gafton <gafton@redhat.com>
- updated to ppp-2.3.3, build against glibc-2.0.6 - previous patches not
  required any more.
- added buildroot
- fixed the PAM support, which was really, completely broken and against any
  standards (session support is still not here... :-( )
- we build against running kernel and pray that it will work
- added a samples patch; updated glibc patch

* Thu Dec 18 1997 Erik Troan <ewt@redhat.com>
- added a patch to use our own route.h, rather then glibc's (which has 
  alignment problems on Alpha's) -- I only applied this patch on the Alpha,
  though it should be safe everywhere

* Fri Oct 10 1997 Erik Troan <ewt@redhat.com>
- turned off the execute bit for scripts in /usr/doc

* Fri Jul 18 1997 Erik Troan <ewt@redhat.com>
- built against glibc

* Tue Mar 25 1997 Erik Troan <ewt@redhat.com>
- Integrated new patch from David Mosberger
- Improved description

