You are not logged in.

#1 2010-05-27 01:23:03

dkorzhevin
Member
Registered: 2010-04-23
Posts: 61

md5 checksums of all packages from the specified directory

How to check md5 checksums of all packages from the specified directory with pacman?

Offline

#2 2010-05-27 01:45:33

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: md5 checksums of all packages from the specified directory

Maybe you should check some devtools?
Scripting it shouldn't be too hard.

You didn't provide too much info, but try this to get the ball rolling:

#!/bin/bash

INST="/var/lib/pacman/sync/core/zlib-1.2.5-1"
PKG="zlib-1.2.5-1-i686.pkg.tar.xz"

A=$(grep -A1 %MD5SUM% $INST/desc | grep -v %MD5SUM%)
B=$(md5sum $PKG | cut -d ' ' -f 1)

if [[ "$A" != "$B" ]] ; then
     echo error $PKG
fi

As it is, you have to run it from the same dir where 'zlib-1.2.5-1-i686.pkg.tar.xz' is, but of course you may add more vars, use find to get the filenames etc.

It's 4.30 AM, the sun comes up and I'm going to bed.
Hmmm, the blue sky and violet-pink clouds remind me of Arch homepage ;P

Last edited by karol (2010-05-27 02:25:22)

Offline

#3 2010-05-28 19:47:33

akephalos
Member
From: Romania
Registered: 2009-04-22
Posts: 114

Re: md5 checksums of all packages from the specified directory

karol wrote:

It's 4.30 AM, the sun comes up and I'm going to bed.
Hmmm, the blue sky and violet-pink clouds remind me of Arch homepage ;P

Hehe, it's a nice feeling, nevertheless.
---

@dkorzhevin: here's a script I've made when I needed this:

#!/bin/bash

echo -n "" > pkgNotFound
echo -n "" > pkgSums

names=`pacman -Slq`

for name in $names
do
    versionLine=`pacman -Si $name | grep "Version        : "`
    version=`echo -n $versionLine | sed -e 's/Version : //g'`
    md5Line=`pacman -Si $name | grep "MD5 Sum        : "`
    md5=`echo -n $md5Line | sed -e 's/MD5 Sum : //g'`

    pkgPath=`find /var/cache/pacman/pkg/ -name $name"-"$version"*"`
    
    if [ "$pkgPath" = "" ]
    then
        echo "Error: "$name" package not found in cache." >> pkgNotFound
    else
        echo $md5"  "$pkgPath >> pkgSums
    fi
done

exit 0

So your output will be located in the file "pkgSums" and it will look like this, these are the checksums that pacman displays, and the paths of your local packages:

4ce0d40359bfa1a4a0f47a0e53e65fa5  /var/cache/pacman/pkg/acl-2.2.49-1-x86_64.pkg.tar.xz
24df396b3146d1a203e0d4f4d6edd67b  /var/cache/pacman/pkg/ar9170-fw-1.0-2-any.pkg.tar.gz
8454e0fc947f9c8ce4ac5c39ed6ef165  /var/cache/pacman/pkg/attr-2.4.44-1-x86_64.pkg.tar.gz
9ef6b0ce43a4660170df21ead2f8e711  /var/cache/pacman/pkg/autoconf-2.65-2-any.pkg.tar.xz
505fe675565601f6ca803779601837cf  /var/cache/pacman/pkg/automake-1.11.1-1-any.pkg.tar.gz
...

To check the checksums against the packages, just run md5 with the newly created file, if you get output then something stinks smile:

# md5sum -c --quiet pkgSums

There's another file "pkgNotFound" for the packages which are found in pacman but not on your disk. So make sure you don't have these two files already, in the current directory, containing important information - they will be overwritten.

Offline

#4 2010-05-28 19:58:03

Pierre
Developer
From: Bonn
Registered: 2004-07-05
Posts: 1,967
Website

Re: md5 checksums of all packages from the specified directory

No idea what you want to actually achieve, but have a look at this script which checks the whole repo: https://github.com/pierres/repo-tools/b … /checkrepo

Offline

Board footer

Powered by FluxBB