%bcond_with systemd

Summary: The basic tools for setting up networking.
Summary(ja): ネットワークをセットアップするための基本的なツール
Name: net-tools
Version: 2.10
Release: 1%{?_dist_release}%{?with_systemd:.systemd}
Group: system,network,admin-tools
Vendor: Project Vine
Distribution: Vine Linux

License: GPL
URL: https://sourceforge.net/projects/net-tools/
Source0: https://downloads.sourceforge.net/project/net-tools/net-tools-%{version}.tar.xz
Source1: net-tools-config.h
Source2: net-tools-config.make
Source3: ether-wake.c
Source4: ether-wake.8
Source5: mii-diag.c
Source6: mii-diag.8
Source7: iptunnel.8
Source8: ipmaddr.8
Source9: arp-ethers.service

# source for Vine
Source100: net-tools-2.10-ja.po

# adds <delay> option that allows netstat to cycle printing through statistics every delay seconds.
Patch1: net-tools-cycle.patch

# various man page fixes merged into one patch
Patch2: net-tools-man.patch

# linux-4.8
Patch3: net-tools-linux48.patch

# use all interfaces instead of default (#1003875)
Patch20: ether-wake-interfaces.patch

Patch24: net-tools-correct-exit-code.patch

BuildRoot: %{_tmppath}/%{name}-root
BuildRequires: bluez-libs-devel
%if %{with systemd}
%{?systemd_requires}
%endif


%description
The net-tools package contains the basic tools needed for setting up
networking:  ethers, route and others.

%description -l ja
net-tools パッケージはネットワークをセットアップする基本的なツールを
含んでいます: イーサーネット, ルーティングやその他


%debug_package


%prep
%setup -q
%patch1 -p1 -b .cycle
%patch2 -p1 -b .man
#patch3 -p1 -b .linux48

cp %SOURCE1 ./config.h
cp %SOURCE2 ./config.make
cp %SOURCE3 .
cp %SOURCE4 ./man/en_US
cp %SOURCE5 .
cp %SOURCE6 ./man/en_US
cp %SOURCE7 ./man/en_US
cp %SOURCE8 ./man/en_US

%patch20 -p1 -b .interfaces
%patch24 -p1 -b .exit-codes

touch ./config.h
cp %SOURCE100 po/ja.po


%build
export CFLAGS="${RPM_OPT_FLAGS} -fpie"
export LDFLAGS="${RPM_LD_FLAGS} -pie -Wl,-z,now"

make
make ether-wake
gcc ${RPM_OPT_FLAGS} ${RPM_LD_FLAGS} -o mii-diag mii-diag.c


%install
rm -rf $RPM_BUILD_ROOT

mv man/de_DE man/de
mv man/fr_FR man/fr
mv man/pt_BR man/pt

make BASEDIR=%{buildroot} mandir=%{_mandir} install

install -m 755 ether-wake %{buildroot}/sbin
install -m 755 mii-diag %{buildroot}/sbin

mv -f %{buildroot}/bin/{ifconfig,route} %{buildroot}/sbin/

rm %{buildroot}/sbin/rarp
rm %{buildroot}%{_mandir}/man8/rarp.8*
rm %{buildroot}%{_mandir}/de*/man8/rarp.8*
rm %{buildroot}%{_mandir}/fr*/man8/rarp.8*
rm %{buildroot}%{_mandir}/pt*/man8/rarp.8*

# otherwise %%find_lang finds them even they're empty
rm -rf %{buildroot}%{_mandir}/de/man1
rm -rf %{buildroot}%{_mandir}/fr/man1
rm -rf %{buildroot}%{_mandir}/man1
rm -rf %{buildroot}%{_mandir}/pt/man1
rm -rf %{buildroot}%{_mandir}/pt/man5

mkdir -p %{buildroot}%{_sysconfdir}
touch %{buildroot}%{_sysconfdir}/ethers
echo "# see man ethers for syntax" > %{buildroot}%{_sysconfdir}/ethers

%if %{with systemd}
# install systemd unit file
install -D -p -m 644 %{SOURCE9} %{buildroot}%{_unitdir}/arp-ethers.service
%endif

%find_lang %{name}


%clean
rm -rf $RPM_BUILD_ROOT


%if %{with systemd}
%post
%systemd_post arp-ethers.service
%endif


%files -f %{name}.lang
%defattr(-,root,root)
%license COPYING
/bin/*
/sbin/*
%{_mandir}/man[58]/*
%{_mandir}/de/man[58]/*
%{_mandir}/fr/man[58]/*
%{_mandir}/pt/man8/*
%config(noreplace) %{_sysconfdir}/ethers
%if %{with systemd}
%attr(0644,root,root)   %{_unitdir}/arp-ethers.service
%endif


%changelog
* Thu Feb 18 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 2.10-1
- new upstream release.
- updated Source100 (ja.po).
- dropped Patch100.
- added systemd support (disabled as default).

* Thu Nov 29 2018 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 1.60-17
- replace all patches from CentOS 6 (included previous patches).
- added Patch99 to build with new kernel-headers.

* Mon Jul 21 2014 Daisuke SUZUKI <daisuke@vinelinux.org> 1.60-16
- update config.{h,make}
  - CONFIG_HWSTRIP=0, CONFIG_HWTR=0

* Sat Aug 11 2012 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> 1.60-15vl6
- add patch22, 65 to fix <BTS:1329>

* Wed Apr 13 2011 Daisuke SUZUKI <daisuke@linux.or.jp> 1.60-14
- rebuild for Vine 6

* Wed Sep 10 2008 Shu KONNO <owa@bg.wakwak.com> 1.60-13vl5
- applied new versioning policy, spec in utf-8
- added net-tools-1.60-label.patch

* Fri Aug 18 2006 KAZUKI SHIMURA <kazuki@ma.ccnw.ne.jp> 1.60-12vl2
- add patches to build with current environment
  - x25_sr.patch (patch9)
  - gcc33.patch (patch10)
  - update ether-wake.c (source3)

* Sat May 31 2003 Ryoichi INAGAKI <ryo1@bc.wakwak.com> 1.60-12vl1
- update and replaced ja.po 
- sync with RedHat Rawhide 1.60-12

  - Fri Feb 07 2003 Phil Knirsch <pknirsch@redhat.com>
  - Fixed -s parameter.
  - Fix /proc statistics for -nic operation.
  - Fixed -i operation in general.

  - Tue Dec 17 2002 Phil Knirsch <pknirsch@redhat.com> 1.60-9
  - Copyright -> License.

  - Tue Aug 06 2002 Phil Knirsch <pknirsch@redhat.com> 
  - Added patch from Norm for a corrected output.

  - Fri Apr 12 2002 Jeremy Katz <katzj@redhat.com>
  - fix nstrcmp() to be correct in the case where there are many devices 
    of the same type, eg, "eth10" > "eth1"  (#61436)

  - Tue Jul 31 2001 Bill Nottingham <notting@redhat.com>
  - do *not* use SIOCDEVPRIVATE for MII ioctls

  - Fri Jun  1 2001 Preston Brown <pbrown@redhat.com>
  - include wake-on-lan wakeup utility, ether-wake by Donald Becker

* Sat May 12 2001 <sagami@vinelinux.org>
- 1.60-4vl1: follow up with RH 1.60-1

* Tue May 23 2000 Yasuyuki Furukawa <furukawa@vinelinux.org>
- sync with RH 6.2

* Tue Mar  7 2000 Jeff Johnson <jbj@redhat.com>
- rebuild for sparc baud rates > 38400.

* Wed Feb 02 2000 Cristian Gafton <gafton@redhat.com>
- fix description

* Fri Jan 14 2000 Jeff Johnson <jbj@redhat.com>
- fix "netstat -ci" (#6904).
- document more netstat options (#7429).

* Thu Jan 13 2000 Jeff Johnson <jbj@redhat.com>
- update to 1.54.
- enable "everything but DECnet" including IPv6.

* Mon Oct 11 1999 Norihito Ohmori <ohmori@flatout.org>
- ported from net-tools-1.51 with Japanese catalog
  by Yasuyuki Furukawa

* Sun Aug 29 1999 Jeff Johnson <jbj@redhat.com>
- update to 1.53.

* Wed Jul 28 1999 Jeff Johnson <jbj@redhat.com>
- plug "netstat -c" fd leak (#3620).

* Thu Jun 17 1999 Jeff Johnson <jbj@redhat.com>
- plug potential buffer overruns.

* Sat Jun 12 1999 John Hardin <jhardin@wolfenet.com>
- patch to recognize ESP and GRE protocols for VPN masquerade

* Fri Apr 23 1999 Jeff Johnson <jbj@redhat.com>
- update to 1.52.

* Thu Mar 25 1999 Jeff Johnson <jbj@redhat.com>
- update interface statistics continuously (#1323)

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

* Fri Mar 19 1999 Jeff Johnson <jbj@redhat.com>
- update to 1.51.
- strip binaries.

* Tue Feb  2 1999 Jeff Johnson <jbj@redhat.com>
- update to 1.50.
- added slattach/plipconfig/ipmaddr/iptunnel commands.
- enabled translated man pages.

* Tue Dec 15 1998 Jakub Jelinek <jj@ultra.linux.cz>
- update to 1.49.

* Sat Dec  5 1998 Jeff Johnson <jbj@redhat.com>
- update to 1.48.

* Thu Nov 12 1998 Jeff Johnson <jbj@redhat.com>
- update to 1.47.

* Wed Sep  2 1998 Jeff Johnson <jbj@redhat.com>
- update to 1.46

* Thu Jul  9 1998 Jeff Johnson <jbj@redhat.com>
- build root
- include ethers.5

* Thu Jun 11 1998 Aron Griffis <agriffis@coat.com>
- upgraded to 1.45
- patched hostname.c to initialize buffer
- patched ax25.c to use kernel headers

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

* Fri Feb 27 1998 Jason Spangler <jasons@usemail.com>
- added config patch

* Fri Feb 27 1998 Jason Spangler <jasons@usemail.com>
- changed to net-tools 1.432
- removed old glibc 2.1 patch
 
* Wed Oct 22 1997 Erik Troan <ewt@redhat.com>
- added extra patches for glibc 2.1

* Tue Oct 21 1997 Erik Troan <ewt@redhat.com>
- included complete set of network protocols (some were removed for
  initial glibc work)

* Wed Sep 03 1997 Erik Troan <ewt@redhat.com>
- updated glibc patch for glibc 2.0.5

* Thu Jun 19 1997 Erik Troan <ewt@redhat.com>
- built against glibc
- updated to 1.33
