Author: adsb
Date: 2008-10-27 23:18:36 +0000 (Mon, 27 Oct 2008)
New Revision: 1676

Modified:
   trunk/debian/changelog
   trunk/scripts/getbuildlog.1
   trunk/scripts/getbuildlog.sh
Log:
Allow the logs for the build with the largest version number to be
easily retrieved. Based on a patch by Jörg Sommer.

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog      2008-10-25 17:14:53 UTC (rev 1675)
+++ trunk/debian/changelog      2008-10-27 23:18:36 UTC (rev 1676)
@@ -10,6 +10,8 @@
         package versions containing tildes.
       - Simplify a couple of variable assignments and use shell string
         operations to extract the version and architecture from the logs.
+    + Allow the logs for the build with the largest version number to be
+      easily retrieved. Based on a patch by Jörg Sommer.
   * uscan: Document the USCAN_TIMEOUT configuration file variable.
     (Closes: #502517)
 

Modified: trunk/scripts/getbuildlog.1
===================================================================
--- trunk/scripts/getbuildlog.1 2008-10-25 17:14:53 UTC (rev 1675)
+++ trunk/scripts/getbuildlog.1 2008-10-27 23:18:36 UTC (rev 1676)
@@ -14,6 +14,13 @@
 \fIarchitecture-pattern\fR will be downloaded. The version and architecture
 patterns are interpreted as extended regular expressions as described in
 \fBgrep\fR(1).
+.PP
+If \fIversion-pattern\fR is "last" then only the logs for the most 
+recent version of \fIpackage\fR found on buildd.debian.org will be 
+downloaded.
+.PP
+If \fIversion-pattern\fR is "last-all" then the logs for the most recent
+version found on each build log index will be downloaded.
 .SH OPTIONS
 .TP
 \fB\-h\fR, \fB\-\-help\fR

Modified: trunk/scripts/getbuildlog.sh
===================================================================
--- trunk/scripts/getbuildlog.sh        2008-10-25 17:14:53 UTC (rev 1675)
+++ trunk/scripts/getbuildlog.sh        2008-10-27 23:18:36 UTC (rev 1676)
@@ -29,6 +29,12 @@
   If <version-pattern> or <architecture-pattern> are given, only build logs
   whose versions and architectures, respectively, matches the given patterns
   are downloaded.
+
+  If <version-pattern> is "last" then only the logs for the most recent
+  version of <package> found on buildd.debian.org will be downloaded.
+
+  If <version-pattern> is "last-all" then the logs for the most recent
+  version found on each build log index will be downloaded.
 Options:
   -h, --help        Show this help message.
   -V, --version     Show version and copyright information.
@@ -69,6 +75,15 @@
 ARCH=${3:-[[:alnum:]-]+}
 ESCAPED_PACKAGE=`echo "$PACKAGE" | sed -e 's/\+/\\\+/g'`
 
+GET_LAST_VERSION=no
+if [ "$VERSION" = "last" ]; then
+    GET_LAST_VERSION=yes
+    VERSION=[:~+.[:alnum:]-]+
+elif [ "$VERSION" = "last-all" ]; then
+    GET_LAST_VERSION=all
+    VERSION=[:~+.[:alnum:]-]+
+fi
+
 PATTERN="fetch\.(cgi|php)\?&pkg=$ESCAPED_PACKAGE&ver=$VERSION&arch=$ARCH&\
 stamp=[[:digit:]]+"
 
@@ -84,7 +99,27 @@
     # Quick-and-dirty unescaping
     sed -i -e "s/%2B/\+/g" -e "s/%3A/:/g" -e "s/%7E/~/g" $ALL_LOGS
 
-    for match in `grep -E -o "$PATTERN" $ALL_LOGS`; do
+    # If only the last version was requested, extract and sort
+    # the listed versions and determine the highest
+    if [ "$GET_LAST_VERSION" != "no" ]; then
+       LASTVERSION=$( \
+           for match in `grep -E -o "$PATTERN" $ALL_LOGS`; do
+               ver=${match##*ver=}
+               echo ${ver%%&*}
+           done | perl -e '
+               use Devscripts::Versort;
+               while (<>) { push @versions, [$_]; }
+               @versions = Devscripts::Versort::versort(@versions);
+               print $versions[0][0]; ' | sed -e "s/\+/\\\+/g"
+       )
+
+       NEWPATTERN="fetch\.(cgi|php)\?&pkg=$ESCAPED_PACKAGE&\
+ver=$LASTVERSION&\arch=$ARCH&stamp=[[:digit:]]+"
+    else
+       NEWPATTERN=$PATTERN
+    fi
+
+    for match in `grep -E -o "$NEWPATTERN" $ALL_LOGS`; do
        ver=${match##*ver=}
        ver=${ver%%&*}
        arch=${match##*arch=}
@@ -94,6 +129,11 @@
     done
 
     rm -f $ALL_LOGS
+
+    if [ "$GET_LAST_VERSION" = "yes" ]; then
+       PATTERN=$NEWPATTERN
+       GET_LAST_VERSION=no
+    fi
 }
 
 getbuildlog http://buildd.debian.org



-- 
To unsubscribe, send mail to [EMAIL PROTECTED]

Reply via email to