diff --git a/hostname.spec b/hostname.spec index 871983d..d19a844 100644 --- a/hostname.spec +++ b/hostname.spec @@ -1,14 +1,19 @@ Summary: Utility to set/show the host name or domain name Name: hostname Version: 3.20 -Release: 4%{?dist} +Release: 5%{?dist} License: GPLv2+ Group: System Environment/Base URL: http://packages.qa.debian.org/h/hostname.html Source0: http://ftp.de.debian.org/debian/pool/main/h/hostname/hostname_%{version}.tar.gz Source1: https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt +Source2: nis-domainname +Source3: nis-domainname.service BuildRequires: gcc +# NOTE: We are *not* requiring systemd on purpose, because we want to allow +# hostname package to be installed in containers without the systemd. + # Initial changes Patch1: hostname-rh.patch @@ -18,7 +23,7 @@ DNS name, and to display or set its hostname or NIS domain name. %prep %setup -q -n hostname -cp %{SOURCE1} . +cp %{SOURCE1} %{SOURCE2} %{SOURCE3} . %patch1 -p1 %build @@ -27,14 +32,38 @@ make CFLAGS="%{optflags} $CFLAGS -D_GNU_SOURCE" LDFLAGS="$RPM_LD_FLAGS" %install make BASEDIR=%{buildroot} BINDIR=%{_bindir} install +install -m 0755 -d %{buildroot}%{_libexecdir}/%{name} +install -m 0755 -d %{buildroot}%{_prefix}/lib/systemd/system +install -m 0755 nis-domainname %{buildroot}%{_libexecdir}/%{name} +install -m 0644 nis-domainname.service %{buildroot}%{_prefix}/lib/systemd/system + +%post +if [ $1 -eq 1 ]; then + # Initial installation... + systemctl --no-reload preset nis-domainname.service &>/dev/null || : +fi + +%preun +if [ $1 -eq 0 ]; then + # Package removal, not upgrade... + systemctl --no-reload disable --now nis-domainname.service &>/dev/null || : +fi + +# NOTE: Nothing to do for upgrade (in postun), nis-domainname.service is oneshot. + %files %doc COPYRIGHT %{!?_licensedir:%global license %%doc} %license gpl-2.0.txt %{_bindir}/* %{_mandir}/man1/* +%{_prefix}/lib/systemd/system/* +%{_libexecdir}/%{name}/* %changelog +* Thu May 31 2018 David Kaspar [Dee'Kej] - 3.20-5 +- nis-domainname.service moved here from initscripts package + * Wed Mar 7 2018 Pavel Zhukov - 3.20-4 - Add gcc to BuildRequires diff --git a/nis-domainname b/nis-domainname new file mode 100755 index 0000000..b8d1059 --- /dev/null +++ b/nis-domainname @@ -0,0 +1,10 @@ +#!/usr/bin/bash + +source /etc/sysconfig/network + +if [ -n "${NISDOMAIN}" ] && [ -x /usr/bin/nisdomainname ]; then + nisdomainname ${NISDOMAIN} + exit $? +fi + +exit 0 diff --git a/nis-domainname.service b/nis-domainname.service new file mode 100644 index 0000000..9c92742 --- /dev/null +++ b/nis-domainname.service @@ -0,0 +1,14 @@ +[Unit] +Description=Read and set NIS domainname from /etc/sysconfig/network +Before=ypbind.service yppasswdd.service ypserv.service ypxfrd.service sysinit.target +DefaultDependencies=no +Conflicts=shutdown.target +ConditionPathExists=/etc/sysconfig/network + +[Service] +ExecStart=/usr/libexec/hostname/nis-domainname +Type=oneshot +RemainAfterExit=yes + +[Install] +WantedBy=sysinit.target