[yum-commits] Branch 'yum-3_2_X' - 2 commits - etc/0yum.cron etc/Makefile etc/yum-cron etc/yum-cron.sysconf etc/yum-daily.yum etc/yum-weekly.yum yum/__init__.py yum.spec
skvidal at osuosl.org
skvidal at osuosl.org
Thu Jan 13 05:31:06 UTC 2011
etc/0yum.cron | 141 +++++++++++++++++++++++++++++++++++++++++++++++++++
etc/Makefile | 7 ++
etc/yum-cron | 102 ++++++++++++++++++++++++++++++++++++
etc/yum-cron.sysconf | 58 ++++++++++++++++++++
etc/yum-daily.yum | 3 +
etc/yum-weekly.yum | 4 +
yum.spec | 86 +++++++++++++++++++++++++++++--
yum/__init__.py | 19 ++++--
8 files changed, 410 insertions(+), 10 deletions(-)
New commits:
commit fdbc727fc7ce91126fab994262e5ef6283f3217c
Author: Seth Vidal <skvidal at fedoraproject.org>
Date: Thu Jan 13 00:28:57 2011 -0500
- mark as 3.2.29 in spec and init
- update fixme in update() so that it is in the right place and explains a bit better
- partial fix commented out but didn't want to introduce a change so late
diff --git a/yum.spec b/yum.spec
index 1f8b3ee..cdf880b 100644
--- a/yum.spec
+++ b/yum.spec
@@ -1,6 +1,6 @@
Summary: RPM installer/updater
Name: yum
-Version: 3.2.28
+Version: 3.2.29
Release: 0
License: GPLv2+
Group: System Environment/Base
diff --git a/yum/__init__.py b/yum/__init__.py
index 5d3309d..f6e8a6b 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -91,7 +91,7 @@ from weakref import proxy as weakref
from urlgrabber.grabber import default_grabber
-__version__ = '3.2.28'
+__version__ = '3.2.29'
__version_info__ = tuple([ int(num) for num in __version__.split('.')])
# Setup a default_grabber UA here that says we are yum, done using the global
@@ -3754,15 +3754,22 @@ class YumBase(depsolve.Depsolve):
# check to see if the pkg we want to install is not _quite_ the newest
# one but still technically an update over what is installed.
- #FIXME - potentially do the comparables thing from what used to
- # be in cli.installPkgs() to see what we should be comparing
- # it to of what is installed. in the meantime name.arch is
- # most likely correct
pot_updated = self.rpmdb.searchNevra(name=available_pkg.name, arch=available_pkg.arch)
if pot_updated and self.allowedMultipleInstalls(available_pkg):
# only compare against the newest of what's installed for kernel
pot_updated = sorted(pot_updated)[-1:]
-
+#FIXME - potentially do the comparables thing from what used to
+# be in cli.installPkgs() to see what we should be comparing
+# it to of what is installed. in the meantime name.arch is
+# most likely correct
+# this is sorta a fix - but it shouldn't be only for localPackages
+# else:
+# if available_pkg in self.localPackages:
+# # if we got here the potentially updated is not a matching arch
+# # and we're goofed up in a localPackage that someone wants to apply for some odd reason
+# # so we go for name-only update match and check
+# pot_updated = self.rpmdb.searchNevra(name=available_pkg.name)
+
for ipkg in pot_updated:
if self.tsInfo.isObsoleted(ipkg.pkgtup):
self.verbose_logger.log(logginglevels.DEBUG_2, _('Not Updating Package that is already obsoleted: %s.%s %s:%s-%s') %
commit c63fc2c8dfd33a9b182d30673293bf18a188ed81
Author: Seth Vidal <skvidal at fedoraproject.org>
Date: Wed Jan 12 17:08:05 2011 -0500
add yum-cron back to yum
- add patch from Marko Myllynen <myllynen at redhat.com> to make the random wait behave a bit better
- update spec file for correct deps
diff --git a/etc/0yum.cron b/etc/0yum.cron
new file mode 100755
index 0000000..0cfaa4b
--- /dev/null
+++ b/etc/0yum.cron
@@ -0,0 +1,141 @@
+#!/bin/bash
+
+# Only run if this flag file is set (by /etc/rc.d/init.d/yum-cron)
+if [ ! -f /var/lock/subsys/yum-cron ]; then
+ exit 0
+fi
+
+DAILYSCRIPT=/etc/yum/yum-daily.yum
+WEEKLYSCRIPT=/etc/yum/yum-weekly.yum
+LOCKDIR=/var/lock/yum-cron.lock
+LOCKFILE=$LOCKDIR/pidfile
+TSLOCK=$LOCKDIR/ts.lock
+
+# Grab config settings
+if [ -f /etc/sysconfig/yum-cron ]; then
+ source /etc/sysconfig/yum-cron
+fi
+# set default for SYSTEMNAME
+[ -z "$SYSTEMNAME" ] && SYSTEMNAME=$(hostname)
+
+# Only run on certain days of the week
+dow=`date +%w`
+DAYS_OF_WEEK=${DAYS_OF_WEEK:-0123456}
+if [ "${DAYS_OF_WEEK/$dow/}" == "${DAYS_OF_WEEK}" ]; then
+ exit 0
+fi
+
+# if DOWNLOAD_ONLY is set then we force CHECK_ONLY too.
+# Gotta check before one can download!
+if [ "$DOWNLOAD_ONLY" == "yes" ]; then
+ CHECK_ONLY=yes
+fi
+
+YUMTMP=$(mktemp /var/run/yum-cron.XXXXXX)
+touch $YUMTMP
+[ -x /sbin/restorecon ] && /sbin/restorecon $YUMTMP
+
+# Random wait function
+random_wait() {
+ sleep $(( $RANDOM % ($RANDOMWAIT * 60) + 1 ))
+}
+
+# Note - the lockfile code doesn't try and use YUMTMP to email messages nicely.
+# Too many ways to die, this gets handled by normal cron error mailing.
+# Try mkdir for the lockfile, will test for and make it in one atomic action
+if mkdir $LOCKDIR 2>/dev/null; then
+ # store the current process ID in there so we can check for staleness later
+ echo "$$" >"${LOCKFILE}"
+ # and clean up locks and tempfile if the script exits or is killed
+ trap "{ rm -f $LOCKFILE $TSLOCK; rmdir $LOCKDIR 2>/dev/null; rm -f $YUMTMP; exit 255; }" INT TERM EXIT
+else
+ # lock failed, check if process exists. First, if there's no PID file
+ # in the lock directory, something bad has happened, we can't know the
+ # process name, so clean up the old lockdir and restart
+ if [ ! -f $LOCKFILE ]; then
+ rmdir $LOCKDIR 2>/dev/null
+ echo "yum-cron: no lock PID, clearing and restarting myself" >&2
+ exec $0 "$@"
+ fi
+ OTHERPID="$(cat "${LOCKFILE}")"
+ # if cat wasn't able to read the file anymore, another instance probably is
+ # about to remove the lock -- exit, we're *still* locked
+ if [ $? != 0 ]; then
+ echo "yum-cron: lock failed, PID ${OTHERPID} is active" >&2
+ exit 0
+ fi
+ if ! kill -0 $OTHERPID &>/dev/null; then
+ # lock is stale, remove it and restart
+ echo "yum-cron: removing stale lock of nonexistant PID ${OTHERPID}" >&2
+ rm -rf "${LOCKDIR}"
+ echo "yum-cron: restarting myself" >&2
+ exec $0 "$@"
+ else
+ # Remove stale (more than a day old) lockfiles
+ find $LOCKDIR -type f -name 'pidfile' -amin +1440 -exec rm -rf $LOCKDIR \;
+ # if it's still there, it wasn't too old, bail
+ if [ -f $LOCKFILE ]; then
+ # lock is valid and OTHERPID is active - exit, we're locked!
+ echo "yum-cron: lock failed, PID ${OTHERPID} is active" >&2
+ exit 0
+ else
+ # lock was invalid, restart
+ echo "yum-cron: removing stale lock belonging to stale PID ${OTHERPID}" >&2
+ echo "yum-cron: restarting myself" >&2
+ exec $0 "$@"
+ fi
+ fi
+fi
+
+# Then check for updates and/or do them, as configured
+{
+ # First, if this is CLEANDAY, do so
+ CLEANDAY=${CLEANDAY:-0}
+ if [ ! "${CLEANDAY/$dow/}" == "${CLEANDAY}" ]; then
+ /usr/bin/yum $YUM_PARAMETER -e ${ERROR_LEVEL:-0} -d ${DEBUG_LEVEL:-0} -y shell $WEEKLYSCRIPT
+ fi
+
+ # Now continue to do the real work
+ if [ "$CHECK_ONLY" == "yes" ]; then
+ random_wait
+ touch $TSLOCK
+ /usr/bin/yum $YUM_PARAMETER -e 0 -d 0 -y check-update 1> /dev/null 2>&1
+ case $? in
+ 1) exit 1;;
+ 100) echo "New updates available for host `/bin/hostname`";
+ /usr/bin/yum $YUM_PARAMETER -e ${ERROR_LEVEL:-0} -d ${DEBUG_LEVEL:-0} -y -C check-update
+ if [ "$DOWNLOAD_ONLY" == "yes" ]; then
+ /usr/bin/yum $YUM_PARAMETER -e ${ERROR_LEVEL:-0} -d ${DEBUG_LEVEL:-0} -y --downloadonly update
+ echo "Updates downloaded, use \"yum -C update\" manually to install them."
+ fi
+ ;;
+ esac
+ elif [ "$CHECK_FIRST" == "yes" ]; then
+ # Don't run if we can't access the repos
+ random_wait
+ touch $TSLOCK
+ /usr/bin/yum $YUM_PARAMETER -e 0 -d 0 check-update 2>&-
+ case $? in
+ 1) exit 1;;
+ 100) /usr/bin/yum $YUM_PARAMETER -e ${ERROR_LEVEL:-0} -d ${DEBUG_LEVEL:-0} -y update yum
+ /usr/bin/yum $YUM_PARAMETER -e ${ERROR_LEVEL:-0} -d ${DEBUG_LEVEL:-0} -y shell $DAILYSCRIPT
+ ;;
+ esac
+ else
+ random_wait
+ touch $TSLOCK
+ /usr/bin/yum $YUM_PARAMETER -e ${ERROR_LEVEL:-0} -d ${DEBUG_LEVEL:-0} -y update yum
+ /usr/bin/yum $YUM_PARAMETER -e ${ERROR_LEVEL:-0} -d ${DEBUG_LEVEL:-0} -y shell $DAILYSCRIPT
+ fi
+} >> $YUMTMP 2>&1
+
+if [ ! -z "$MAILTO" ] && [ -x /bin/mail ]; then
+# if MAILTO is set, use mail command (ie better than standard mail with cron output)
+ [ -s "$YUMTMP" ] && mail -s "System update: $SYSTEMNAME" $MAILTO < $YUMTMP
+else
+# default behavior is to use cron's internal mailing of output from cron-script
+ cat $YUMTMP
+fi
+rm -f $YUMTMP
+
+exit 0
diff --git a/etc/Makefile b/etc/Makefile
index a512cdf..29a7f95 100644
--- a/etc/Makefile
+++ b/etc/Makefile
@@ -29,3 +29,10 @@ install:
mkdir -p $(DESTDIR)/etc/bash_completion.d
install -m 644 yum.bash $(DESTDIR)/etc/bash_completion.d
+ mkdir -p $(DESTDIR)/etc/cron.daily
+ mkdir -p $(DESTDIR)/etc/sysconfig/
+ install -D -m 755 0yum.cron $(DESTDIR)/etc/cron.daily/0yum.cron
+ install -D -m 755 yum-cron $(DESTDIR)/etc/rc.d/init.d/yum-cron
+ install -D -m 644 yum-daily.yum $(YUMETC)/yum-daily.yum
+ install -D -m 644 yum-weekly.yum $(YUMETC)/yum-weekly.yum
+ install -D -m 644 yum-cron.sysconf $(DESTDIR)/etc/sysconfig/yum-cron
diff --git a/etc/yum-cron b/etc/yum-cron
new file mode 100755
index 0000000..63c5ec0
--- /dev/null
+++ b/etc/yum-cron
@@ -0,0 +1,102 @@
+#!/bin/bash
+#
+# yum-cron This shell script enables the automatic use of YUM
+#
+# Author: Seth Vidal <skvidal at phy.duke.edu>
+#
+# chkconfig: - 50 01
+#
+# description: Enable daily run of yum, a program updater.
+# processname: yum-cron
+# config: /etc/yum/yum-daily.yum
+#
+
+# source function library
+. /etc/rc.d/init.d/functions
+
+test -f /etc/sysconfig/yum-cron && . /etc/sysconfig/yum-cron
+
+lockfile=/var/lock/subsys/yum-cron
+tslock=/var/lock/yum-cron.lock/ts.lock
+yumcronpid=/var/lock/yum-cron.lock/pidfile
+
+RETVAL=0
+
+start() {
+ echo -n $"Enabling nightly yum update: "
+ touch "$lockfile" && success || failure
+ RETVAL=$?
+ echo
+}
+
+stop() {
+ echo -n $"Disabling nightly yum update: "
+ if [ -f "$yumcronpid" -a "$SERVICE_WAITS" = "yes" ]; then
+ yum_done=0
+ if [ ! -f $tslock ]; then
+ # No transaction yet in progress, just kill it
+ kill `cat $yumcronpid > /dev/null 2>&1` > /dev/null 2>&1
+ yum_done=1
+ fi
+ if [ $yum_done -eq 0 ]; then
+ echo -n $"Waiting for yum "
+ if [ -z "$SERVICE_WAIT_TIME" ]; then
+ SERVICE_WAIT_TIME=300
+ fi
+ start=`date +%s`
+ end=`expr $start + $SERVICE_WAIT_TIME`
+ while [ `date +%s` -le $end ]
+ do
+ sleep 5
+ if [ ! -f "$tslock" ]; then
+ yum_done=1
+ break
+ fi
+ done
+ if [ $yum_done -eq 1 ]; then
+ echo -n " ok "
+ else
+ echo -n " failed "
+ fi
+ 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 $"Nightly yum update is enabled."
+ RETVAL=0
+ else
+ echo $"Nightly yum update is disabled."
+ RETVAL=3
+ fi
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
+ exit 1
+esac
+
+exit $RETVAL
diff --git a/etc/yum-cron.sysconf b/etc/yum-cron.sysconf
new file mode 100644
index 0000000..930341c
--- /dev/null
+++ b/etc/yum-cron.sysconf
@@ -0,0 +1,58 @@
+# Pass any given paramter to yum, as run in all the scripts invoked
+# by this package. Be aware that this is global, and yum is invoked in
+# several modes by these scripts for which your own parameter might not
+# be appropriate
+YUM_PARAMETER=
+
+# Don't install, just check (valid: yes|no)
+CHECK_ONLY=no
+
+# Check to see if you can reach the repos before updating (valid: yes|no)
+CHECK_FIRST=no
+
+# Don't install, just check and download (valid: yes|no)
+# Implies CHECK_ONLY=yes (gotta check first to see what to download)
+DOWNLOAD_ONLY=no
+
+# Error level, practical range 0-10, 0 means print only critical errors which
+# you must be told, 1 means print all errors, even ones that are not important
+# Level 0 is the default
+# ERROR_LEVEL=0
+
+# Debug level, practical range 0-10, higher number means more output
+# Level 1 is a useful level if you want to see what's been done and
+# don't want to read /var/log/yum.log
+# Level 0 is the default
+# DEBUG_LEVEL=1
+
+# randomwait is used by yum to wait random time
+# default is 60 so yum waits random time from 1 to 60 minutes
+# the value must not be zero
+RANDOMWAIT="60"
+
+# if MAILTO is set and the mail command is available, the mail command
+# is used to deliver yum output
+
+# by default MAILTO is unset, so crond mails the output by itself
+# example: MAILTO=root
+MAILTO=
+
+# you may set SYSTEMNAME if you want your yum emails tagged differently
+# default is output of hostname command
+# this variable is used only if MAILTO is set too
+#SYSTEMNAME=""
+
+# you may set DAYS_OF_WEEK to the days of the week you want to run
+# default is every day
+#DAYS_OF_WEEK="0123456"
+
+# which day should it do cleanup on? defaults to 0 (Sunday). If this day isn't in the
+# DAYS_OF_WEEK above, it'll never happen
+CLEANDAY="0"
+
+# set to yes to make the yum-cron service to wait for transactions to complete
+SERVICE_WAITS=yes
+
+# set maximum time period (in seconds) for the yum-cron service to wait for
+# transactions to complete. The default is 300 seconds (5 minutes)
+SERVICE_WAIT_TIME=300
diff --git a/etc/yum-daily.yum b/etc/yum-daily.yum
new file mode 100644
index 0000000..5d4e874
--- /dev/null
+++ b/etc/yum-daily.yum
@@ -0,0 +1,3 @@
+update
+ts run
+exit
diff --git a/etc/yum-weekly.yum b/etc/yum-weekly.yum
new file mode 100644
index 0000000..c60fa08
--- /dev/null
+++ b/etc/yum-weekly.yum
@@ -0,0 +1,4 @@
+clean packages
+clean expire-cache
+ts run
+exit
diff --git a/yum.spec b/yum.spec
index 4d2ad2f..1f8b3ee 100644
--- a/yum.spec
+++ b/yum.spec
@@ -19,7 +19,6 @@ Requires: urlgrabber >= 3.9.2
Requires: yum-metadata-parser >= 1.1.0
Requires: python-iniparse
Requires: pygpgme
-Prereq: /sbin/chkconfig, /sbin/service, coreutils
Conflicts: rpm >= 5-0
# Zif is a re-implementation of yum in C, however:
#
@@ -59,13 +58,31 @@ Group: Applications/System
Requires: yum = %{version}-%{release}
Requires: dbus-python
Requires: pygobject2
-Prereq: /sbin/chkconfig
-Prereq: /sbin/service
+Requires(preun): /sbin/chkconfig
+Requires(preun): /sbin/service
+Requires(postun): /sbin/chkconfig
+Requires(postun): /sbin/service
+
%description updatesd
yum-updatesd provides a daemon which checks for available updates and
can notify you when they are available via email, syslog or dbus.
+
+%package cron
+Summary: Files needed to run yum updates as a cron job
+Group: System Environment/Base
+Requires: yum >= 3.0 vixie-cron crontabs yum-downloadonly findutils
+Requires(post): /sbin/chkconfig
+Requires(post): /sbin/service
+Requires(preun): /sbin/chkconfig
+Requires(preun): /sbin/service
+Requires(postun): /sbin/service
+
+%description cron
+These are the files needed to run yum updates as a cron job.
+Install this package if you want auto yum updates nightly via cron.
+
%prep
%setup -q
@@ -103,6 +120,50 @@ if [ $1 = 0 ]; then
fi
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
+
+%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
+
+%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
+
+
+
%files -f %{name}.lang
%defattr(-, root, root)
%doc README AUTHORS COPYING TODO INSTALL ChangeLog PLUGINS
@@ -128,6 +189,19 @@ exit 0
%{_mandir}/man*/yum.*
%{_mandir}/man*/yum-shell*
+
+%files cron
+%defattr(-,root,root)
+%doc COPYING
+%{_sysconfdir}/cron.daily/0yum.cron
+%{_sysconfdir}/yum/yum-daily.yum
+%{_sysconfdir}/yum/yum-weekly.yum
+%{_sysconfdir}/rc.d/init.d/yum-cron
+%config(noreplace) %{_sysconfdir}/sysconfig/yum-cron
+
+
+
+
%files updatesd
%defattr(-, root, root)
%config(noreplace) %{_sysconfdir}/yum/yum-updatesd.conf
@@ -138,6 +212,10 @@ exit 0
%{_mandir}/man*/yum-updatesd*
%changelog
+* Wed Jan 12 2011 Seth Vidal <skvidal at fedoraproject.org>
+- put yum-cron back into yum and make the subpkg. Thanks To Alec Habig for
+ maintaining this so well for so long.
+
* Fri Jul 30 2010 Seth Vidal <skvidal at fedoraproject.org>
- 3.2.28
More information about the Yum-commits
mailing list