From 64d8ac8f459d145993e0840eeade4835df3e6858 Mon Sep 17 00:00:00 2001 From: Dustin Kirkland Date: Sun, 24 Jun 2012 13:12:57 -0500 Subject: [PATCH] * usr/lib/byobu/updates_available: LP: #976928, #1010505, #999151 - use run-one when running apt-check or apt-get - if run-one isn't installed on Debian/Ubuntu, update package checking won't work; sorry --- debian/changelog | 4 ++++ debian/control | 4 ++-- usr/lib/byobu/updates_available | 18 ++++++++---------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/debian/changelog b/debian/changelog index d34f918a..1bc64944 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,10 @@ byobu (5.20) unreleased; urgency=low * usr/bin/byobu-status: - fix upgrades to the new width handling, where some things were undefined + * usr/lib/byobu/updates_available: LP: #976928, #1010505, #999151 + - use run-one when running apt-check or apt-get + - if run-one isn't installed on Debian/Ubuntu, + update package checking won't work; sorry -- Dustin Kirkland Fri, 08 Jun 2012 17:25:23 -0500 diff --git a/debian/control b/debian/control index eb621b10..6a3a664d 100644 --- a/debian/control +++ b/debian/control @@ -17,7 +17,8 @@ Depends: gettext-base, python, python-newt (>= 0.52.2-11), - tmux (>= 1.5) | screen + tmux (>= 1.5) | screen, + util-linux, Recommends: screen, tmux (>= 1.5), @@ -25,7 +26,6 @@ Suggests: apport, lsb-release, po-debconf, - run-one, ttf-ubuntu-font-family (>= 0.80-0ubuntu1~medium), update-notifier-common, vim, diff --git a/usr/lib/byobu/updates_available b/usr/lib/byobu/updates_available index dfa58a16..8cc55a61 100755 --- a/usr/lib/byobu/updates_available +++ b/usr/lib/byobu/updates_available @@ -39,7 +39,7 @@ ___print_updates() { } ___update_cache() { - local mycache=$1 RUN_ONE= + local mycache=$1 flock="$1.lock" # Now we actually have to do hard computational work to calculate updates. # Let's try to be "nice" about it: renice 10 $$ >/dev/null 2>&1 || true @@ -47,28 +47,26 @@ ___update_cache() { # These are very computationally intensive processes. # Background this work, have it write to the cache files, # and let the next cache check pick up the results. - # Also, try to ensure that no more than one of these run at - # a given time; install the run-one package. - command -v run-one >/dev/null && RUN_ONE=run-one + # Ensure that no more than one of these run at a given time if [ -x /usr/lib/update-notifier/apt-check ]; then # If apt-check binary exists, use it - $RUN_ONE /usr/lib/update-notifier/apt-check 2>&1 | awk '-F;' 'END { print $1, $2 }' > "$mycache" & + flock -xn "$flock" /usr/lib/update-notifier/apt-check 2>&1 | awk '-F;' 'END { print $1, $2 }' > "$mycache" & elif command -v apt-get >/dev/null; then # If apt-get exists, use it - $RUN_ONE apt-get -s -o Debug::NoLocking=true upgrade | grep -c ^Inst > $mycache & + flock -xn "$flock" apt-get -s -o Debug::NoLocking=true upgrade | grep -c ^Inst > $mycache & elif command -v pkcon >/dev/null; then # use packagekit to show list of packages - $RUN_ONE pkcon get-updates -p | grep -c '^Package' > "$mycache" & + flock -xn "$flock" pkcon get-updates -p | grep -c '^Package' > "$mycache" & elif command -v zypper >/dev/null; then # If zypper exists, use it - $RUN_ONE zypper --no-refresh lu --best-effort | grep -c 'v |' > $mycache & + flock -xn "$flock" zypper --no-refresh lu --best-effort | grep -c 'v |' > $mycache & elif command -v yum >/dev/null; then # If yum exists, use it # TODO: We need a better way of counting updates available from a RH expert - $RUN_ONE yum list updates -q | grep -vc "Updated Packages" > $mycache & + flock -xn "$flock" yum list updates -q | grep -vc "Updated Packages" > $mycache & elif command -v pacman >/dev/null; then # If pacman (Archlinux) exists, use it - LC_ALL=C $RUN_ONE pacman -Sup | grep -vc "^\(::\| \)" > $mycache & + LC_ALL=C flock -xn "$flock" pacman -Sup | grep -vc "^\(::\| \)" > $mycache & fi }