diff --git a/cups.init b/cups.init deleted file mode 100755 index 34d734c..0000000 --- a/cups.init +++ /dev/null @@ -1,146 +0,0 @@ -#!/bin/sh -# -# "$Id: cups.sh,v 1.10 2000/03/30 05:19:16 mike Exp $" -# -# Startup/shutdown script for the Common UNIX Printing System (CUPS). -# -# Linux chkconfig stuff: -# -# chkconfig: 2345 25 10 -# description: Startup/shutdown script for the Common UNIX \ -# Printing System (CUPS). -# -# Copyright 1997-2000 by Easy Software Products, all rights reserved. -# -# These coded instructions, statements, and computer programs are the -# property of Easy Software Products and are protected by Federal -# copyright law. Distribution and use rights are outlined in the file -# "LICENSE.txt" which should have been included with this file. If this -# file is missing or damaged please contact Easy Software Products -# at: -# -# Attn: CUPS Licensing Information -# Easy Software Products -# 44141 Airport View Drive, Suite 204 -# Hollywood, Maryland 20636-3111 USA -# -# Voice: (301) 373-9603 -# EMail: cups-info@cups.org -# WWW: http://www.cups.org -# -# heavily edited so that it's more like other scripts in init.d on Red Hat -# Linux -# -### BEGIN INIT INFO -# Provides: cups -# Required-Start: $syslog $local_fs -# Required-Stop: $syslog $local_fs -# Should-Start: portreserve -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: The CUPS scheduler -# Description: The CUPS scheduler -### END INIT INFO - -# Source function library. -. /etc/rc.d/init.d/functions - -DAEMON=cupsd -exec=/usr/sbin/cupsd -prog=cups -config=/etc/cups/cupsd.conf -lockfile=/var/lock/subsys/cups - -check() { - # Check that we're a privileged user - [ `id -u` = 0 ] || exit 4 - - # Check if cupsd is executable - [ -x $exec ] || exit 5 -} - -start () { - check - [ -f $config ] || exit 6 - - echo -n $"Starting $prog: " - - # tell portreserve to release the port - [ -x /sbin/portrelease ] && /sbin/portrelease cups &>/dev/null || : - - # start daemon - daemon $DAEMON - RETVAL=$? - echo - [ $RETVAL = 0 ] && touch $lockfile - - udevadm trigger --subsystem-match=usb \ - --attr-match=bInterfaceClass=07 \ - --attr-match=bInterfaceSubClass=01 \ - --action=add &>/dev/null || : - udevadm trigger --subsystem-match=usb \ - --property-match=DEVNAME="/dev/usb/lp*" \ - --action=add &>/dev/null || : - - return 0 -} - -stop () { - check - - # stop daemon - echo -n $"Stopping $prog: " - killproc $DAEMON - RETVAL=$? - echo - [ $RETVAL = 0 ] && rm -f $lockfile - return 0 -} - -restart() { - stop - start -} - -case $1 in - start) - start - ;; - stop) - stop - ;; - restart) - restart - ;; - condrestart|try-restart) - [ -f $lockfile ] && restart || : - ;; - reload) - echo -n $"Reloading $prog: " - killproc $DAEMON -HUP - RETVAL=$? - echo - ;; - force-reload) - echo -n $"Reloading $prog: " - if ! killproc $DAEMON -HUP; then - restart - fi - echo - ;; - status) - status -l $(basename $lockfile) $DAEMON - RETVAL=$? - ;; - restartlog) - stop - cat /dev/null >/var/log/cups/error_log - start - ;; - *) - - echo $"Usage: $prog {start|stop|restart|restartlog|condrestart|try-restart|reload|force-reload|status}" - exit 2 -esac - -exit $RETVAL diff --git a/cups.service b/cups.service new file mode 100644 index 0000000..dfb87b8 --- /dev/null +++ b/cups.service @@ -0,0 +1,15 @@ +[Unit] +Description=CUPS scheduler +Requires=printer.target +After=syslog.target + +[Service] +Type=forking +PIDFile=/var/run/cupsd.pid +ExecStartPre=/usr/sbin/cupsd -t +ExecStart=/usr/sbin/cupsd +ExecStartPost=/sbin/udevadm trigger --subsystem-match=usb --attr-match=bInterfaceClass=07 --attr-match=bInterfaceSubClass=01 --action=add +ExecStartPost=/sbin/udevadm trigger --subsystem-match=usb --property-match=DEVNAME="/dev/usb/lp*" --action=add + +[Install] +WantedBy=multi-user.target diff --git a/cups.spec b/cups.spec index 35dd9fa..124ab7c 100644 --- a/cups.spec +++ b/cups.spec @@ -15,12 +15,12 @@ Summary: Common Unix Printing System Name: cups Version: 1.5 -Release: 0.8.%{alphatag}%{?dist} +Release: 0.9.%{alphatag}%{?dist} License: GPLv2 Group: System Environment/Daemons Source: http://ftp.easysw.com/pub/cups/%{version}%{alphatag}/cups-%{version}%{alphatag}-source.tar.bz2 -# Our initscript -Source1: cups.init +# Our systemd service unit +Source1: cups.service # Pixmap for desktop file Source2: cupsprinter.png # udev rules for libusb devices @@ -106,6 +106,7 @@ BuildRequires: libtiff-devel BuildRequires: krb5-devel BuildRequires: avahi-devel BuildRequires: poppler-utils +BuildRequires: systemd-units # Make sure we get postscriptdriver tags. BuildRequires: python-cups @@ -128,6 +129,10 @@ Requires: tmpwatch # Requires /etc/tmpfiles.d (bug #656566) Requires: systemd-units >= 13 +Requires(post): systemd-units +Requires(preun): systemd-units +Requires(postun): systemd-units +Requires(post): systemd-sysv # We use portreserve to prevent our TCP port being stolen. # Require the package here so that we know /etc/portreserve/ exists. @@ -330,8 +335,8 @@ chmod 700 $RPM_BUILD_ROOT%{cups_serverbin}/backend/serial rm -rf $RPM_BUILD_ROOT%{_initddir} \ $RPM_BUILD_ROOT%{_sysconfdir}/init.d \ $RPM_BUILD_ROOT%{_sysconfdir}/rc?.d -mkdir -p $RPM_BUILD_ROOT%{_initddir} -install -m 755 %{SOURCE1} $RPM_BUILD_ROOT%{_initddir}/cups +mkdir -p $RPM_BUILD_ROOT%{_unitdir} +install -m 755 %{SOURCE1} $RPM_BUILD_ROOT%{_unitdir}/%{name}.service find $RPM_BUILD_ROOT%{_datadir}/cups/model -name "*.ppd" |xargs gzip -n9f @@ -414,8 +419,11 @@ s:.*\('%{_datadir}'/\)\([^/_]\+\)\(.*\.po$\):%lang(\2) \1\2\3: ' > %{name}.lang %post -/sbin/chkconfig --del cupsd 2>/dev/null || true # Make sure old versions aren't there anymore -/sbin/chkconfig --add cups || true +if [ $1 -eq 1 ] ; then + # Initial installation + /bin/systemctl daemon-reload >/dev/null 2>&1 || : +fi + # Remove old-style certs directory; new-style is /var/run # (see bug #194581 for why this is necessary). /bin/rm -rf %{_sysconfdir}/cups/certs @@ -433,8 +441,7 @@ s:.*\('%{_datadir}'/\)\([^/_]\+\)\(.*\.po$\):%lang(\2) \1\2\3: --slave %{_mandir}/man1/lpq.1.gz print-lpqman %{_mandir}/man1/lpq-cups.1.gz \ --slave %{_mandir}/man1/lpr.1.gz print-lprman %{_mandir}/man1/lpr-cups.1.gz \ --slave %{_mandir}/man1/lprm.1.gz print-lprmman %{_mandir}/man1/lprm-cups.1.gz \ - --slave %{_mandir}/man1/lpstat.1.gz print-lpstatman %{_mandir}/man1/lpstat-cups.1.gz \ - --initscript cups + --slave %{_mandir}/man1/lpstat.1.gz print-lpstatman %{_mandir}/man1/lpstat-cups.1.gz %endif rm -f %{_localstatedir}/cache/cups/*.ipp %{_localstatedir}/cache/cups/*.cache exit 0 @@ -444,9 +451,10 @@ exit 0 %postun libs -p /sbin/ldconfig %preun -if [ "$1" = "0" ]; then - /sbin/service cups stop > /dev/null 2>&1 - /sbin/chkconfig --del cups +if [ $1 -eq 0 ] ; then + # Package removal, not upgrade + /bin/systemctl --no-reload disable %{name}.service >/dev/null 2>&1 || : + /bin/systemctl stop %{name}.service >/dev/null 2>&1 || : %if %use_alternatives /usr/sbin/alternatives --remove print %{_bindir}/lpr.cups %endif @@ -454,11 +462,23 @@ fi exit 0 %postun -if [ "$1" -ge "1" ]; then - /sbin/service cups condrestart > /dev/null 2>&1 +/bin/systemctl daemon-reload >/dev/null 2>&1 || : +if [ $1 -ge 1 ]; then + # Package upgrade, not uninstall + /bin/systemctl try-restart %{name}.service >/dev/null 2>&1 || : fi exit 0 +%triggerun -- %{name} < 1.5-0.9 +# Save the current service runlevel info +# User must manually run systemd-sysv-convert --apply cups +# to migrate them to systemd targets +%{_bindir}/systemd-sysv-convert --save %{name} >/dev/null 2>&1 || : + +# Run these because the SysV package being removed won't do them +/sbin/chkconfig --del cups >/dev/null 2>&1 || : +/bin/systemctl try-restart %{name}.service >/dev/null 2>&1 || : + %triggerin -- samba-client ln -sf ../../../bin/smbspool %{cups_serverbin}/backend/smb || : exit 0 @@ -515,7 +535,7 @@ rm -rf $RPM_BUILD_ROOT %doc %{_datadir}/%{name}/www/ja/index.html %doc %{_datadir}/%{name}/www/pl/index.html %doc %{_datadir}/%{name}/www/ru/index.html -%{_initddir}/cups +%{_unitdir}/%{name}.service %{_bindir}/cupstestppd %{_bindir}/cupstestdsc %{_bindir}/cancel* @@ -614,6 +634,9 @@ rm -rf $RPM_BUILD_ROOT %{_mandir}/man1/ipptool.1.gz %changelog +* Wed Jun 29 2011 Tim Waugh 1:1.5-0.9.rc1 +- Ship systemd service unit instead of SysV initscript (bug #690766). + * Wed Jun 29 2011 Tim Waugh 1:1.5-0.8.rc1 - Tag localization files correctly (bug #716421).