summaryrefslogtreecommitdiff
path: root/cmdline
diff options
context:
space:
mode:
authorMartin Pitt <martin.pitt@canonical.com>2010-11-09 11:31:47 +0100
committerMartin Pitt <martin.pitt@canonical.com>2010-11-09 11:31:47 +0100
commit23632f5a29fe7dbb02f7b13eb2b404632cc8ac8c (patch)
tree10eda2cabb1d0f1c6c4f072e59d96f25a9d88090 /cmdline
parent0e1945c14bee88013ad03c3b58e088c704f7ffa9 (diff)
* Add cmdline/apt-changelog: Script to fetch package changelog from
changelogs.ubuntu.com. Install it in cmdline/makefile and debian/rules. * Add doc/apt-changelog.1.xml, and install it in debian/rules.
Diffstat (limited to 'cmdline')
-rwxr-xr-xcmdline/apt-changelog59
-rw-r--r--cmdline/makefile7
2 files changed, 66 insertions, 0 deletions
diff --git a/cmdline/apt-changelog b/cmdline/apt-changelog
new file mode 100755
index 000000000..ac2b6e5fb
--- /dev/null
+++ b/cmdline/apt-changelog
@@ -0,0 +1,59 @@
+#!/bin/sh
+# Fetch Package changelog for given source or binary package. Send it through
+# a pager if stdout is a terminal.
+# (C) 2010 Canonical Ltd
+# Author: Martin Pitt <martin.pitt@ubuntu.com>
+
+set -e
+
+# evaluate and check CLI argumens
+pkg="$1"
+
+if [ -z "$1" -o -n "$3" ]; then
+ echo "Usage: $0 <package_name> [ <version> | candidate ]" >&2
+ exit 1
+fi
+
+version="$2"
+
+# do we want the log for the currently installed version?
+if [ -z "$version" ]; then
+ if ! dpkgs=`dpkg -s $pkg 2>/dev/null`; then
+ echo "ERROR: Package $pkg is not installed; try 'candidate' version for uninstalled packages" >&2
+ exit 1
+ fi
+ version=`echo "$dpkgs" | grep ^Version`
+fi
+
+# turn binary package names into source
+if src=`apt-cache show $pkg 2>/dev/null| grep ^Source:`; then
+ pkg=${src#Source: }
+fi
+
+# get version and directory
+if ! showsrc=`apt-cache showsrc $pkg 2>/dev/null` || [ -z "$showsrc" ] ; then
+ echo "ERROR: Source or binary package $pkg does not exist" >&2
+ exit 1
+fi
+
+if [ "$version" = "candidate" ]; then
+ version=`echo "$showsrc"| grep -m 1 ^Version:`
+fi
+
+# strip off tag name and epoch
+version=${version#Version: }
+version=${version#*:}
+
+dir=`echo "$showsrc"| grep ^Directory:`
+dir=${dir#Directory: }
+
+# fetch it
+OUT=`mktemp -t "${pkg}.changes.XXXXXX"`
+trap "rm $OUT" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
+if ! wget -q -O- http://changelogs.ubuntu.com/changelogs/$dir/${pkg}_${version}/changelog > "$OUT"
+then
+ echo "ERROR: changelog for this version is not (yet) available; try https://launchpad.net/ubuntu/+source/$pkg/+changelog" >&2
+ exit 1
+fi
+sensible-pager "$OUT"
+
diff --git a/cmdline/makefile b/cmdline/makefile
index 917ccc96a..61fa77dc2 100644
--- a/cmdline/makefile
+++ b/cmdline/makefile
@@ -64,3 +64,10 @@ include $(COPY_H)
#TO=$(BIN)
#TARGET=program
#include $(COPY_H)
+
+# The apt-changelog program
+SOURCE=apt-changelog
+TO=$(BIN)
+TARGET=program
+include $(COPY_H)
+