[26868] in Source-Commits

home help back first fref pref prev next nref lref last post

/svn/athena r25805 - trunk/debathena/config/auto-update/debian

daemon@ATHENA.MIT.EDU (Jonathan D Reed)
Wed Dec 26 10:54:59 2012

Date: Wed, 26 Dec 2012 10:54:52 -0500
From: Jonathan D Reed <jdreed@MIT.EDU>
Message-Id: <201212261554.qBQFsqmL021429@drugstore.mit.edu>
To: source-commits@MIT.EDU
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Author: jdreed
Date: 2012-12-26 10:54:52 -0500 (Wed, 26 Dec 2012)
New Revision: 25805

Modified:
   trunk/debathena/config/auto-update/debian/athena-auto-update
   trunk/debathena/config/auto-update/debian/changelog
   trunk/debathena/config/auto-update/debian/debathena-auto-update.default
Log:
In auto-update:
  * Cleanup old kernels, keeping the two most recent ones installed.  This
    only works on the "-generic" flavor of kernels, on the assumption that
    anyone running a different flavor knows what they're doing.  It is
    only enabled by default on debathena-cluster workstations.


Modified: trunk/debathena/config/auto-update/debian/athena-auto-update
===================================================================
--- trunk/debathena/config/auto-update/debian/athena-auto-update	2012-12-26 15:30:50 UTC (rev 25804)
+++ trunk/debathena/config/auto-update/debian/athena-auto-update	2012-12-26 15:54:52 UTC (rev 25805)
@@ -171,11 +171,13 @@
 # Set conservative defaults in case file is missing
 UPDATE_FORCE_CONFFILE=old
 RUN_UPDATE_HOOK=no
+CLEANUP_OLD_KERNELS=no
 # Process defaults file
 [ -f /etc/default/debathena-auto-update ] && . /etc/default/debathena-auto-update
 # On cluster machines, force our desired settings
 # Ignore /etc/default/debathena-auto-update
 if dpkg-query --showformat '${Status}\n' -W "debathena-cluster" 2>/dev/null | grep -q ' installed$'; then
+    CLEANUP_OLD_KERNELS=yes
     UPDATE_FORCE_CONFFILE=new
     RUN_UPDATE_HOOK=yes
 fi
@@ -324,6 +326,35 @@
   fi
 fi
 
+# Cleanup old kernels
+if [ "$CLEANUP_OLD_KERNELS" = "yes" ]; then
+  echo "Cleaning up old kernels..."
+  kernels=$(dpkg-query -W -f '${Package}:${Status}\n' linux-image-\*-generic | \
+    awk -F ':' '$2=="install ok installed" {print $1;}' | \
+    sed -e 's/^linux-image-//' | sort -V)
+  numkernels=$(echo "$kernels" | wc -l)
+  echo "Found $numkernels kernels: $kernels"
+  if [ $numkernels -gt 2 ]; then
+    toremove=$(echo "$kernels" | head -$(($numkernels-2)))
+    kpkgs=
+    for k in $toremove; do
+      if [ "$(uname -r)" != "$k" ]; then
+        kpkgs="$kpkgs linux-image-$k"
+      fi
+    done
+    echo "Will remove these kernels: $kpkgs"
+    echo "Simulating..."
+    if v apt-get -y -s remove $kpkgs; then
+      echo "Simulation ok, proceeding..."
+      if ! v apt-get -y remove $kpkgs; then
+	warn "Something went wrong trying to remove kernels!"
+      fi
+    else
+	warn "Simulation failed!"
+    fi
+  fi
+fi
+
 # Finally, update the apt-file cache
 v apt-file update
 

Modified: trunk/debathena/config/auto-update/debian/changelog
===================================================================
--- trunk/debathena/config/auto-update/debian/changelog	2012-12-26 15:30:50 UTC (rev 25804)
+++ trunk/debathena/config/auto-update/debian/changelog	2012-12-26 15:54:52 UTC (rev 25805)
@@ -1,3 +1,12 @@
+debathena-auto-update (1.42) unstable; urgency=low
+
+  * Cleanup old kernels, keeping the two most recent ones installed.  This
+    only works on the "-generic" flavor of kernels, on the assumption that
+    anyone running a different flavor knows what they're doing.  It is
+    only enabled by default on debathena-cluster workstations.
+
+ -- Jonathan Reed <jdreed@mit.edu>  Wed, 26 Dec 2012 10:49:00 -0500
+
 debathena-auto-update (1.41) unstable; urgency=low
 
   * Ensure there are no double slashes in URLs, because Google hates them

Modified: trunk/debathena/config/auto-update/debian/debathena-auto-update.default
===================================================================
--- trunk/debathena/config/auto-update/debian/debathena-auto-update.default	2012-12-26 15:30:50 UTC (rev 25804)
+++ trunk/debathena/config/auto-update/debian/debathena-auto-update.default	2012-12-26 15:54:52 UTC (rev 25805)
@@ -1,5 +1,7 @@
 # Defaults for athena-auto-update(8) 
 #
+# (This file is sourced by a Bourne shell)
+#
 # N.B. The defaults for athena-auto-update (not upgrade) do not apply
 # when the debathena-cluster metapackage is installed
 
@@ -17,6 +19,9 @@
 # Values: yes, no
 RUN_UPDATE_HOOK=no
 
+# Cleanup old kernels (keeping the two most recent ones)?
+CLEANUP_OLD_KERNELS=no
+
 ######################################################################
 # Defaults for athena-auto-upgrade(8)
 


home help back first fref pref prev next nref lref last post