]> git.decadent.org.uk Git - ion3.git/blob - debian/get-orig-source
Started renaming.
[ion3.git] / debian / get-orig-source
1 #!/bin/bash
2
3 set -e
4
5 PACKAGE="$(dpkg-parsechangelog | sed 's/^Source: //; t; d')"
6 test -n "$PACKAGE"
7
8 # Get the main upstream tarball URL and version via uscan.
9 while read line; do
10     if [ "${line#http://}" != "$line" -a "${line#* }" = "$line" ]; then
11         main_url="${line}"
12     fi
13     if [ "${line#Newest version }" != "$line" ]; then
14         version="${line#Newest version on remote site is }"
15         version="${version%, local version is *}"
16     fi
17 done < <(LANG=C uscan --report --verbose)
18 test -n "$main_url" -a -n "$version"
19
20 # Get the document tarball URL and the filenames of the tarballs.
21 # Download them.
22 main_file=${main_url##*/}
23 doc_url=${main_url/ion/ion-doc}
24 doc_file=${doc_url##*/}
25 wget -O $main_file $main_url
26 wget -O $doc_file $doc_url
27
28 # Work out what directories we expect to be in them, and check this.
29 main_dir=${main_file%.tar.gz}
30 doc_dir=${doc_file%.tar.gz}
31 test -z "$(tar tzf $main_file | grep -v "^$main_dir/")"
32 test -z "$(tar tzf $doc_file | grep -v "^$doc_dir/")"
33
34 # Unpack, combine and repack.
35 tar xzf $main_file
36 tar xzf $doc_file
37 mv $main_dir $PACKAGE-$version.orig
38 mv $doc_dir $PACKAGE-$version.orig/doc
39 tar cf - $PACKAGE-$version.orig | gzip -c9 > $PACKAGE_$version.orig.tar.gz
40
41 # Clean up.
42 rm -rf $main_file $doc_file $PACKAGE-$version.orig