Page MenuHomeFreeBSD

getpatch
ActivePublic

Authored by bapt on Jun 5 2014, 10:37 AM.
#!/bin/sh
fget()
{
fetch -q --no-verify-peer -o - "https://bugs.freebsd.org/bugzilla/jsonrpc.cgi?method=Bug.attachments&params=[{\"ids\": [\"$1\"]}]"
}
patch=$1
res=$(fget $patch)
error=$(echo $res | jshon -e error -t)
if [ $error = "object" ]; then
echo $res | jshon -e error -e message
exit 1
fi
nbattach=$(echo $res | jshon -e result -e bugs -e $patch -l)
if [ $nbattach -eq 0 ]; then
echo "No attachement found for #$patch"
exit 1
fi
i=0
while [ $i -lt $nbattach ]; do
obsolete=$(echo $res | jshon -e result -e bugs -e $patch -e $i -e is_obsolete)
if [ $obsolete -eq 1 ]; then
continue
fi
filename=$(echo $res | jshon -e result -e bugs -e $patch -e $i -e file_name -u)
data=$(echo $res | jshon -e result -e bugs -e $patch -e $i -e data -u)
echo "Creating $filename"
echo "${data}==" | b64decode -r > $filename
i=$(($i + 1))
done

Event Timeline

bapt edited the content of this paste. (Show Details)Jun 5 2014, 10:37 AM
bapt updated the paste's language from autodetect to bash.
bapt changed the visibility from "All Users" to "Public (No Login Required)".
bapt changed the title of this paste from untitled to getpatch.