On Tue, 2007-10-16 at 17:28 +0200, Luca Bedogni wrote:
[...]
> Hi
> a diff option that display changes in the wnpp output could be useful,
> for instance when running wnpp-alert in a cronjob. With this option you
> can see only the differences between different executions of the program,
> seeing only the new or close RFH, O or RFA bugs.
Thanks for the suggestion, and the patch. I've committed a slightly
modified version (log attached) which produces more "diffesque" output.
Adam
Author: adam-guest
Date: 2007-10-22 18:05:18 +0000 (Mon, 22 Oct 2007)
New Revision: 819
Modified:
trunk/debian/changelog
trunk/scripts/wnpp-alert.1
trunk/scripts/wnpp-alert.sh
Log:
* wnpp-alert: Add an option to display the changes since the last
invocation. Based on a patch by Luca Bedogni; thanks.
(Closes: #446910)
Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog 2007-10-17 19:53:27 UTC (rev 818)
+++ trunk/debian/changelog 2007-10-22 18:05:18 UTC (rev 819)
@@ -3,6 +3,9 @@
[ Adam D. Barratt ]
* licensecheck: Better detect 3-clause BSD licenses (Closes: #442630)
* bts: Update for new bugspam.cgi syntax (Closes: #445557)
+ * wnpp-alert: Add an option to display the changes since the last
+ invocation. Based on a patch by Luca Bedogni; thanks.
+ (Closes: #446910)
[ James Vega ]
* debcheckout: -u should imply -a, as documented. Thanks Luca Capello for
@@ -18,7 +21,7 @@
* debcommit: Name git tags "debian/$version" or just with the package
version number for native version numbers. Closes: #446699
- -- Joey Hess <[EMAIL PROTECTED]> Tue, 16 Oct 2007 16:33:07 -0400
+ -- Adam D. Barratt <[EMAIL PROTECTED]> Mon, 22 Oct 2007 18:49:49 +0100
devscripts (2.10.9) unstable; urgency=low
Modified: trunk/scripts/wnpp-alert.1
===================================================================
--- trunk/scripts/wnpp-alert.1 2007-10-17 19:53:27 UTC (rev 818)
+++ trunk/scripts/wnpp-alert.1 2007-10-22 18:05:18 UTC (rev 819)
@@ -4,7 +4,7 @@
.SH SYNOPSIS
\fBwnpp-alert\fR
.br
-\fBwnpp-alert \-\-help|\-\-version\fR
+\fBwnpp-alert \-\-help|\-\-version|\-\-diff\fR
.SH DESCRIPTION
\fBwnpp-alert\fR downloads the lists of packages which have been
orphaned (O), are up for adoption (RFA), or the maintainer has asked
@@ -12,6 +12,11 @@
packages installed on the system which are in those lists.
.SH OPTIONS
.TP
+.BR \-\-diff ", " \-d
+If the \fI~/.devscripts_cache\fP directory exists, compare the output of
+\fBwnpp-alert\fR to the previous output (cached in the file
+\fIwnpp-diff\fR) and output the differences.
+.TP
.BR \-\-help ", " \-h
Show a summary of options.
.TP
Modified: trunk/scripts/wnpp-alert.sh
===================================================================
--- trunk/scripts/wnpp-alert.sh 2007-10-17 19:53:27 UTC (rev 818)
+++ trunk/scripts/wnpp-alert.sh 2007-10-22 18:05:18 UTC (rev 819)
@@ -15,6 +15,7 @@
PROGNAME=`basename $0`
CACHEDIR=~/.devscripts_cache
+CACHEDDIFF="${CACHEDIR}/wnpp-diff"
usage () { echo \
"Usage: $PROGNAME [--help|-h|--version|-v]
@@ -31,6 +32,23 @@
Modifications: Julian Gilbey <[EMAIL PROTECTED]>"
}
+wnppdiff () {
+ if [ ! -f "$CACHEDDIFF" ]; then
+ # First use
+ comm -12 $WNPP_PACKAGES $INSTALLED | sed -e 's/+/\\+/g' | \
+ xargs -i egrep '^[A-Z]+ [0-9]+ {} ' $WNPP | \
+ tee $CACHEDDIFF
+ else
+ comm -12 $WNPP_PACKAGES $INSTALLED | sed -e 's/+/\\+/g' | \
+ xargs -i egrep '^[A-Z]+ [0-9]+ {} ' $WNPP > $WNPP_DIFF
+ sort -o $CACHEDDIFF $CACHEDDIFF
+ sort -o $WNPP_DIFF $WNPP_DIFF
+ comm -3 $CACHEDDIFF $WNPP_DIFF | \
+ sed -e 's/\t/\+/g' -e 's/^\([^+]\)/-\1/g'
+ mv $WNPP_DIFF $CACHEDDIFF
+ fi
+}
+
if [ "x$1" = "x--help" -o "x$1" = "x-h" ]; then usage; exit 0; fi
if [ "x$1" = "x--version" -o "x$1" = "x-v" ]; then version; exit 0; fi
@@ -55,6 +73,12 @@
trap "rm -f '$INSTALLED' '$WNPP' '$WNPPTMP' '$WNPP_PACKAGES'" \
0 1 2 3 7 10 13 15
+if [ "x$1" = "x--diff" ] || [ "x$1" = "x-d" ]; then
+ WNPP_DIFF=`mktemp -t wnppalert-wnpp_diff.XXXXXX`
+ trap "rm -f '$INSTALLED' '$WNPP' '$WNPPTMP' '$WNPP_PACKAGES' '$WNPP_DIFF'" \
+ 0 1 2 3 7 10 13 15
+fi
+
# Here's a really sly sed script. Rather than first grepping for
# matching lines and then processing them, this attempts to sed
# every line; those which succeed execute the 'p' command, those
@@ -86,5 +110,14 @@
sort -u \
> $INSTALLED
+if [ "x$1" = "x--diff" -o "x$1" = "x-d" ]; then
+ if [ -d "$CACHEDIR" ]; then
+ wnppdiff
+ exit 0
+ else
+ echo "$PROGNAME: Unable to create diff; displaying full output"
+ fi
+fi
+
comm -12 $WNPP_PACKAGES $INSTALLED | sed -e 's/+/\\+/g' | \
xargs -i egrep '^[A-Z]+ [0-9]+ {} ' $WNPP