Skip to content

Instantly share code, notes, and snippets.

@ilyaevseev
Last active August 29, 2015 13:56
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 ilyaevseev/8818910 to your computer and use it in GitHub Desktop.
Save ilyaevseev/8818910 to your computer and use it in GitHub Desktop.
For given deb-package, creates list of changed files and line-by-line diff.
#!/bin/sh
Install_me_so='
apt-get install debsums
wget -O /usr/local/bin/deb2diffs https://gist.github.com/ilyaevseev/8818910/raw/67677ef6324554f51aea390e39597ad97140d3de/deb2diffs.sh
chmod +x /usr/local/bin/deb2diffs
'
#set -x
Fail() { echo "$@" 1>&2; exit 1; }
test -n "$1" || Fail "Usage: $0 <pkgname> Example: deb2diffs otrs2"
pkgname="$1"
debfile="$(find /var/cache/apt/archives/ -maxdepth 1 -type f -name ${pkgname}*.deb | sort -r | head -1)"
test -s "$debfile" || Fail "Missing package ${pkgname}."
longname=$(basename $debfile .deb)
if test -d "$longname"; then
: Fail "Directory $name already exists."
else
dpkg -x "$debfile" "$longname"
fi
tstamp="$(LANG=C date +%Y-%m-%d)"
debsums $pkgname |
awk '/FAILED$/ {print $1;}' |
tee "$longname.$tstamp.changed" |
while read filepath; do
diff -u "${longname}/${filepath}" "${filepath}";
done > "$longname.$tstamp.diff"
## END ##
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment