You are not logged in.

#1 2007-06-18 05:46:55

drakosha
Member
Registered: 2006-01-03
Posts: 253
Website

check installed packages integrity? [Solved - script inside]

Hi,

is it possible to check installed packages for integrity - i.e. missing/changed files, etc. I looked at pacman man, but found nothing ...

Last edited by drakosha (2007-06-18 17:53:24)

Offline

#2 2007-06-18 07:04:39

klixon
Member
From: Nederland
Registered: 2007-01-17
Posts: 525

Re: check installed packages integrity? [Solved - script inside]

#!/bin/bash

PACKAGE = $1

for file in $( pacman -Ql ${PACKAGE} | cut -d' ' -f2 ); do
  if [ "${test:$(( ${#test} - 1 ))" == "/" ]; then 
    if [ ! -d ${file} ]; then
      echo "Directory missing: ${file}"
    fi
  else
    if [ ! -f ${file} ]; then
      echo "File missing: ${file}"
    fi
  fi
done

might work to check for missing files, but i've got no way to test this as i'm not at home... Maybe someone else can spot some problems?

it should work like this:

# paccheck [packagename]

Untested...

[edit]: pacman -Ql instead of -QL
[edit2]: take 2nd field of output from pacman -Ql.

Last edited by klixon (2007-06-18 10:55:13)


Stand back, intruder, or i'll blast you out of space! I am Klixon and I don't want any dealings with you human lifeforms. I'm a cyborg!

Offline

#3 2007-06-18 07:24:09

chaosgeisterchen
Member
From: Kefermarkt, Upper Austria
Registered: 2006-11-20
Posts: 550

Re: check installed packages integrity? [Solved - script inside]

Have you coded these lines right now?


celestary
Intel Core2Duo E6300 @ 1.86 GHz
kernel26
KDEmod current repository

Offline

#4 2007-06-18 07:30:21

drakosha
Member
Registered: 2006-01-03
Posts: 253
Website

Re: check installed packages integrity? [Solved - script inside]

nice idea smile

Offline

#5 2007-06-18 10:18:01

klixon
Member
From: Nederland
Registered: 2007-01-17
Posts: 525

Re: check installed packages integrity? [Solved - script inside]

chaosgeisterchen wrote:

Have you coded these lines right now?

yep

Last edited by klixon (2007-06-18 10:18:37)


Stand back, intruder, or i'll blast you out of space! I am Klixon and I don't want any dealings with you human lifeforms. I'm a cyborg!

Offline

#6 2007-06-18 10:45:11

drakosha
Member
Registered: 2006-01-03
Posts: 253
Website

Re: check installed packages integrity? [Solved - script inside]

i'm not a bash wizard, so i used awk, this looks to be working:

#!/bin/bash

PACKAGE=$1

for file in $( pacman -Ql ${PACKAGE} | awk '{print $2}'); do
      if [ "${test:$(( ${#test} - 1 ))}" == "/" ]; then
              if [ ! -d ${file} ]; then
                        echo "Directory missing: ${file}"
              fi
      else
              if [ ! -f ${file} ]; then
                        echo "File missing: ${file}"
              fi
      fi
done

Offline

#7 2007-06-18 10:46:46

drakosha
Member
Registered: 2006-01-03
Posts: 253
Website

Re: check installed packages integrity? [Solved - script inside]

...and this will check all installed packages:

for p in `pacman -Q | awk '{print $1}'`; do bash paccheck.bash $p; done

Offline

#8 2007-06-18 10:52:55

klixon
Member
From: Nederland
Registered: 2007-01-17
Posts: 525

Re: check installed packages integrity? [Solved - script inside]

dang... you're right... fix in original script...

i had no connection to home, so i checked the filelists at the arch-homepage... roll

does pacman -Ql ever output directory-entries? Or is it only filenames?
If it's only filenames, we could make the script a bit simpler

Last edited by klixon (2007-06-18 11:00:08)


Stand back, intruder, or i'll blast you out of space! I am Klixon and I don't want any dealings with you human lifeforms. I'm a cyborg!

Offline

#9 2007-06-18 11:02:30

drakosha
Member
Registered: 2006-01-03
Posts: 253
Website

Re: check installed packages integrity? [Solved - script inside]

looks like only files...

Offline

#10 2007-06-18 11:23:30

shining
Pacman Developer
Registered: 2006-05-10
Posts: 2,043

Re: check installed packages integrity? [Solved - script inside]

klixon wrote:

does pacman -Ql ever output directory-entries? Or is it only filenames?

I'm wondering the same, see the beginning of my comment there:
http://bbs.archlinux.org/viewtopic.php? … 87#p258887

Last edited by shining (2007-06-18 11:24:40)


pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))

Offline

#11 2007-06-18 11:32:50

klixon
Member
From: Nederland
Registered: 2007-01-17
Posts: 525

Re: check installed packages integrity? [Solved - script inside]

I guess it uses a directory name for empty directories that are required, so the [ ! -d ] check is still valid...

I'm glad i'm doing the opposite of what you're trying to do... That looks a bit more hairy.

Last edited by klixon (2007-06-18 11:46:02)


Stand back, intruder, or i'll blast you out of space! I am Klixon and I don't want any dealings with you human lifeforms. I'm a cyborg!

Offline

#12 2007-06-18 13:14:19

shining
Pacman Developer
Registered: 2006-05-10
Posts: 2,043

Re: check installed packages integrity? [Solved - script inside]

klixon wrote:

I guess it uses a directory name for empty directories that are required, so the [ ! -d ] check is still valid...

Oh no, finally it's a little bug in pacman (src/pacman/package.c)

225     if(!stat(path, &buf) && S_ISDIR(buf.st_mode)) {
226       /* if we stat it and it is a dir, don't print */
227     } else {
228       fprintf(stdout, "%s %s\n", pkgname, path);
229     }

If a directory doesn't exist, or is only readable by root, it can't stat it and detect it's a directory, so it'll print it smile
As root, the only directory it prints is the one which doesn't exist, ie /tmp/ttf-ms-fonts/
because of the special status of the ttf-ms-fonts package.
And as user, it also prints /var/spool/cups/tmp/ , because it doesn't have the right to stat it I guess.


I'm glad i'm doing the opposite of what you're trying to do... That looks a bit more hairy.

lol indeed, that's why I gave up smile


pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))

Offline

#13 2007-06-18 13:36:51

byte
Member
From: Düsseldorf (DE)
Registered: 2006-05-01
Posts: 2,046

Re: check installed packages integrity? [Solved - script inside]


1000

Offline

Board footer

Powered by FluxBB