Skip to content

Commit

Permalink
yum-cron.sysvinit => yum-cron.service. BZ 893593
Browse files Browse the repository at this point in the history
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?
  • Loading branch information
Zdenek Pavlas committed Jan 14, 2013
1 parent afdf914 commit fd53c9c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 147 deletions.
2 changes: 1 addition & 1 deletion yum-cron/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 10 additions & 0 deletions yum-cron/yum-cron.service
Original file line number Diff line number Diff line change
@@ -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
105 changes: 0 additions & 105 deletions yum-cron/yum-cron.sysvinit

This file was deleted.

49 changes: 8 additions & 41 deletions yum.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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



Expand Down Expand Up @@ -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.*

Expand Down

0 comments on commit fd53c9c

Please sign in to comment.