Skip to content

Instantly share code, notes, and snippets.

@sgpinkus
Created November 14, 2016 11:08
Show Gist options
  • Save sgpinkus/aaca392bf6ca192cd020327320dfd9b2 to your computer and use it in GitHub Desktop.
Save sgpinkus/aaca392bf6ca192cd020327320dfd9b2 to your computer and use it in GitHub Desktop.
#!/bin/bash
fail() {
echo "$@"
exit 1
}
[[ -z "$1" ]] && fail "Usage: $0 <path to file to check>"
FILE=`readlink -f "$1"`
[[ -f "$FILE" ]] || fail "File must exist. $FILE does not."
RFILE=`echo "$FILE" | cut --complement -c 1`
PKG=`dpkg -S "$FILE" | cut -f1 -d":"`
[[ -z "$PKG" ]] && fail "No package for file '$FILE'"
echo "FILE=$FILE/$RFILE; PKG=$PKG; QRY=`dpkg-query -W systemd`"
PKGMD5=`dpkg-query --control-show "$PKG" md5sums | grep "$RFILE$"`
CURMD5=`md5sum "$FILE"`
echo "Current: $CURMD5"
echo "Package: $PKGMD5"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment