You are not logged in.
On one of my Arch machines I seemed to have lost something for Pacman as 'Pacman -Q' gives absolutely no results.
I've searched on both the forum & the wiki but I guess I'm too stupid to get the right search term to come up with anything. I still have the packages in /var/cache/pacman/pkg and a lot in /var/lib/pacman, so I don't know what it is I lost.
Any ideas guys?
Offline
Your local database of installed packages is in /var/lib/pacman/local - if you've lost that, you have a bit of a headache to sort out.
Because you're not the first person to do this(!), there have been various threads on the subject over the years - have a browse/search around here for various possible solutions. Essentially, you need to determine the names of your installed packages from the files currently installed, and then reinstall them.
Offline
I wonder if I can just take the packagename from the files in /var/cache/pacman/pkg and just reinstall all of them?
Offline
Even if you have never cleared your cache (pacman -Sc/Scc), you'd still be missing the packages from the installation. /var/log/pacman.log is your best bet.
1000
Offline
Thanks, byte for that info. What I did was create:
#!/bin/bash
#
SEDEXP='s/^\[[^ ]* *[0-9][0-9]:[0-9][0-9]\] \([^ ]*\) *\([^ ]*\) .*/\1 \2/'
GRPEXP='(upgraded)|(installed)'
AWKEXP='{print $2}'
#
sed -e "$SEDEXP" /var/log/pacman.log | grep -E "$GRPEXP" | awk "$AWKEXP" | sort -u
# End
This gave me a list of some 272 packages, which (except for half a dozen errors) was the same list that I came up with from the /var/cache/pacman/pkg files list. However, the script above when used on /var/log/pacman.log made fewer mistakes than when I tried it by hand.
Thanks again.
Offline
An improvement on rdt's script. This assumes (as did his) that package names do not have spaces in them.
It has the advantages of:
- replace 4 calls in a pipe with 1 call
- does not report packages that were removed since being installed
- is hopefully easier to read
- checks the correct column for 'upgraded' or 'installed' and not the entire line, ie will not report a line that says something along the lines of "warning: we upgraded your rc file"
awk '
$3 == "installed" || $3 == "upgraded" { pkg[$4] = 1 }
$3 == "removed" { pkg[$4] = 0 }
END { for (i in pkg) if ( pkg[i] == 1 ) print i; }
' /var/log/pacman.log
Offline
I did a minor change to the above scripts, because I only want to reinstall the packages that was lost from the database. Might be interestng if you have lots of packages and only a few of them are broken, take a look at
http://bbs.archlinux.org/viewtopic.php? … 34#p616234.
Offline