summaryrefslogtreecommitdiff
path: root/debian
diff options
context:
space:
mode:
authorMatt Zimmerman <matt.zimmerman@canonical.com>2004-11-13 18:35:58 +0000
committerMatt Zimmerman <matt.zimmerman@canonical.com>2004-11-13 18:35:58 +0000
commit0c1326826fd23ce859db8e923c37b7199c6da2c8 (patch)
tree32759b3626b853225730c3d07b413ee669472994 /debian
parent6b8147b88eb5ee755ff4477568503b205c79a030 (diff)
Add cron.daily
* Patch from Michael Vogt to add an optional cron job which can run apt-get update periodically
Diffstat (limited to 'debian')
-rw-r--r--debian/apt.cron.daily54
-rw-r--r--debian/changelog2
-rwxr-xr-xdebian/rules2
3 files changed, 57 insertions, 1 deletions
diff --git a/debian/apt.cron.daily b/debian/apt.cron.daily
new file mode 100644
index 000000000..67b58747e
--- /dev/null
+++ b/debian/apt.cron.daily
@@ -0,0 +1,54 @@
+#!/bin/sh
+#
+# cron job for apt-get update
+#
+# Update-Package-Intervall is in days
+#
+STAMP=/var/lib/apt/update-stamp
+
+#set -e
+
+do_update()
+{
+ touch $STAMP.new
+ if apt-get update -qq; then
+ if [ -x /usr/bin/dbus-send ]; then
+ dbus-send --system / app.apt.dbus.updated boolean:true
+ fi
+ mv $STAMP.new $STAMP
+ fi
+ rm -f $STAMP.new
+}
+
+UpdateInterval=0
+RES=`apt-config shell UpdateInterval APT::Periodic::Update-Package-Lists`
+eval $RES
+
+if [ $UpdateInterval -eq 0 ]; then
+ exit 0
+fi
+
+# laptop check, on_ac_power returns:
+# 0 (true) System is on mains power
+# 1 (false) System is not on mains power
+# 255 (false) Power status could not be determined
+# Desktop systems always return 255 it seems
+if [ -x /usr/bin/on_ac_power ]; then
+ /usr/bin/on_ac_power
+ if [ $? -eq 1 ]; then
+ exit 0
+ fi
+fi
+
+if [ ! -f $STAMP ]; then
+ do_update
+ exit 0
+fi
+
+LastUpdate=`stat -c "%Y" $STAMP 2>/dev/null`
+Now=`date +%s`
+
+NeedUpdate=$(($LastUpdate+$UpdateInterval*3600*24))
+if [ $NeedUpdate -le $Now ]; then
+ do_update
+fi
diff --git a/debian/changelog b/debian/changelog
index c5122fc54..87a864c4e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -22,6 +22,8 @@ apt (0.5.28) unstable; urgency=low
(Closes: #267266)
* Set default Dpkg::MaxArgs to 1024, and Dpkg::MaxArgBytes to 32k. Needed
to work around ordering bugs when installing a large number of packages
+ * Patch from Michael Vogt to add an optional cron job which can run
+ apt-get update periodically
--
diff --git a/debian/rules b/debian/rules
index f54334fd9..2dbb9707f 100755
--- a/debian/rules
+++ b/debian/rules
@@ -211,7 +211,7 @@ apt: build debian/shlibs.local
dh_installexamples -p$@ $(BLD)/docs/examples/*
dh_installman -p$@
-
+ dh_installcron -p$@
dh_installdocs -p$@
dh_installchangelogs -p$@
dh_strip -p$@