Skip to content

Instantly share code, notes, and snippets.

@darealshinji
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darealshinji/68e63b7591898dd8cf0c to your computer and use it in GitHub Desktop.
Save darealshinji/68e63b7591898dd8cf0c to your computer and use it in GitHub Desktop.
#!/bin/sh
# adress, i.e.: http://ppa.launchpad.net/djcj/nightingale/ubuntu/pool/main/n/nightingale/nightingale-common_1.13+20141127-1~utopic_all.deb
adress=${1}
# source package name, i.e.: nightingale
srcpkg=${2}
# version string
version=$(basename ${adress} | cut -d '_' -f2)
# Maximum size of the *.debian.tar.* file.
# If the filesize exceeds, the file won't be downloaded.
debtarball_maxsize=800000
debtarball_info=$(wget -q -O - "$(dirname ${adress})/${srcpkg}_${version}.dsc" | grep ${srcpkg}_${version}.debian.tar. | head -n1)
test -z "$debtarball_info" && exit 0
debtarball=$(echo $debtarball_info | cut -d' ' -f3)
debtarball_size=$(echo $debtarball_info | cut -d' ' -f2)
test $debtarball_size -ge $debtarball_maxsize && exit 0
case $(echo $debtarball | tail -c4) in
.xz) compression=J ;;
bz2) compression=j ;;
.gz) compression=z ;;
*)
esac
cd /tmp && rm -rf debian
wget -q -O - "$(dirname ${adress})/${debtarball}" | tar xvf${compression} - >/dev/null
cat debian/changelog && rm -rf debian
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment