2 # Fetch Package changelog for given source or binary package. Send it through
3 # a pager if stdout is a terminal.
4 # (C) 2010 Canonical Ltd
5 # Author: Martin Pitt <martin.pitt@ubuntu.com>
9 # evaluate and check CLI argumens
12 if [ -z "$1" -o -n "$3" ]; then
13 echo "Usage: $0 <package_name> [ <version> | candidate ]" >&2
19 # do we want the log for the currently installed version?
20 if [ -z "$version" ]; then
21 if ! dpkgs
=`dpkg -s $pkg 2>/dev/null`; then
22 echo "ERROR: Package $pkg is not installed; try 'candidate' version for uninstalled packages" >&2
25 version
=`echo "$dpkgs" | grep ^Version`
28 # turn binary package names into source
29 if src
=`apt-cache show $pkg 2>/dev/null| grep ^Source:`; then
33 # get version and directory
34 if ! showsrc
=`apt-cache showsrc $pkg 2>/dev/null` || [ -z "$showsrc" ] ; then
35 echo "ERROR: Source or binary package $pkg does not exist" >&2
39 if [ "$version" = "candidate" ]; then
40 version
=`echo "$showsrc"| grep -m 1 ^Version:`
43 # strip off tag name and epoch
44 version
=${version#Version: }
47 dir
=`echo "$showsrc"| grep ^Directory:`
48 dir
=${dir#Directory: }
51 OUT
=`mktemp -t "${pkg}.changes.XXXXXX"`
52 trap "rm $OUT" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
53 if ! wget
-q -O- http
://changelogs.ubuntu.com
/changelogs
/$dir/${pkg}_
${version}/changelog
> "$OUT"
55 echo "ERROR: changelog for this version is not (yet) available; try https://launchpad.net/ubuntu/+source/$pkg/+changelog" >&2