* bin/updates-available: add some rudimentary caching mechanism for updates,

will make screen launch *much* faster on <= Ubuntu 8.10
This commit is contained in:
Dustin Kirkland 2009-01-10 12:57:06 -06:00
commit f78936a278
2 changed files with 21 additions and 2 deletions

View file

@ -11,22 +11,38 @@ print_updates() {
} }
cache=/var/run/updates-available cache=/var/run/updates-available
mycache=/var/tmp/updates-available-$USER
u= 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 if [ -r $cache ]; then
u=`grep -m 1 "^[0-9]" $cache | sed "s/\s.*$//"` u=`grep -m 1 "^[0-9]" $cache | sed "s/\s.*$//"`
print_updates $u print_updates $u
fi 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 apt-check binary exists, use it
if [ -x /usr/lib/update-notifier/apt-check ]; then if [ -x /usr/lib/update-notifier/apt-check ]; then
u=`/usr/lib/update-notifier/apt-check 2>&1 | tail -n 1 | sed "s/;.*$//"` u=`/usr/lib/update-notifier/apt-check 2>&1 | tail -n 1 | sed "s/;.*$//"`
echo "$u" > $mycache
print_updates $u print_updates $u
fi fi
# If apt-get exists, use it # If apt-get exists, use it
if [ -x /usr/bin/apt-get ]; then if [ -x /usr/bin/apt-get ]; then
u=`/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade | grep -c ^Inst` u=`/usr/bin/apt-get -s -o Debug::NoLocking=true upgrade | grep -c ^Inst`
echo "$u" > $mycache
print_updates $u print_updates $u
fi fi

5
debian/changelog vendored
View file

@ -1,10 +1,13 @@
screen-profiles (1.6) UNRELEASED; urgency=low screen-profiles (1.6) UNRELEASED; urgency=low
[ Dustin Kirkland ]
* debian/install: no need to install the debian profile in ubuntu * debian/install: no need to install the debian profile in ubuntu
* debian/rules: clean up comments * debian/rules: clean up comments
* profiles/ubuntu: zero-fill the hour component of the timestamp * 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 <kirkland@ubuntu.com> Sat, 10 Jan 2009 09:03:53 -0600 -- Dustin Kirkland <kirkland@ubuntu.com> Sat, 10 Jan 2009 12:56:02 -0600
screen-profiles (1.5-0ubuntu1) jaunty; urgency=low screen-profiles (1.5-0ubuntu1) jaunty; urgency=low