5 PACKAGE="$(dpkg-parsechangelog | sed 's/^Source: //; t; d')"
8 # Get the main upstream tarball URL and version via uscan.
10 if [ "${line#http://}" != "$line" -a "${line#* }" = "$line" ]; then
13 if [ "${line#Newest version }" != "$line" ]; then
14 version="${line#Newest version on remote site is }"
15 version="${version%, local version is *}"
17 done < <(LANG=C uscan --report --verbose)
18 test -n "$main_url" -a -n "$version"
20 # Get the document tarball URL and the filenames of the tarballs.
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
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/")"
34 # Unpack, combine and repack.
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
42 rm -rf $main_file $doc_file $PACKAGE-$version.orig