[yum-commits] yum-cron/Makefile yum-cron/yum-cron.service yum-cron/yum-cron.sysvinit yum.spec
zpavlas at osuosl.org
zpavlas at osuosl.org
Tue Jan 15 13:41:26 UTC 2013
yum-cron/Makefile | 2
yum-cron/yum-cron.service | 10 ++++
yum-cron/yum-cron.sysvinit | 105 ---------------------------------------------
yum.spec | 49 +++------------------
4 files changed, 19 insertions(+), 147 deletions(-)
New commits:
commit fd53c9c4c28a6f8eba5c7c13a55baf146ef99e9d
Author: Zdenek Pavlas <zpavlas at redhat.com>
Date: Fri Jan 11 14:52:38 2013 +0100
yum-cron.sysvinit => yum-cron.service. BZ 893593
Based on the BZ patch, with some modifications:
- got rid of (now unused) yum-cron.sysvinit
- added BuildRequires: systemd-units, as recommended on
https://fedoraproject.org/wiki/PackagingDrafts:SystemdClarification#Packaging
- also updated yum-cron/Makefile
RPMs have built fine in rawhide, but I'm not sure this patch is 100% correct,
especially if hardcoding yum-cron.service path in Makefile is ok:
+install -D -m 644 yum-cron.service $(DESTDIR)/usr/lib/systemd/system/yum-cron.service
Is there a way to expand ${_unitdir} in Makefiles?
diff --git a/yum-cron/Makefile b/yum-cron/Makefile
index 1a68a3c..0b68d37 100644
--- a/yum-cron/Makefile
+++ b/yum-cron/Makefile
@@ -11,5 +11,5 @@ install:
# Install yum-update.cron as 0yum-update.cron so it runs before items like
# manpage update, mlocate, and prelink
install -D -m 755 yum-update.cron.sh $(DESTDIR)/etc/cron.daily/0yum-update.cron
- install -D -m 755 yum-cron.sysvinit $(DESTDIR)/etc/rc.d/init.d/yum-cron
+ install -D -m 644 yum-cron.service $(DESTDIR)/usr/lib/systemd/system/yum-cron.service
install -D -m 755 yum-cron.py $(DESTDIR)/usr/sbin/yum-cron
diff --git a/yum-cron/yum-cron.service b/yum-cron/yum-cron.service
new file mode 100644
index 0000000..534d9b0
--- /dev/null
+++ b/yum-cron/yum-cron.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=Run automatic yum updates as a cron job
+
+[Service]
+Type=simple
+ExecStart=/bin/touch /var/lock/subsys/yum-cron
+ExecStop=/bin/rm -f /var/lock/subsys/yum-cron
+
+[Install]
+WantedBy=multi-user.target
diff --git a/yum-cron/yum-cron.sysvinit b/yum-cron/yum-cron.sysvinit
deleted file mode 100755
index 7b44d5e..0000000
--- a/yum-cron/yum-cron.sysvinit
+++ /dev/null
@@ -1,105 +0,0 @@
-#!/bin/bash
-#
-# yum-cron Enable or disable scheduled yum system updates.
-#
-# chkconfig: - 50 01
-#
-# description: This controls whether yum-cron runs. If this service is \
-# off, the yum-cron scripts in /etc/cron.daily exit \
-# immediately; otherwise, they download and/or apply package \
-# updates as configured in /etc/yum/yum-cron.conf.
-# processname: yum-cron
-#
-
-# source function library
-. /etc/rc.d/init.d/functions
-lockfile=/var/lock/subsys/yum-cron
-
-# This is generated by /usr/sbin/yum-cron and will exist when that script
-# is running and not otherwise.
-pidfile=/var/lock/yum-cron.pid
-SERVICE_WAITS=yes
-
-RETVAL=0
-
-start() {
- echo -n $"Enabling scheduled yum updates: "
- # The cron script exits silently if this file doesn't exist.
- touch "$lockfile" && success || failure
- RETVAL=$?
- echo
-}
-
-stop() {
- # Disabling this is just removing the so-called lock file. But we
- # also have logic to delay shutdown if a transaction is in-progress.
- # All that affects is the exit of _this_ script, which may be
- # waited on by other things in the shutdown process.
- echo -n $"Disabling scheduled yum updates: "
- if [ "$SERVICE_WAITS" = "yes" ]; then
- # if SERVICE_WAITS is yes, we check for an active pid
- # file and recheck in 5 second increments up to
- # SERVICE_WAIT_TIME before continuing.
- if (set -o noclobber; ! echo "$$" > $pidfile ) 2>/dev/null; then
- # yum-cron has the lock. Read the pid, and wait and then loop
- # until it's done.
- activepid="$(< $pidfile)" 2>/dev/null
- if [ $? != 0 ]; then
- echo; echo -n $"Stale yum-cron lock ignored. "
- else
- echo; echo -n $"Waiting for in-progress yum transaction"
- end=$( expr $( date +%s ) + ${SERVICE_WAIT_TIME:-300} )
- while checkpid $activepid 2>/dev/null ; do
- echo -n "."
- if [ $( date +%s ) -gt $end ]; then
- echo -n " Timed out. "
- break
- fi
- sleep 5
- done
- fi
- else
- # we got the lock. we don't really want it; remove and move on.
- rm -f "$pidfile"
- fi
- fi
- rm -f "$lockfile" && success || failure
- RETVAL=$?
- echo
-}
-
-restart() {
- stop
- start
-}
-
-case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- restart|force-reload)
- restart
- ;;
- reload)
- ;;
- condrestart)
- [ -f "$lockfile" ] && restart
- ;;
- status)
- if [ -f $lockfile ]; then
- echo $"Scheduled yum updates are enabled."
- RETVAL=0
- else
- echo $"Scheduled yum updates are disabled."
- RETVAL=3
- fi
- ;;
- *)
- echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
- exit 1
-esac
-
-exit $RETVAL
diff --git a/yum.spec b/yum.spec
index d7568db..c3e065b 100644
--- a/yum.spec
+++ b/yum.spec
@@ -114,11 +114,10 @@ can notify you when they are available via email, syslog or dbus.
Summary: Files needed to run yum updates as a cron job
Group: System Environment/Base
Requires: yum >= 3.0 cronie crontabs findutils
-Requires(post): /sbin/chkconfig
-Requires(post): /sbin/service
-Requires(preun): /sbin/chkconfig
-Requires(preun): /sbin/service
-Requires(postun): /sbin/service
+BuildRequires: systemd-units
+Requires(post): systemd
+Requires(preun): systemd
+Requires(postun): systemd
%description cron
These are the files needed to run yum updates as a cron job.
@@ -198,45 +197,13 @@ exit 0
%post cron
-# Make sure chkconfig knows about the service
-/sbin/chkconfig --add yum-cron
-# if an upgrade:
-if [ "$1" -ge "1" ]; then
-# if there's a /etc/rc.d/init.d/yum file left, assume that there was an
-# older instance of yum-cron which used this naming convention. Clean
-# it up, do a conditional restart
- if [ -f /etc/init.d/yum ]; then
-# was it on?
- /sbin/chkconfig yum
- RETVAL=$?
- if [ $RETVAL = 0 ]; then
-# if it was, stop it, then turn on new yum-cron
- /sbin/service yum stop 1> /dev/null 2>&1
- /sbin/service yum-cron start 1> /dev/null 2>&1
- /sbin/chkconfig yum-cron on
- fi
-# remove it from the service list
- /sbin/chkconfig --del yum
- fi
-fi
-exit 0
+%systemd_post yum-cron.service
%preun cron
-# if this will be a complete removeal of yum-cron rather than an upgrade,
-# remove the service from chkconfig control
-if [ $1 = 0 ]; then
- /sbin/chkconfig --del yum-cron
- /sbin/service yum-cron stop 1> /dev/null 2>&1
-fi
-exit 0
+%systemd_preun yum-cron.service
%postun cron
-# If there's a yum-cron package left after uninstalling one, do a
-# conditional restart of the service
-if [ "$1" -ge "1" ]; then
- /sbin/service yum-cron condrestart 1> /dev/null 2>&1
-fi
-exit 0
+%systemd_postun_with_restart yum-cron.service
@@ -283,7 +250,7 @@ exit 0
%doc COPYING
%{_sysconfdir}/cron.daily/0yum-update.cron
%config(noreplace) %{_sysconfdir}/yum/yum-cron.conf
-%{_sysconfdir}/rc.d/init.d/yum-cron
+%{_unitdir}/yum-cron.service
%{_sbindir}/yum-cron
%{_mandir}/man*/yum-cron.*
More information about the Yum-commits
mailing list