summaryrefslogtreecommitdiff
path: root/contrib/get-bug-attachments
diff options
context:
space:
mode:
authorMorgan Deters <mdeters@gmail.com>2012-09-26 18:51:48 +0000
committerMorgan Deters <mdeters@gmail.com>2012-09-26 18:51:48 +0000
commitc1e936b9cec3d731778b95504770e48c28fd1a65 (patch)
treed0302810f915f51b4c82e4e5d36267b35ba7af38 /contrib/get-bug-attachments
parentf6fcb28606d8eca239c3a71e7f42a2bbbf0a8995 (diff)
Fix a handful of things for Mac, and Java bindings.
Also add a "mac-build" script that sets up prerequisites for Mac.
Diffstat (limited to 'contrib/get-bug-attachments')
-rwxr-xr-xcontrib/get-bug-attachments29
1 files changed, 23 insertions, 6 deletions
diff --git a/contrib/get-bug-attachments b/contrib/get-bug-attachments
index 16af3c67f..3bb433c51 100755
--- a/contrib/get-bug-attachments
+++ b/contrib/get-bug-attachments
@@ -28,7 +28,7 @@ function webcat {
function webget {
if which wget &>/dev/null; then
- tmpfile="$(mktemp)"
+ tmpfile="$(mktemp get_bug_attach.$$.XXXXXXXX)"
filename="$(wget -qS -O "$tmpfile" "$1" 2>&1 | grep 'Content-disposition: attachment' | sed 's,.*filename="\(.*\)".*,\1,')"
ext="$(echo "$filename" | sed 's,.*\.\(.*\),\1,')"
if [ -e "$2.$ext" ] && ! diff -q "$tmpfile" "$2.$ext" &>/dev/null; then
@@ -45,8 +45,23 @@ function webget {
echo "$2.$ext"
fi
elif which curl &>/dev/null; then
- mkdir -p "$(dirname "$2")"
- curl "$1" >"$2"
+ tmpfile="$(mktemp get_bug_attach.$$.XXXXXXXX)"
+ filename="$(curl --head "$1" 2>&1 | grep 'Content-disposition: attachment' | sed 's,.*filename="\(.*\)".*,\1,')"
+ curl "$1" >"$tmpfile" 2>/dev/null
+ ext="$(echo "$filename" | sed 's,.*\.\(.*\),\1,')"
+ if [ -e "$2.$ext" ] && ! diff -q "$tmpfile" "$2.$ext" &>/dev/null; then
+ c=a
+ while [ -e "$2$c.$ext" ] && ! diff -q "$tmpfile" "$2$c.$ext" &>/dev/null; do
+ c=$(echo $c | tr a-y b-z)
+ done
+ mkdir -p "$(dirname "$2")"
+ mv "$tmpfile" "$2$c.$ext"
+ echo "$2$c.$ext"
+ else
+ mkdir -p "$(dirname "$2")"
+ mv "$tmpfile" "$2.$ext"
+ echo "$2.$ext"
+ fi
else
echo "Please install wget or curl." >&2;
exit 1
@@ -61,15 +76,17 @@ for attachment in $(\
| sort -nu); do
let count++
- echo -n "Downloading attachment $attachment..."
+ printf "%-30s " "Downloading attachment $attachment..."
webget "http://church.cims.nyu.edu/bugs/attachment.cgi?id=$attachment" "test/regress/regress0/bug$bugid"
done
if [ $count -eq 0 ]; then
- echo "There are no bug testcase attachments for bug #$bugid."
+ echo "There are no bug attachments for bug #$bugid."
else
- echo "Downloaded $count bug testcases for bug #$bugid."
+ s=s
+ [ $count -eq 1 ] && s=
+ echo "Downloaded $count bug attachment$s for bug #$bugid."
fi
done
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback