For the final installment of my “Summer of Scripts”, I’m showing a generic tool I wrote and a specialized version of it useful to Arch Linux users.
tarhash
computes
checksums for files inside tarballs without unpacking them.
% tarhash ~/src/mutt-1.5.21.tar.gz | head -3
9cc2ec57dc43e6768516898ebb90f3d76cb24d72 ./mutt-1.5.21/ABOUT-NLS
a87360b6b5b8d6d2cdeb83d54b3aa4a0a35bf090 ./mutt-1.5.21/BEWARE
5d1b9cfe259891e3408938afa6bdd3821953973f ./mutt-1.5.21/COPYRIGHT
It defaults to SHA1, but you can specify other hashes easily:
% tarhash --sha512 ~/src/mutt-1.5.21.tar.gz | head -3
808297837049d5b84b54ba780f87f08c22fb83ebbc62edaf3085966428593e76d28a7bf08cc4f029ee24a3a455fa292aac064b01ab8700240cb9ab0cc0284fae ./mutt-1.5.21/ABOUT-NLS
b0ac0f3c9297c0bf26c20ce58bf7bb234bd2ab84e5ee545345f39142e83f4d93ca1eaf406d77fb8ffab8ac748bb25ea8891412f6dc3d0058db73de73442b38eb ./mutt-1.5.21/BEWARE
68c306e6fc7a0b9a1dc47bbc700f034bc40c6c4e2125c35ce24deba44a95eb8113ce8dbd81a9fd9ad7208d28108e36a8f6bb078de416e42d7ad46271b13cca77 ./mutt-1.5.21/COPYRIGHT
Also, since it uses the powerful bsdtar of libarchive, it supports other archive formats as well:
% tarhash /usr/lib/python3.3/test/zipdir.zip
da39a3ee5e6b4b0d3255bfef95601890afd80709 ./a/b/c
Since the hashes of tarballs themselves easily can change (due to changed metadata, different order of files, etc…), this tool is nice to compare tarballs contentwise.
However, tarhash
actually is a by-product of
pacverify
, which
tries to find files that have changed in your Arch Linux installation,
compared to the original packages. Simply run it and after some time
you’ll see output like:
cpupower 3.10-1: /./etc/default/cpupower: FAILED
cpupower 3.10-1: sha256sum: WARNING: 1 computed checksum did NOT match
Of course, it’s ok that some config files have been changed, but that is your job to decide.
pacverify
is also good if you think some (possibly undetected?)
filesystem corruption took place (or someone fiddled in your files,
but be sure to compare against verified package files them).
That’s it for the summer. I hope you had fun and learned something. :)
NP: Toxoplasma—Alte Zeichen