Created
June 1, 2011 17:01
-
-
Save thepaul/1002763 to your computer and use it in GitHub Desktop.
extract and output the changelog from a .deb file, when possible
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
changelog_from_deb () { | |
# won't work when packages symlink their docs from another package from the same source; | |
# you'll get "No changelog found." | |
t="$(mktemp -d)" | |
p="$(dpkg-deb -f "$1" Package)" | |
fail=1 | |
dpkg-deb --fsys-tarfile "$1" | \ | |
tar -x --wildcards -C $t ./usr/share/doc/"$p"/changelog\* 2>/dev/null | |
for f in changelog.Debian.gz changelog.gz; do | |
if [ -e "$t/usr/share/doc/$p/$f" ]; then | |
gzip -dc < "$t/usr/share/doc/$p/$f" | |
fail=0 | |
break | |
fi | |
done | |
rm -rf $t | |
[ $fail -eq 0 ] || echo "No changelog found." >&2 | |
return $fail | |
} |
Very handy - thanks Paul.
Quick hack based on the code above, that avoids the temp directory, and writes to stdout.
#!/bin/bash
if [ ! -f $1 ]; then
echo "Package not found." >&2
exit
fi
p="$(dpkg-deb -f "$1" Package)"
dpkg-deb --fsys-tarfile $1 | tar -xf - --to-stdout --wildcards ./usr/share/doc/"$p"/changelog* | gzip -d 2>/dev/null
if [ $? -ne 0 ]; then
echo "Changelog not found." >&2
fi
For .rpm that would be
rpm -qp --changelog "$1"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
apt-listchanges does something similar