From f78936a278cae769ad8e47c91618d7b3ae01b1fa Mon Sep 17 00:00:00 2001 From: Dustin Kirkland Date: Sat, 10 Jan 2009 12:57:06 -0600 Subject: [PATCH] * bin/updates-available: add some rudimentary caching mechanism for updates, will make screen launch *much* faster on <= Ubuntu 8.10 --- bin/updates-available | 18 +++++++++++++++++- debian/changelog | 5 ++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/bin/updates-available b/bin/updates-available index 182df922..635a0219 100755 --- a/bin/updates-available +++ b/bin/updates-available @@ -11,22 +11,38 @@ print_updates() { } cache=/var/run/updates-available +mycache=/var/tmp/updates-available-$USER u= -# If global updates-available cache is present, use it. Available as of jaunty. +# If global updates-available cache is present, use it. +# Only available in Jaunty+. if [ -r $cache ]; then u=`grep -m 1 "^[0-9]" $cache | sed "s/\s.*$//"` print_updates $u fi +# If the user's updates-available cache is present, and less than an hour old, +# use it. (The "hour" part should be configurable) +if [ -r $mycache -a -O $mycache ]; then + now=`date +%s` + timestamp=`stat -c "%Y" $mycache` + diff=`expr $now - $timestamp` + if [ $diff -lt 3600 ]; then + u=`grep -m 1 "^[0-9]" $mycache | sed "s/\s.*$//"` + print_updates $u + fi +fi + # If apt-check binary exists, use it if [ -x /usr/lib/update-notifier/apt-check ]; then u=`/usr/lib/update-notifier/apt-check 2>&1 | tail -n 1 | sed "s/;.*$//"` + echo "$u" > $mycache print_updates $u fi # If apt-get exists, use it if [ -x /usr/bin/apt-get ]; then u=`/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade | grep -c ^Inst` + echo "$u" > $mycache print_updates $u fi diff --git a/debian/changelog b/debian/changelog index 686be3ce..a082720a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,10 +1,13 @@ screen-profiles (1.6) UNRELEASED; urgency=low + [ Dustin Kirkland ] * debian/install: no need to install the debian profile in ubuntu * debian/rules: clean up comments * profiles/ubuntu: zero-fill the hour component of the timestamp + * bin/updates-available: add some rudimentary caching mechanism for updates, + will make screen launch *much* faster on <= Ubuntu 8.10 - -- Dustin Kirkland Sat, 10 Jan 2009 09:03:53 -0600 + -- Dustin Kirkland Sat, 10 Jan 2009 12:56:02 -0600 screen-profiles (1.5-0ubuntu1) jaunty; urgency=low