File sysvinit.spec of Package sysvinit

# spec file for package sysvinit
# Copyright (c) 2014 SUSE LINUX Products 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

%if 0%{suse_version} < 1300
%global         with_util_linux 1
%bcond_with	util_linux
%if %{undefined systemd_requires}
%bcond_without  sysvinit
%bcond_with     sysvinit

%if 0%{?suse_version} > 1310
%define have_mkinitrd 0
%define have_mkinitrd 1

Name:           sysvinit
%define KPVER  2.21
%define SCVER  1.16
%define SIVER  2.88+
%define START  0.58
Version:        %{SIVER}
Release:        0
Summary:        SysV-Style init
License:        GPL-2.0+
Group:          System/Base
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  audit-devel
BuildRequires:  libselinux-devel
BuildRequires:  libsepol-devel
BuildRequires:  pam-devel
%if 0%{?suse_version} > 1140
%if 0%{?suse_version} > 1230
BuildRequires:  systemd-rpm-macros
BuildRequires:  pkg-config
BuildRequires:  systemd-devel
#!BuildIgnore:  sysvinit-tools
Requires(post): coreutils grep
%if %have_mkinitrd
Requires(post): mkinitrd
Requires(postun): mkinitrd
Source:         sysvinit-%{SIVER}dsf.tar.bz2
Source2:        killproc-%{KPVER}.tar.bz2
Source4:        showconsole-%{SCVER}.tar.bz2
Source5:        startpar-%{START}.tar.bz2
Source7:        %{name}-rpmlintrc
Patch:          %{name}-%{version}dsf.dif
Patch1:         %{name}-2.82-startstop.patch
Patch2:         %{name}-2.88dsf-suse.patch
Patch3:         %{name}-2.88dsf-scripts2.patch
Patch4:         notify-pam-dead.patch
Patch5:         %{name}-2.88dsf-multiple-sulogin.patch
Patch6:         %{name}-%{version}dsf-run.diff
Patch7:         %{name}-%{version}dsf-crypt.patch
Patch8:         %{name}-%{version}dsf-blowfish.dif
Patch9:         %{name}-2.88dsf-no-kill.patch
Patch10:        %{name}-%{version}dsf-env.patch
Patch11:        %{name}-%{version}dsf-dostat.patch
# PATCH-FIX-UPSTREAM -- killall5: handle strange names of executables
Patch12:        %{name}-%{version}dsf-sulogin.diff
# PATCH-FIX-SUSE -- sulogin: find suitable console device even if first is not usable
Patch13:        %{name}-%{version}dsf-xen.patch
Patch30:        killproc-%{KPVER}.dif
Patch31:        killproc-2.18-open_flags.dif
Patch40:        showconsole-%{SCVER}.dif
Patch41:        showconsole-1.16-deadlock.diff
Patch42:        showconsole-1.16-glibc.dif
Patch50:        startpar-%{START}.dif
Requires:       mingetty
Requires:       sysvinit-tools

System V style init programs by Miquel van Smoorenburg that control the
booting and shutdown of your system. These support a number of system
runlevels, each one associated with a specific set of utilities. For
example, the normal system runlevel is 3, which starts a getty on
virtual consoles tty1-tty6. Runlevel 5 starts xdm. Runlevel 0 shuts
down the system. See the individual man pages for inittab, initscript,
halt, init, powerd, reboot, runlevel, shutdown, and telinit for 
more information.

%package tools
Summary:        Tools for basic booting
Group:          System/Base
%if 0%{suse_version} > 1120
Requires(preun):  coreutils %insserv_prereq
Requires(postun): coreutils %insserv_prereq
PreReq:         coreutils %insserv_prereq

%description tools
Helper tools from sysvinit that support booting, including but not exclusive
to startpar, killproc and pidof. System V init specific programs are in the 
sysvinit package.

%package init
Summary:        Provides /sbin/init for sysvinit
Group:          System/Base
Provides:       sbin_init
Conflicts:      otherproviders(sbin_init)
Requires:       %{name}
%ifnarch s390 s390x
Requires:       powerd

%description init
Just some symlinks and manual page for sysvinit

%setup -n %{name}-%{SIVER}dsf -q -b 2 -b 4 -b 5
%patch1  -p0 -b .startstop
%patch2  -p0 -b .suse
%patch3  -p0 -b .scripts2
%patch4  -p0 -b .pam
%patch5  -p0 -b .sulogin
%patch6  -p0 -b .run
%patch7  -p0 -b .crypt
%patch8  -p0 -b .blowfish
%patch9  -p0 -b .no-kill
%patch10 -p0 -b .env
%patch11 -p0 -b .dostat
%patch12 -p0 -b .ka5
%patch13 -p0 -b .xen
pushd doc
  mkdir killproc showconsole
pushd ../killproc-%{KPVER}
%patch31 -p0 -b .dialog
ln -t../%{name}-%{SIVER}dsf/doc/killproc README
pushd ../showconsole-%{SCVER}
%patch41 -p1
%patch42 -p0
ln -t../%{name}-%{SIVER}dsf/doc/showconsole README
pushd ../startpar-%{START}
%_fixowner .
%_fixgroup .
/bin/chmod -Rf a+rX,g-w,o-w .

  make %{?_smp_mflags} WITH_SELINUX=yes DISTRO=SuSE
pushd ../showconsole-%{SCVER}
  make %{?_smp_mflags} CC="%__cc"
pushd ../killproc-%{KPVER}
  make %{?_smp_mflags} INC="-I../showconsole-%{SCVER} -L../showconsole-%{SCVER}" CC="%__cc"
pushd ../startpar-%{START}
  make %{?_smp_mflags} INC="-I../showconsole-%{SCVER} -L../showconsole-%{SCVER}" CC="%__cc"

  rm -rf %{buildroot}
  mkdir  %{buildroot}
  mkdir -m 755 -p %{buildroot}/bin
  mkdir -m 755 -p %{buildroot}/dev
  mkdir -m 755 -p %{buildroot}/etc
  mkdir -m 755 -p %{buildroot}/sbin
  mkdir -m 755 -p %{buildroot}/usr/bin
  mkdir -m 755 -p %{buildroot}/usr/include
  mkdir -m 755 -p %{buildroot}%{_mandir}/man1
  mkdir -m 755 -p %{buildroot}%{_mandir}/man5
  mkdir -m 755 -p %{buildroot}%{_mandir}/man8
  make install -C src MANPATH=%{_mandir} ROOT=%{buildroot} WITH_SELINUX=yes DISTRO=SuSE
  mv %{buildroot}/sbin/init %{buildroot}/sbin/sysvinit
  mv %{buildroot}%{_mandir}/man8/init.8 %{buildroot}/%{_mandir}/man8/sysvinit.8
  ln -s /sbin/sysvinit %{buildroot}/sbin/init
  ln -s sysvinit.8 %{buildroot}%{_mandir}/man8/init.8
  mkdir -p %{buildroot}/lib/sysvinit
  ln -sf /sbin/sysvinit %{buildroot}/lib/sysvinit/telinit
  ln -sf /sbin/sysvinit %{buildroot}/sbin/telinit
  test -p     %{buildroot}/dev/initctl || {
    rm -f     %{buildroot}/dev/initctl
    mknod     %{buildroot}/dev/initctl p
    chmod 600 %{buildroot}/dev/initctl
pushd ../showconsole-%{SCVER}
  make install MANPATH=%{_mandir} INSTBINFLAGS="-m 0700" DESTDIR=%{buildroot}
pushd ../killproc-%{KPVER}
  make install MANPATH=%{_mandir} INSTBINFLAGS="-m 0755" DESTDIR=%{buildroot}
pushd ../startpar-%{START}
  make install DESTDIR=%{buildroot}
# Install mkinitrd scriptlets
%if %have_mkinitrd
  install -d %{buildroot}/lib/mkinitrd/scripts
  install -m 0755 %{SOURCE8} %{buildroot}/lib/mkinitrd/scripts/
  install -m 0755 %{SOURCE9} %{buildroot}/lib/mkinitrd/scripts/
  install -m 0755 %{SOURCE10} %{buildroot}/lib/mkinitrd/scripts/
# Remove files not packed:
  rm -f %{buildroot}/usr/include/{initreq.h,libblogger.h}
  rm -f %{buildroot}/usr/lib/libblogger.a
  rm -f %{buildroot}%{_mandir}/man1/mesg.1*
  chmod 444 %{buildroot}%{_mandir}/man?/*
%if ! %{with util_linux}
  rm -vf %{buildroot}/bin/mountpoint
  rm -vf %{buildroot}/usr/bin/utmpdump
  rm -vf %{buildroot}/sbin/sulogin
  rm -vf %{buildroot}%{_mandir}/man1/mountpoint.1*
  rm -vf %{buildroot}%{_mandir}/man1/utmpdump.1*
  rm -vf %{buildroot}%{_mandir}/man8/sulogin.8*
%if !%{with sysvinit}
  rm -vf  %{buildroot}/sbin/sysvinit
  rm -vfr %{buildroot}/lib/sysvinit
  rm -vf  %{buildroot}/sbin/halt
  rm -vf  %{buildroot}/sbin/init
  rm -vf  %{buildroot}/sbin/poweroff
  rm -vf  %{buildroot}/sbin/reboot
  rm -vf  %{buildroot}/sbin/runlevel
  rm -vf  %{buildroot}/sbin/shutdown
  rm -vf  %{buildroot}/sbin/telinit
  rm -vf  %{buildroot}%{_mandir}/man8/halt.8
  rm -vf  %{buildroot}%{_mandir}/man5/initscript.5
  rm -vf  %{buildroot}%{_mandir}/man5/inittab.5
  rm -vf  %{buildroot}%{_mandir}/man8/init.8
  rm -vf  %{buildroot}%{_mandir}/man8/sysvinit.8
  rm -vf  %{buildroot}%{_mandir}/man8/poweroff.8
  rm -vf  %{buildroot}%{_mandir}/man8/reboot.8
  rm -vf  %{buildroot}%{_mandir}/man8/runlevel.8
  rm -vf  %{buildroot}%{_mandir}/man8/shutdown.8
  rm -vf  %{buildroot}%{_mandir}/man8/telinit.8
  rm -vfr %{buildroot}/lib/mkinitrd

%if %{with sysvinit}
if test -x /sbin/telinit -a -p /dev/initctl -a -f /proc/1/exe -a -d /proc/1/root -a ! -d /.build -a -x /sbin/init; then
    icount=$(grep -cE '^[[:alnum:]]+:[[:alnum:]]*:' /etc/inittab 2>/dev/null || echo 0)
    if test $(stat -Lc '%%D-%%i' /) = $(stat -Lc '%%D-%%i' /proc/1/root) -a $icount -gt 6 ; then
	if test $(stat -Lc '%%D-%%i' /sbin/init) = $(stat -Lc '%%D-%%i' /sbin/sysvinit); then
	    /sbin/telinit u
    elif test $icount -le 6 ; then
	echo 'Broken /etc/inittab found, installing and using %{name} make no sense!' 1>&2
%if %have_mkinitrd
if test -x /sbin/mkinitrd_setup; then
exit $ret

%if %have_mkinitrd
if test -x /sbin/mkinitrd_setup; then

%defattr (-,root,root,755)
%dir /lib/sysvinit

%files init
%defattr (-,root,root,755)
%doc %{_mandir}/man8/halt.8.gz
%doc %{_mandir}/man5/initscript.5.gz
%doc %{_mandir}/man5/inittab.5.gz
%doc %{_mandir}/man8/init.8.gz
%doc %{_mandir}/man8/sysvinit.8.gz
%doc %{_mandir}/man8/poweroff.8.gz
%doc %{_mandir}/man8/reboot.8.gz
%doc %{_mandir}/man8/runlevel.8.gz
%doc %{_mandir}/man8/shutdown.8.gz
%doc %{_mandir}/man8/telinit.8.gz
%if %have_mkinitrd
%dir /lib/mkinitrd
%dir /lib/mkinitrd/scripts

%files tools
%defattr (-,root,root,755)
%doc COPYING COPYRIGHT doc/Propaganda 
%doc doc/Changelog doc/killproc doc/showconsole
%config /etc/pam.d/init
%if %{with util_linux}
%if %{with util_linux}
%doc %{_mandir}/man1/mountpoint.1.gz
%doc %{_mandir}/man1/utmpdump.1.gz
%doc %{_mandir}/man8/sulogin.8.gz
%doc %{_mandir}/man1/last.1.gz
%doc %{_mandir}/man1/lastb.1.gz
%doc %{_mandir}/man1/usleep.1.gz
%doc %{_mandir}/man1/fsync.1.gz
# /usr/include/libblogger.h
# /usr/lib/libblogger.a
%doc %{_mandir}/man8/blogger.8.gz
%doc %{_mandir}/man8/blogd.8.gz
%doc %{_mandir}/man8/fstab-decode.8.gz
%doc %{_mandir}/man8/showconsole.8.gz
%doc %{_mandir}/man8/setconsole.8.gz
%doc %{_mandir}/man8/isserial.8.gz
%doc %{_mandir}/man8/checkproc.8.gz
%doc %{_mandir}/man8/pidofproc.8.gz
%doc %{_mandir}/man8/killall5.8.gz
%doc %{_mandir}/man8/killproc.8.gz
%doc %{_mandir}/man8/pidof.8.gz
%doc %{_mandir}/man8/startproc.8.gz
%doc %{_mandir}/man8/start_daemon.8.gz
%doc %{_mandir}/man8/startpar.8.gz
%doc %{_mandir}/man8/rvmtab.8.gz
%doc %{_mandir}/man8/vhangup.8.gz
%doc %{_mandir}/man8/mkill.8.gz
%if 0
%doc contrib/bootlogd.README
%doc %{_mandir}/man8/bootlogd.8.gz
%doc %{_mandir}/man8/intr.8.gz