You are not logged in.
I am searching for an easy way for getting diffs on .conf (or any other) files from a given 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.)
Last edited by thiagowfx (2014-02-23 17:23:54)
Offline
Both /etc/pacman.conf and /etc/makepkg.conf are meant to be configured by users. There's nothing wrong with these files being a bit different than the ones originally included in the package.
Offline
Sorry, thought I made myself clear, pacman was only an example.
What I am trying to do is to find a way to list the diffs of any package.
Offline
Extract the original file from the package in your cache and redirect it into diff.
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.
Last edited by Slithery (2014-02-23 16:31:59)
Offline
This is a handy idea:
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.
Last edited by Trilby (2014-02-23 16:46:19)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
You could combine slithery's suggestion with a simple loop eg; pacman -Qkk `pacman -Qq` 2>&1 >/dev/null | while read type pkg file; do bsdtar -xOf .... $file | diff - $file ; done
Offline
Thanks slithery, that's exactly what I wanted. I'll try to create a wrapper for this.
Edit: ops, you guys are fast. I'll test your wrappers first.
Last edited by thiagowfx (2014-02-23 16:51:31)
Offline
Nice, everything is working properly. I defined these:
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.
Last edited by thiagowfx (2014-02-23 17:47:01)
Offline
Nice one thiagowfx, I'm stealing these.
Should prove useful for when I forget to document stuff as I'm going along
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.
Offline
@ thiagowfx,
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.
Last edited by x33a (2014-02-23 17:57:19)
Offline
Slightly updated version of the wrappers:
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.
Offline