Hi,

On Tue, 2008-05-27 at 17:36 +0200, Frank S. Thomas wrote:
> I'd like to propose my getbuildlog script for inclusion in devscripts. It 
> downloads package build logs from  Debian auto-builders (buildd.debian.org, 
> buildd.debian-ports.org, and experimental.debian.net) that matches given 
> version- and architecture-patterns. I've outlined my motivation for writing 
> this script in:
>   http://lists.debian.org/debian-mentors/2008/05/msg00404.html
> I think this script could be useful for others too. The diff to the current 
> SVN is attached.

Thanks for the unusually (but welcome :-) comprehensive patch.

I've added your script, with a couple of small tweaks to make it cope
with packages with names containing + symbols and versions containing
epochs. I've attached a diff against your original script; hopefully you
agree with the changes :)

Regards,

Adam
--- scripts/getbuildlog.sh	2008-05-27 18:41:41.000000000 +0100
+++ trunk/scripts/getbuildlog.sh	2008-05-27 18:41:09.000000000 +0100
@@ -65,10 +65,11 @@
 fi
 
 PACKAGE=$1
-VERSION=`(test -z "$2" && echo "[~+.[:alnum:]-]+") || echo "$2"`
+VERSION=`(test -z "$2" && echo "[:~+.[:alnum:]-]+") || echo "$2"`
 ARCH=`(test -z "$3" && echo "[[:alnum:]-]+") || echo "$3"`
+ESCAPED_PACKAGE=`echo "$PACKAGE" | sed -e 's/\+/\\\+/g'`
 
-PATTERN="fetch\.(cgi|php)\?&pkg=$PACKAGE&ver=$VERSION&arch=$ARCH&\
+PATTERN="fetch\.(cgi|php)\?&pkg=$ESCAPED_PACKAGE&ver=$VERSION&arch=$ARCH&\
 stamp=[[:digit:]]+"
 
 getbuildlog() {
@@ -80,10 +81,13 @@
     # Put each href in $ALL_LOGS on a separate line so that $PATTERN
     # matches only one href. This is required because grep is greedy.
     sed -i -e "s/href=\"/\nhref=\"/g" $ALL_LOGS
+    # Quick-and-dirty unescaping
+    sed -i -e "s/%2B/\+/g" -e "s/%3A/:/g" $ALL_LOGS
 
     for match in `grep -E -o "$PATTERN" $ALL_LOGS`; do
         ver=`echo $match | cut -d'&' -f3 | cut -d'=' -f2`
         arch=`echo $match | cut -d'&' -f4 | cut -d'=' -f2`
+	match=`echo $match | sed -e 's/\+/%2B/g'`
         wget -O "${PACKAGE}_${ver}_${arch}.log" "$BASE/$match&file=log"
     done
 

Reply via email to