You have an installed package and you would like to see the if any of its installed files have been changed. If there are changes, you would like to see the differences.
Verify Package
The solution to finding modified package files is the dpkg -V
*PACKAGE_NAME*
command. It lists any files whose md5sums do not
match those in the package metadata.
Example:
$ dpkg -V minidlna
??5?????? c /etc/minidlna.conf
Show Differences in Modified Package Files
get the package locally
apt-get download minidlna
PKG=minidlna.*deb
look at the list of files in the package
dpkg-deb --contents ${PKG}
Get the tarfile of the package and extract the file of interest to stdout:
dpkg-deb --fsys-tarfile ${PKG} \
| tar xfO - ./etc/minidlna.conf
Now put it all together. Given a debian package, DEB, and a file of interest, FILE, produce a difference listing using the following bash script:
#!/bin/bash DEB="$1" shift FILES=("${@}") error() { echo "$@" 1>&2 exit 1 } WORKDIR=$(mktemp -d) trap "rm -rf ${WORKDIR}" 0 1 2 15 (cd ${WORKDIR}; apt-get download ${DEB}) DEB_FILE=$(eval echo ${WORKDIR}/${DEB}*.deb) [ -f "${DEB_FILE}" ] || error "${DEB}: ${DEB_FILE} not found." for FILE in "${FILES[@]}"; do MEMBER=$(dpkg-deb --contents ${DEB_FILE} |grep "${FILE}" |awk '{print $NF}') if [ -n "${MEMBER}" ]; then diff -u <(dpkg-deb --fsys-tarfile ${DEB_FILE} \ |tar xfO - "${MEMBER}") "${FILE}" fi done
Here is a sample run:
$ debdiff minidlna /etc/minidlna.conf
Get:1 http://ports.ubuntu.com/ubuntu-ports bionic/universe arm64 minidlna arm64 1.2.1+dfsg-1 [128 kB]
Fetched 128 kB in 2s (61.7 kB/s)
--- /dev/fd/63 2020-04-22 10:51:12.718656103 -0600
+++ /etc/minidlna.conf 2019-03-01 22:34:52.672223536 -0700
@@ -78,11 +78,11 @@
# Name that the DLNA server presents to clients.
# Defaults to "hostname: username".
-#friendly_name=
+friendly_name=My Media Server
# Serial number the server reports to clients.
# Defaults to the MAC address of nework interface.
-#serial=
+serial=104857665536
# Model name the server reports to clients.
#model_name=Windows Media Connect compatible (MiniDLNA)