function qkkdiff-file {
if [[ "$1" == "" ]];
then
echo "Example usage: qkkdiff-file /etc/pacman.conf"
elif [[ -f "$1" ]];
then
pkg="$(pacman -Qo $1 | awk '//{printf "%s-%s", $(NF-1), $NF;}')"
bsdtar -xOf /var/cache/pacman/pkg/${pkg}-$(uname -m).pkg.tar.xz "${1/\//}" | diff - "$1"
return 0
else
echo "The provided file \e[0;31m${1}\e[0m does not exist."
return 1
fi
}
function qkkdiff {
if [[ "$1" == "" ]];
then
echo "Example usage:\nqkkdiff pacman"
elif ! pacman -Q "$1";
then
return 1
else
# Example usage: qkkdiff pacman
ver=$(pacman -Q "$1" | cut -f2 -d' ')
pacman -Qkkq "$1" | while read package file; do echo $file; bsdtar -xOf /var/cache/pacman/pkg/${package}-${ver}-$(uname -m).pkg.tar.xz ${file/\//} | diff - $file ; done
return 0
fi
}
I'll not be posting more updates here. Those are available in ~/.aliases of my dotfiles.
]]>While not a full replacement for what you want, pacman ships with pacdiff, which provides a way to diff the files which generate a pacnew file.
]]>You may want to tweak them a bit though, at the minute they only work for x86_64 packages. They'll fall over if the package architecture is any or i686.
]]>qkkdiff () {
ver=$(pacman -Q $1 | cut -f2 -d' ')
pacman -Qkkq $1 | while read package file
do
echo $file
bsdtar -xOf /var/cache/pacman/pkg/${package}-${ver}-x86_64.pkg.tar.xz ${file/\//} | diff -uN - $file
done
return 0
}
qkkdiff-file () {
pkg="$(pacman -Qo $1 | awk '//{printf "%s-%s", $(NF-1), $NF;}')"
bsdtar -xOf /var/cache/pacman/pkg/${pkg}-x86_64.pkg.tar.xz ${1/\//} | diff -uN - $1
return 0
}
You are supposed to use the first one on a package, and the second one on a file.
]]>Edit: ops, you guys are fast. I'll test your wrappers first.
]]>pkg="$(pacman -Qo $1 | awk '//{printf "%s-%s", $(NF-1), $NF;}')"
bsdtar -xOf /var/cache/pacman/pkg/${pkg}-x86_64.pkg.tar.xz ${1/\//} | diff - $1
pass the file name as the first parameter.
]]>bsdtar -xOf /var/cache/pacman/pkg/pacman-4.1.2-5-x86_64.pkg.tar.xz etc/pacman.conf | diff - /etc/pacman.conf
Wrap that into a script or function of some sort.
]]>What I am trying to do is to find a way to list the diffs of any package.
]]>I'll give one example to better explain: suppose I want to see which config files from the pacman package I have modified. I could start with
pacman -Qkk pacman
which is really nice, listing (in my case):
warning: pacman: /etc/makepkg.conf (Modification time mismatch)
warning: pacman: /etc/makepkg.conf (Size mismatch)
warning: pacman: /etc/pacman.conf (Modification time mismatch)
warning: pacman: /etc/pacman.conf (Size mismatch)
But I want a little more of just finding the modified files: I want to see which modifications have been made to them. Exactly a diff between the current file and the original file from the package.
Question is: does pacman have an integrated way to do it, maybe other addicional flag to -Qkk that I've missed? If not, what could I do trying to Keep it Simple?
(Of course, I could just find the original files, then manually doing the diffs, but I am trying to find if something more practical/direct already exists.)