#! /bin/bash

exec >&3

strip_md5sum() {
    sed 's/^.* \+//' "$@"
}

print_changed_files() {
    (cd / &&
        strip_md5sum "$@" |
        xargs md5sum 2>/dev/null | sort |
        comm -3 - <(sort "$@")
    ) | strip_md5sum | sort -u

}

files_in_usrlocal() {
    [ ! -d /usr/local/share/request-tracker4/ ] || [ `find /usr/local/share/request-tracker4/ -type f | wc -l` -gt 0 ] && echo -e "\nThere are locally modified files in /usr/local/share/request-tracker4/,\n these may (or may not) be the source of the problem.\n"
}

sumfile=/var/lib/dpkg/info/request-tracker4.md5sums

echo "Changed files:"
print_changed_files "$sumfile" | sed 's/^/  /'

files_in_usrlocal
