branche for lenny lenny
authorChristian Arnold <arnold@schlittermann.de>
Mon, 02 May 2011 15:09:26 +0200
branchlenny
changeset 2 bc049aafe824
parent 1 54d18ebcdf02
child 3 acee28461123
branche for lenny
99iusupgrade
apt-feed-logbuch.sh
debian/control
ius.upgrade.conf
--- a/99iusupgrade	Fri Apr 29 16:34:44 2011 +0200
+++ b/99iusupgrade	Mon May 02 15:09:26 2011 +0200
@@ -1,7 +1,4 @@
 DPkg {
-  Pre-Invoke {
-    "wc -l < /var/log/apt/history.log > /tmp/lines_count.dat";
-  };
   Post-Invoke {
     "test -x /usr/sbin/apt-feed-logbuch && /usr/sbin/apt-feed-logbuch $(echo $PPID) || true";
   };
--- a/apt-feed-logbuch.sh	Fri Apr 29 16:34:44 2011 +0200
+++ b/apt-feed-logbuch.sh	Mon May 02 15:09:26 2011 +0200
@@ -11,26 +11,34 @@
 export LANG=C
 export LC_CTYPE=en_US.UTF-8
 
-APT_LOG="/var/log/apt/history.log"
-LINES_COUNT="/tmp/lines_count.dat"
-LOGBUCH_OPT=""
+LOGBUCH_OPTS=""
 
 if test -f /etc/default/ius.upgrade.conf; then
     . /etc/default/ius.upgrade.conf
 fi
 
+TMPFILE1=$(tempfile)
+TMPFILE2=$(tempfile)
+trap "rm -f $TMPFILE1 $TMPFILE2" EXIT
+
 APT_CMD=$(ps -p $1 -o args=)
-APT_TMP="/tmp/$$.tmp"
-APT_OUT="/tmp/$$.out"
+
+APT=`echo $APT_CMD | awk '{ print $1 }'`
 
-if [ $APT_LOG -nt $LINES_COUNT ]; then
-  BEFOR=$(cat $LINES_COUNT)
-  AFTER=$(wc -l < $APT_LOG)
-  LINES=$(($AFTER - $BEFOR - 1))
-  echo APT: $APT_CMD > $APT_OUT
-  tail -n $LINES $APT_LOG | sed -e '/^Start-Date:/d;/^Commandline:/d;/^End-Date:/d' >> $APT_TMP
-  perl -ne 'chomp; ($action, $packages) = split " ", $_, 2; print map { "- $action $_\n" } $packages =~ /\S+\s\(.*?\)/g' $APT_TMP >> $APT_OUT
-  logbuch $LOGBUCH_OPT --message=@$APT_OUT
-  # cleanup
-  rm -f $APT_TMP $LINES_COUNT $APT_OUT
+if [ "$APT" = "aptitude" ]; then
+    APT_OPTS="--assume-yes --quiet --verbose --show-versions"
+else
+    APT_OPTS="--yes"
 fi
+
+APT_ARGS=$(echo $APT_CMD | sed "s/$APT[[:space:]]\+//")
+
+# Simulation
+$APT --simulate $APT_OPTS $APT_ARGS > $TMPFILE1 2>&1
+if tail -1 $TMPFILE1 | grep --quiet --ignore-case abort; then
+    exit
+fi
+
+grep '^Inst\|Conf\|Remv\|Purg' $TMPFILE1 > $TMPFILE2
+
+logbuch $LOGBUCH_OPTS --message=apt:"$APT_CMD"@$TMPFILE2
--- a/debian/control	Fri Apr 29 16:34:44 2011 +0200
+++ b/debian/control	Mon May 02 15:09:26 2011 +0200
@@ -7,6 +7,6 @@
 
 Package: ius.upgrade
 Architecture: all
-Depends: logbuch (>= 0.17), apt (>= 0.8.10.3)
+Depends: logbuch (>= 0.31), apt (>= 0.7.20.2+lenny2)
 Description: short script for logging apt-get/aptitude actions to logbuch
  logging all apt-get/aptitude actions automatically to logbuch
--- a/ius.upgrade.conf	Fri Apr 29 16:34:44 2011 +0200
+++ b/ius.upgrade.conf	Mon May 02 15:09:26 2011 +0200
@@ -1,3 +1,1 @@
-APT_LOG="/var/log/apt/history.log"
-LINES_COUNT="/tmp/lines_count.dat"
 #LOGBUCH_OPT="--nomail --nodb"