# HG changeset patch # User Christian Arnold # Date 1304341766 -7200 # Node ID bc049aafe8243a5f478f0f33e59b59b529699718 # Parent 54d18ebcdf023d0f573fc8b6759b3a079f2b03cc branche for lenny diff -r 54d18ebcdf02 -r bc049aafe824 99iusupgrade --- 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"; }; diff -r 54d18ebcdf02 -r bc049aafe824 apt-feed-logbuch.sh --- 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 diff -r 54d18ebcdf02 -r bc049aafe824 debian/control --- 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 diff -r 54d18ebcdf02 -r bc049aafe824 ius.upgrade.conf --- 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"