Hi, I've closed all apticron bugs in bts. Actually there are some new features here, and I know it's not a good practice for now. However, I think the changes are simple and really valuable for apticron users. Note that most insertions are only useless space/tab removals, so don't panic with the number of lines before reading the attached diff. Thanks, -- Tiago Bortoletto Vaz http://tiagovaz.org 0xA504FECA - http://pgp.mit.edu GNU/Linux user #188687
diff -ur apticron-1.1.21/apticron apticron-1.1.22/apticron --- apticron-1.1.21/apticron 2008-04-27 18:07:46.000000000 -0300 +++ apticron-1.1.22/apticron 2008-08-26 19:14:39.000000000 -0300 @@ -1,4 +1,4 @@ -#!/bin/bash -e +#!/bin/bash -e isDigit() { @@ -51,7 +51,7 @@ echo "--cron: used by cron scripts in order not to run the job" echo " more than once in a day." exit 1 -fi +fi # a sane default for email EMAIL=root @@ -62,12 +62,16 @@ # Set $DIRCACHE eval `/usr/bin/apt-config shell DIRCACHE Dir::Cache` -# Set the SYSTEM +# Set the SYSTEM SYSTEM=`/bin/hostname -f` # Set the IPADDRESSNUM IPADDRESSNUM="1" +# Source lsb-release so we know what distribution we are +DISTRIB_ID="Debian" # Default to Debian +[ -e /etc/lsb-release ] && . /etc/lsb-release + # Source the config file [ -e /etc/apticron/apticron.conf ] && . /etc/apticron/apticron.conf @@ -97,7 +101,7 @@ # Add the Address ADDRESSES="${ADDRESSES} ${address}" done - + ADDRESSES=`echo $ADDRESSES | /usr/bin/fmt -w68 |\ /bin/sed 's/^/\t[ /;s/\$/ ]/'` ADDRESSES=`echo -e "\n$ADDRESSES"` @@ -106,12 +110,36 @@ # update the package lists /usr/bin/apt-get -qq update || true +# workaround to handle apt-get installing packages hold by aptitude. See #137771. +APTITUDE_HOLDS=`grep "^State: 2" -B 2 /var/lib/aptitude/pkgstates |grep "^Package: .*$" |cut -d" " -f 2` +DSELECT_HOLDS=`dpkg --get-selections |grep hold |cut -f1` + # get the list of packages which are pending an upgrade PKGNAMES=`/usr/bin/apt-get -q -y --allow-unauthenticated -s dist-upgrade | \ /bin/grep ^Inst | /usr/bin/cut -d\ -f2 | /usr/bin/sort` +# creating the future last_run file +TMPFILE="$(mktemp -t apticron.XXXXXXXXXX)" +for p in $PKGNAMES; do + echo $p >> $TMPFILE +done + +# packages hold by aptitude don't go to the upgrading candidates list +for p in $APTITUDE_HOLDS; do + PKGNAMES=`echo $PKGNAMES |sed -r "s/(^| )$p( |$)/ /g" |sed -e 's/^ //g'` +done + +# packages already reported won't be reported again if DIFF_ONLY option is marked +LAST_RUN_FILE="/var/lib/apticron/last_run" +if [ "$DIFF_ONLY" = "1" ] && [ -e "$LAST_RUN_FILE" ]; then + EXTRA_REPORT=" since the last run" + for p in `cat $LAST_RUN_FILE`; do + PKGNAMES=`echo $PKGNAMES |sed -r "s/(^| )$p( |$)/ /g" |sed -e 's/^ //g'` + done +fi + if [ -n "$PKGNAMES" ] ; then - + # do the upgrade downloads /usr/bin/apt-get -qq -d --allow-unauthenticated --force-yes dist-upgrade >& /dev/null @@ -120,11 +148,11 @@ apticron report [`/bin/date -R`] ======================================================================== -apticron has detected that some packages need upgrading on: +apticron has detected that some packages need upgrading on: $SYSTEM $ADDRESSES -The following packages are currently pending an upgrade: +The following packages are currently pending an upgrade$EXTRA_REPORT: EOF @@ -139,6 +167,10 @@ echo -e "\t"$PKG $VER done + if [ "$DIFF_ONLY" = "1" ] && [ -e "$LAST_RUN_FILE" ]; then + echo -e "\n(there are other `cat $LAST_RUN_FILE |wc -l` packages previously reported to you pending an upgrade!)" + fi + MISSING_DEBS=`apt-get -y --allow-unauthenticated --print-uris dist-upgrade \ | grep "file:" \ | sed "s/'file:\(.*\)' .*/\1/g"` @@ -172,17 +204,44 @@ aptitude dist-upgrade as root on $SYSTEM +EOF + + if [ -n "$DSELECT_HOLDS" ] ; then + /bin/cat <<EOF -It is recommended that you simulate the upgrade first to confirm that -the actions that would be taken are reasonable. The upgrade may be -simulated by issuing the command: +======================================================================== - aptitude -s -y dist-upgrade +The following packages are on hold, then will not be upgraded: --- +`echo -e "\t" $DSELECT_HOLDS` +EOF + fi + + if [ -n "$APTITUDE_HOLDS" ] ; then + /bin/cat <<EOF + +WARNING: The following packages were put on hold by aptitude but will be +upgraded anyway in case of using apt-get: + +`echo -e "\t" $APTITUDE_HOLDS` + +If you don't want them to be upgraded please use aptitude to dist-upgrade your +system. This is necessary because aptitude's holds are ignored by both dselect +and apt-get. For more info please see #137771. +EOF + fi + + /bin/cat <<EOF + +-- apticron EOF - ) 2>&1 | /usr/bin/mailx -a "Content-type: text/plain; charset=UTF-8" -s "Debian package updates on `/bin/hostname`" $EMAIL + ) 2>&1 | /usr/bin/mailx -a "Content-type: text/plain; charset=UTF-8" -s "$DISTRIB_ID package updates on `/bin/hostname`" $EMAIL fi + +# updating the last_run file +mv $TMPFILE $LAST_RUN_FILE + +exit 0 diff -ur apticron-1.1.21/apticron.1 apticron-1.1.22/apticron.1 --- apticron-1.1.21/apticron.1 2008-04-27 19:02:41.000000000 -0300 +++ apticron-1.1.22/apticron.1 2008-08-26 19:26:30.000000000 -0300 @@ -1,17 +1,17 @@ -.TH apticron 1 +.TH apticron 1 .SH NAME apticron \- Generate a mail listing packages which are pending an upgrade .SH SYNOPSIS .B apticron [--cron] .br .SH DESCRIPTION -.B apticron +.B apticron is a shell script which generates a mail with a list of all packages currently pending an upgrade, as well as summary of changes - using apt-listchanges - to a configurable Email address. .B apticron -is mainly intended for automatic notification of pending security +is mainly intended for automatic notification of pending security updates but can also be used in many other situations where timely updates are neccessary. @@ -20,7 +20,8 @@ .SH FILES .TP \fI/etc/apticron/apticron\&.conf\fR -Configuration file, Email address to mail and profile for use with apt-listchanges are configurable. +Configuration file, Email address to mail and profile for use with +apt-listchanges are configurable. .TP \fI/etc/cron\&.d/apticron\fR Cron job for executing apticron daily. @@ -37,6 +38,7 @@ .BR cron (8) .br .SH AUTHOR -Apticron is by Colm MacCarthaigh <colm.maccarthaigh@heanet.ie> with -contributions from Marc Sherman <msherman@projectile.ca>. Now it is maintained -by Tiago Bortoletto Vaz <tiago@debian-ba.org>. +Apticron was initially developed by Colm MacCarthaigh +<colm.maccarthaigh@heanet.ie> with contributions from Marc Sherman +<msherman@projectile.ca>. Since 2006 it is maintained by Tiago Bortoletto Vaz +<tiago@debian-ba.org>. diff -ur apticron-1.1.21/debian/changelog apticron-1.1.22/debian/changelog --- apticron-1.1.21/debian/changelog 2008-04-27 21:02:41.000000000 -0300 +++ apticron-1.1.22/debian/changelog 2008-08-26 19:45:38.000000000 -0300 @@ -1,3 +1,32 @@ +apticron (1.1.22) unstable; urgency=low + + * Using /etc/lsb-release in order to get the right distribuion on the + message - useful for Debian derivatives. Thanks to Daniel Hahler + <debian-bugs@thequod.de>. (Closes: #493296) + * Removing annoying tabs and spaces from apticron file. + * Add workaround in order to no longer sending upgrade notices about + packages that are on hold by aptitude - these that are unfortunately + ignored by apt-get. (Closes: #431869) + * List packages that will not be upgraded for being on hold on dselect + database. Also lists those on hold by aptitude, giving the user a warning + message recommending them not to use apt-get in that case. + (Closes: #314646) + * Update Standards-Version to 3.8.0. + * Giving the user an option to receive only the diff pendings between + current and last apticron run. (Closes: #344115) + * Fix minor lintian warnings. + + -- Tiago Bortoletto Vaz <tiago@debian-ba.org> Tue, 26 Aug 2008 17:42:05 -0300 + +apticron (1.1.21+nmu1) unstable; urgency=low + + * Non-maintainer upload to fix pending l10n issues. + * Debconf translations: + - Galician. Closes: #482665 + - Basque. Closes: #495037 + + -- Christian Perrier <bubulle@debian.org> Tue, 19 Aug 2008 07:11:02 +0200 + apticron (1.1.21) unstable; urgency=low [ Tiago Bortoletto Vaz ] diff -ur apticron-1.1.21/debian/compat apticron-1.1.22/debian/compat --- apticron-1.1.21/debian/compat 2008-04-15 11:55:16.000000000 -0300 +++ apticron-1.1.22/debian/compat 2008-08-24 22:21:37.000000000 -0300 @@ -1,2 +1 @@ 5 - diff -ur apticron-1.1.21/debian/control apticron-1.1.22/debian/control --- apticron-1.1.21/debian/control 2008-04-27 20:39:06.000000000 -0300 +++ apticron-1.1.22/debian/control 2008-08-24 20:44:18.000000000 -0300 @@ -4,10 +4,10 @@ Maintainer: Tiago Bortoletto Vaz <tiago@debian-ba.org> Uploaders: Tassia Camoes Araujo <tassia@debian-ba.org>, Colm MacCarthaigh <colm.maccarthaigh@heanet.ie> Build-Depends: debhelper (>= 5), po-debconf -Standards-Version: 3.7.3 +Standards-Version: 3.8.0 Package: apticron -Architecture: all +Architecture: all Depends: mailx, debconf | debconf-2.0, apt (>= 0.6.8), ucf (>= 0.28) Recommends: apt-listchanges, iproute Description: cron-script to mail impending apt updates Only in apticron-1.1.22/debian: dirs Only in apticron-1.1.22/debian/po: eu.po Only in apticron-1.1.22/debian/po: gl.po diff -ur apticron-1.1.21/debian/postinst apticron-1.1.22/debian/postinst --- apticron-1.1.21/debian/postinst 2008-04-16 16:02:35.000000000 -0300 +++ apticron-1.1.22/debian/postinst 2008-08-26 15:09:17.000000000 -0300 @@ -14,26 +14,34 @@ configure) . /usr/share/debconf/confmodule - + db_get apticron/notification EMAIL="$RET" if [ ! -d /etc/apticron/ ] ; then mkdir /etc/apticron fi - + tmpfile="$( mktemp -t apticron.conf.XXXXXXXXXX )" cat <<EOF > "$tmpfile" -# apticron.conf +# apticron.conf # # set EMAIL to a list of addresses which will be notified of impending updates # EMAIL="$EMAIL" # +# Set DIFF_ONLY to "1" to only output the difference of the current run +# compared to the last run (ie. only new upgrades since the last run). If there +# are no differences, no output/email will be generated. By default, apticron +# will output everything that needs to be upgraded. +# +# DIFF_ONLY="1" + +# # Set LISTCHANGES_PROFILE if you would like apticron to invoke apt-listchanges -# with the --profile option. You should add a corresponding profile to +# with the --profile option. You should add a corresponding profile to # /etc/apt/listchanges.conf # # LISTCHANGES_PROFILE="apticron" @@ -45,14 +53,14 @@ # SYSTEM="foobar.example.com" # -# Set IPADDRESSNUM if you would like to configure the maximal number of IP +# Set IPADDRESSNUM if you would like to configure the maximal number of IP # addresses apticron displays. The default is to display 1 address of each # family type (inet, inet6), if available. # # IPADDRESSNUM="1" # -# Set IPADDRESSES to a whitespace seperated list of reachable addresses for +# Set IPADDRESSES to a whitespace seperated list of reachable addresses for # this system. By default, apticron will try to work these out using the # "ip" command # diff -ur apticron-1.1.21/debian/postrm apticron-1.1.22/debian/postrm --- apticron-1.1.21/debian/postrm 2008-04-16 16:02:35.000000000 -0300 +++ apticron-1.1.22/debian/postrm 2008-08-26 20:18:03.000000000 -0300 @@ -9,9 +9,10 @@ rm -f /etc/cron.d/apticron /etc/cron.d/apticron.ucf-* rm -f /var/lib/misc/apticron.cron rm -f /etc/apticron/apticron.conf* - if [ -d /etc/apticron ] ; then + if [ -d /etc/apticron ] ; then rmdir /etc/apticron || true fi + rm -rf /var/lib/apticron ;; esac diff -ur apticron-1.1.21/debian/rules apticron-1.1.22/debian/rules --- apticron-1.1.21/debian/rules 2008-04-15 11:55:16.000000000 -0300 +++ apticron-1.1.22/debian/rules 2008-08-26 15:25:56.000000000 -0300 @@ -4,7 +4,7 @@ #export DH_VERBOSE=1 build: build-stamp -build-stamp: +build-stamp: dh_testdir touch build-stamp @@ -14,14 +14,14 @@ rm -f build-stamp configure-stamp debconf-updatepo dh_clean - + install: build mkdir -p $(CURDIR)/debian/apticron/usr/sbin/ cp apticron ${CURDIR}/debian/apticron/usr/sbin/ chmod 0755 ${CURDIR}/debian/apticron/usr/sbin/apticron dh_testroot dh_installdirs - dh_installdebconf + dh_installdebconf # Build architecture-independent files here. binary-indep: build install @@ -39,7 +39,7 @@ # We have nothing to do by default. # Build architecture-dependent files here. -binary-arch: +binary-arch: binary: binary-indep binary-arch -.PHONY: build clean binary-indep binary-arch binary install +.PHONY: build clean binary-indep binary-arch binary install
Attachment:
signature.asc
Description: Digital signature