Package: apticron
Version: 1.1.13.0.0.dale.0
Severity: wishlist
Tags: patch
I use apticron to list the changes for updates to all my installed packages,
not just security updates. On testing, there are usually
10 to 100 packages that need updating, as I only update about once a month. I
wanted to be able to get these reports from apticron
only when something has changed since the last report I got. I implemented this
using a simple diff of the new report against the old,
and then only send mail if there is a difference. See the attached patch, which
requires changes to the apticron script and the conf
file. I've never made a patch before, so I'm not sure if what I did will work
for you, but I made this patch against the directory I
got when I "apt-get source apticron". Hope it makes sense to you.
Cameron Dale
-- System Information:
Debian Release: testing/unstable
APT prefers testing
APT policy: (990, 'testing'), (500, 'stable')
Architecture: i386 (i686)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.12-1-k7
Locale: LANG=en_CA, LC_CTYPE=en_CA (charmap=ISO-8859-1)
Versions of packages apticron depends on:
ii apt-listchanges 2.59-0.2 Display change history from .deb a
ii debconf [debconf 1.4.58 Debian configuration management sy
ii iproute 20041019-3 Professional tools to control the
ii mailx 1:8.1.2-0.20050715cvs-1 A simple mail user agent
apticron recommends no packages.
-- debconf information:
* apticron/notification: root
diff -Naur apticron-1.1.13/apticron apticron-1.1.13.0.0.dale.0/apticron
--- apticron-1.1.13/apticron 2005-09-28 10:05:34.000000000 +0000
+++ apticron-1.1.13.0.0.dale.0/apticron 2005-12-20 01:28:49.000000000 +0000
@@ -22,10 +22,16 @@
# Set the IPADDRESSNUM
IPADDRESSNUM="1"
+# What to email
+WHAT="all"
+
# Source the config file
[ -e /etc/apticron/apticron.conf ] && . /etc/apticron/apticron.conf
+TMPFILE=/tmp/apticron.$$
+LOGFILE=/var/log/apticron
+
if [ -z "$IPADDRESSES" ]; then
# Set the IPv4 addresses
IPADDRESSES=`(echo $( /bin/hostname -i ) ;
@@ -64,6 +70,14 @@
PKGNAMES=`/usr/bin/apt-get -q -y -s dist-upgrade | /bin/grep ^Inst |\
/usr/bin/cut -d\ -f2 | /usr/bin/sort`
+if [ $WHAT == "diff" ] ; then
+ if [ -e $LOGFILE ] ; then
+ /bin/cp -f --reply=yes $LOGFILE $TMPFILE
+ else
+ /bin/echo "apticron has never been run before or was recently
upgraded (no log file)" > $TMPFILE
+ fi
+fi
+
if [ -n "$PKGNAMES" ] ; then
# do the upgrade downloads
@@ -124,6 +138,59 @@
apticron
EOF
- ) 2>&1 | /usr/bin/mailx -s "Debian Package Updates on `/bin/hostname`"
$EMAIL
+ ) > $LOGFILE 2>&1
+
+fi
+
+if [ $WHAT == "diff" ] ; then
+ /usr/bin/diff -N $TMPFILE $LOGFILE | /bin/grep -E "^[<>]" > $TMPFILE.2
+ NUMLINES=`/bin/grep -c "" $TMPFILE.2`
+ if [ $NUMLINES -gt 2 ] ; then
+ (
+ /bin/cat <<EOF
+apticron report [`/bin/date -R`]
+========================================================================
+
+apticron has detected that the package report changed since the last
+run, this probably means that there are new packages available for:
+
+ $SYSTEM $ADDRESSES
+
+Here is the difference between the two reports:
+========================================================================
+
+EOF
+ /bin/cat $TMPFILE.2
+
+ /bin/cat <<EOF
+========================================================================
+
+You can perform the upgrade of these and any other previously reported
+changed packages by issuing the command:
+
+ apt-get dist-upgrade
+
+as root on $SYSTEM
+
+The complete report of all changed packages is available at:
+
+ $LOGFILE
+
+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:
+
+ apt-get -s dist-upgrade
+
+--
+apticron
+EOF
+
+ ) | /usr/bin/mailx -s "Debian Package Updates on
`/bin/hostname`" $EMAIL
+ fi
+ /bin/rm -f $TMPFILE
+ /bin/rm -f $TMPFILE.2
+else
+ /bin/cat $LOGFILE | /usr/bin/mailx -s "Debian Package Updates on
`/bin/hostname`" $EMAIL
fi
diff -Naur apticron-1.1.13/apticron.conf
apticron-1.1.13.0.0.dale.0/apticron.conf
--- apticron-1.1.13/apticron.conf 2005-09-28 10:05:34.000000000 +0000
+++ apticron-1.1.13.0.0.dale.0/apticron.conf 2005-12-20 01:25:02.000000000
+0000
@@ -31,3 +31,10 @@
#
# IPADDRESSES="192.0.2.1 2001:db8:1:2:3::1"
+#
+# Set WHAT to "diff" to only output the difference in this run compared to
+# the last run (ie. any 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 upgrading.
+#
+# WHAT="diff"
diff -Naur apticron-1.1.13/debian/changelog
apticron-1.1.13.0.0.dale.0/debian/changelog
--- apticron-1.1.13/debian/changelog 2005-09-28 14:50:05.000000000 +0000
+++ apticron-1.1.13.0.0.dale.0/debian/changelog 2005-12-20 05:53:01.000000000
+0000
@@ -1,3 +1,9 @@
+apticron (1.1.13.0.0.dale.0) unstable; urgency=low
+
+ * Added a new output option for diff outputs
+
+ -- Cameron Dale <[EMAIL PROTECTED]> Mon, 19 Dec 2005 17:20:34 -0800
+
apticron (1.1.13) unstable; urgency=low
* Add PT translation courtesty of <[EMAIL PROTECTED]>. (Closes: #330052)