#!/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