]> git.decadent.org.uk Git - ion3.git/blobdiff - debian/get-orig-source
Added get-orig-source script and rule to download and combine both upstream tarballs.
[ion3.git] / debian / get-orig-source
diff --git a/debian/get-orig-source b/debian/get-orig-source
new file mode 100755 (executable)
index 0000000..35cca88
--- /dev/null
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+set -e
+
+# Get the main upstream tarball URL and version via uscan.
+while read line; do
+    if [ "${line#http://}" != "$line" -a "${line#* }" = "$line" ]; then
+       main_url="${line}"
+    fi
+    if [ "${line#Newest version }" != "$line" ]; then
+       version="${line#Newest version on remote site is }"
+       version="${version%, local version is *}"
+    fi
+done < <(LANG=C uscan --report --verbose)
+test -n "$main_url" -a -n "$version"
+
+# Get the document tarball URL and the filenames of the tarballs.
+# Download them.
+main_file=${main_url##*/}
+doc_url=${main_url/ion/ion-doc}
+doc_file=${doc_url##*/}
+wget -O $main_file $main_url
+wget -O $doc_file $doc_url
+
+# Work out what directories we expect to be in them, and check this.
+main_dir=${main_file%.tar.gz}
+doc_dir=${doc_file%.tar.gz}
+test -z "$(tar tzf $main_file | grep -v "^$main_dir/")"
+test -z "$(tar tzf $doc_file | grep -v "^$doc_dir/")"
+
+# Unpack, combine and repack.
+tar xzf $main_file
+tar xzf $doc_file
+mv $main_dir ion3-$version.orig
+mv $doc_dir ion3-$version.orig/doc
+tar cf - ion3-$version.orig | gzip -c9 > ion3_$version.orig.tar.gz
+
+# Clean up.
+rm -rf $main_file $doc_file ion3-$version.orig