File rhnsd.spec of Package rhnsd
#
# spec file for package rhnsd
#
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
# Macros that aren't defined in debbuild
%if %{_vendor} == "debbuild"
%global _unitdir /lib/systemd/system
%global _initrddir /etc/init.d
%global is_deb 1
%global _buildshell /bin/bash
%endif
Summary: Spacewalk query daemon
License: GPL-2.0-only
Group: utils
Name: rhnsd
Version: 5.0.44
Release: 1.git.0.e0506f8%{?dist}
%if %{_vendor} == "debbuild"
%endif
Source0: rhnsd-git-0.ab34d7c.tar.gz
URL: https://github.com/spacewalkproject/spacewalk
%if 0%{?fedora} || 0%{?suse_version} >= 1210 || 0%{?mageia} || 0%{?ubuntu} >= 1504 || 0%{?debian} >= 8 || 0%{?rhel} >= 7
BuildArch: noarch
%endif
%if %{_vendor} != "debbuild"
%if 0%{?suse_version} >= 1210 || 0%{?fedora} || 0%{?mageia} || 0%{?rhel} >= 7
%{?mageia:BuildRequires: systemd-devel}
%{?suse_version:BuildRequires: systemd-rpm-macros}
BuildRequires: systemd
%{?systemd_requires}
%endif
%if 0%{?suse_version}
Requires(post): aaa_base
Requires(preun): aaa_base
BuildRequires: sysconfig
%else
%if 0%{?fedora} || 0%{?rhel} >= 7
Requires(post): chkconfig
Requires(preun): chkconfig
Requires(post): systemd-sysv
Requires(preun): systemd-sysv
%else
Requires(post): chkconfig
Requires(preun): chkconfig
# This is for /sbin/service
Requires(preun): initscripts
Requires(postun): initscripts
%endif
%endif
%endif
%if %{_vendor} == "debbuild"
BuildRequires: init-system-helpers
%if 0%{?debian} >= 8 || 0%{?ubuntu} >= 1504
BuildRequires: systemd
Requires(post): systemd
Requires(preun): systemd
Requires(postun): systemd
%endif
%endif
BuildRequires: gettext
Requires: rhn-check >= 0.0.8
BuildRequires: gcc
%description
The Red Hat Update Agent that automatically queries the Red Hat
Network servers and determines which packages need to be updated on
your machine, and runs any actions.
%prep
%setup -q -n rhnsd-git-0.ab34d7c
%build
make -f Makefile.rhnsd %{?_smp_mflags} CFLAGS="-pie -fPIE -Wl,-z,relro,-z,now %{optflags}" %{?is_deb:PLATFORM=deb}
%install
make -f Makefile.rhnsd install VERSION=%{version}-%{release} PREFIX=$RPM_BUILD_ROOT MANPATH=%{_mandir} INIT_DIR=$RPM_BUILD_ROOT/%{_initrddir} %{?is_deb:PLATFORM=deb} CONFIG_DIR=$RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/rhn
%if %{_vendor} != "debbuild"
%if 0%{?suse_version} && 0%{?suse_version} < 1210
install -m 0755 rhnsd.init.SUSE $RPM_BUILD_ROOT/%{_initrddir}/rhnsd
%endif
%endif
%if %{_vendor} == "debbuild"
install -m 0755 rhnsd.init.Debian $RPM_BUILD_ROOT/%{_initrddir}/rhnsd
%endif
%if 0%{?fedora} || 0%{?suse_version} >= 1210 || 0%{?mageia} || 0%{?ubuntu} >= 1504 || 0%{?debian} >= 8 || 0%{?rhel} >= 7
rm $RPM_BUILD_ROOT/%{_initrddir}/rhnsd
mkdir -p $RPM_BUILD_ROOT/%{_unitdir}
install -m 0644 rhnsd.service $RPM_BUILD_ROOT/%{_unitdir}/
install -m 0644 rhnsd.timer $RPM_BUILD_ROOT/%{_unitdir}/
%else
# find_lang not available on debbuild; we'll work around this below
%if %{_vendor} != "debbuild"
%find_lang %{name}
%endif
%endif
# These will not work with debbuild
%if %{_vendor} != "debbuild"
%{!?systemd_post: %global systemd_post() if [ $1 -eq 1 ] ; then /usr/bin/systemctl enable %%{?*} >/dev/null 2>&1 || : ; fi; }
%{!?systemd_preun: %global systemd_preun() if [ $1 -eq 0 ] ; then /usr/bin/systemctl --no-reload disable %%{?*} > /dev/null 2>&1 || : ; /usr/bin/systemctl stop %%{?*} > /dev/null 2>&1 || : ; fi; }
%{!?systemd_postun_with_restart: %global systemd_postun_with_restart() /usr/bin/systemctl daemon-reload >/dev/null 2>&1 || : ; if [ $1 -ge 1 ] ; then /usr/bin/systemctl try-restart %%{?*} >/dev/null 2>&1 || : ; fi; }
%endif
%if 0%{?fedora} || 0%{?suse_version} >= 1210 || 0%{?mageia} || 0%{?ubuntu} >= 1504 || 0%{?debian} >= 8 || 0%{?rhel} >= 7
rm -f $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/rhn/rhnsd
rm -f $RPM_BUILD_ROOT/%{_sbindir}/rhnsd
rm -rf $RPM_BUILD_ROOT/%{_datadir}/locale
%endif
%if 0%{?suse_version} >= 1210
%pre
%service_add_pre rhnsd.timer
%endif
%post
%if %{_vendor} != "debbuild"
%if 0%{?suse_version} >= 1210
%service_add_post rhnsd.timer
%else
if [ -f /etc/init.d/rhnsd ]; then
/sbin/chkconfig --add rhnsd
fi
if [ -f %{_unitdir}/rhnsd.service ]; then
%systemd_post rhnsd.timer
if [ "$1" = "2" ]; then
# upgrade from old init.d
if [ -L /etc/rc2.d/S97rhnsd ]; then
/usr/bin/systemctl enable rhnsd.timer >/dev/null 2>&1
fi
rm -f /etc/rc?.d/[SK]??rhnsd
fi
fi
%endif
%endif
%if %{_vendor} == "debbuild"
if [ -f %{_initrddir}/rhnsd ] && ( [ "$1" == "configure" ] || [ "$1" == "abort-upgrade" ] ); then
update-rc.d rhnsd defaults >/dev/null 2>&1 || :
fi
if [ -f %{_unitdir}/rhnsd.service ] && [ "$1" == "configure" ]; then
systemctl preset rhnsd.timer >/dev/null 2>&1 || :
fi
%endif
%preun
%if %{_vendor} != "debbuild"
%if 0%{?suse_version} >= 1210
%service_del_preun rhnsd.timer
%else
if [ $1 = 0 ] ; then
%if 0%{?fedora} || 0%{?mageia} || 0%{?rhel} >= 7
%systemd_preun rhnsd.timer
%else
service rhnsd stop >/dev/null 2>&1
%endif
if [ -f /etc/init.d/rhnsd ]; then
/sbin/chkconfig --del rhnsd
fi
fi
%endif
%endif
%if %{_vendor} == "debbuild"
if [ -f %{_initrddir}/rhnsd ] || [ -e "/etc/init/rhnsd.conf" ]; then
update-rc.d -f rhnsd remove || exit $?
fi
if [ -f %{_unitdir}/rhnsd.service ] && ( [ "$1" == "remove" ] || [ "$1" == "purge" ] ); then
systemctl --no-reload disable rhnsd.timer >/dev/null 2>&1 || :
systemctl stop rhnsd.timer >/dev/null 2>&1 || :
fi
%endif
%postun
%if %{_vendor} != "debbuild"
%if 0%{?suse_version} >= 1210
%service_del_postun rhnsd.timer
%else
if [ "$1" -ge "1" ]; then
%if 0%{?fedora} || 0%{?mageia} || 0%{?rhel} >= 7
%systemd_postun_with_restart rhnsd.timer
%else
service rhnsd condrestart >/dev/null 2>&1 || :
%endif
fi
%endif
%endif
%if %{_vendor} == "debbuild"
if [ -f {_initrddir}/rhnsd ] && [ "$1" == "purge" ]; then
update-rc.d rhnsd remove >/dev/null
fi
if [ -f %{_unitdir}/rhnsd.service ]; then
systemctl daemon-reload >/dev/null 2>&1 || :
fi
%endif
%if 0%{?fedora} || 0%{?suse_version} >= 1210 || 0%{?mageia} || 0%{?ubuntu} >= 1504 || 0%{?debian} >= 8 || 0%{?rhel} >= 7
%files
%{_unitdir}/rhnsd.service
%{_unitdir}/rhnsd.timer
%else
%files -f %{name}.lang
%dir %{_sysconfdir}/sysconfig/rhn
%config(noreplace) %{_sysconfdir}/sysconfig/rhn/rhnsd
%{_sbindir}/rhnsd
%{_initrddir}/rhnsd
%endif
%{_mandir}/man8/rhnsd.8*
%doc LICENSE
%if %{_vendor} == "debbuild"
%{_datadir}/locale/
%endif
%changelog