You are not logged in.

#1 2016-02-04 22:49:38

Markus.N2
Member
From: Germany
Registered: 2013-08-22
Posts: 99

How can I restore my database of installed packages ?

Hi,

I had some harddisk problems and needed to migrate my system to a new disk. The old disk was partially unreadable, but not totally. I had two (identical) systems on it. One for production and one for test. The test partition was rarely used and so it had apparently no defective sectors and I could rsync it to the new disk, without i/o errors reported. The system boots successfully from the new disk now. I thought everything was fine, until I tried to upgrade my packages.

pacman -Syu

upgrades the databses and then does nothing.

pacman -Qe

shows an empty list.

And indeed, /var/lib/pacman/local is empty. I don't know how it got lost. As I said, there were no i/o errors reported durig rsync. On the production partition and the data partition I had lots of them, so I know that rsync reports i/o errors with the parameters I used.

Unfortunately, the relevant chapter in Pacman/Tips and tricks is marked as "Out of Date", but the discussion page does not contain this topic. The article mentions a script called "pacrecover". Where can I get it ? Then I could try to follow the old procedure.

Thanks and Regards,
Markus

Offline

#2 2016-02-05 09:34:37

a821
Member
Registered: 2012-10-31
Posts: 381

Re: How can I restore my database of installed packages ?

The section is marked out of date because "testdb" was deprecated https://projects.archlinux.org/pacman.g … S?h=v5.0.0

- pacman can check the validity of the local and sync databases (-Dk and -Dkk respectively).  This replaces the 'testdb' software (FS#42444)

I don't know how to get the script "pacrestore" and I tried Xyne's script and doesn't work (it seems out of date), but it shouldn't be too difficult to fix it if you know perl.

what about something like this?

awk '/\[ALPM\] installed / { print $5 }' /var/log/pacman.log | sort -u

Note that you need pacman's log. If your installation it's not too old it should work. There were some changes in the format of pacman's log few years ago, so it might not work if this is the case...

Offline

#3 2016-02-05 11:03:45

Markus.N2
Member
From: Germany
Registered: 2013-08-22
Posts: 99

Re: How can I restore my database of installed packages ?

Fortunately, I have pacman's log.
Your command only covers the first part of the wiki article (the one before pacrestore). I'm currently sitting at work. Herre I have also an Arch Linux PC, but wiht a healthy pacman database. And when I look at /var/lib/pacman/local/, I see a directory for every package with three or four files: desc, files, install, mtree (install only in some). This is missing on my PC at home and must be rebuilt.
Your command creates the list, but I need something that uses this list as input for recreating these directories. I think that's what "pacrestore" was good for.

I'll continue tomorrow, I have some appointements for the rest of the day.

Offline

#4 2016-02-05 13:32:56

a821
Member
Registered: 2012-10-31
Posts: 381

Re: How can I restore my database of installed packages ?

My point was that you can get the list of installed packages to populate pacman's database. Look at the function recovery-pacman in the link you provided.

Also, I forgot to mention you can change "installed" by "removed" to refine your list. In my case, if get the list of installed packages from the log, then remove the "removed" packages, and finally compare this list with my actual packages, the script misses three packages, which I installed, removed and installed again. YMMV. Note that I have only 420 packages in that machine.

Yeah, it's not perfect but it is a starting point.

Offline

#5 2016-02-07 18:02:15

Markus.N2
Member
From: Germany
Registered: 2013-08-22
Posts: 99

Re: How can I restore my database of installed packages ?

Looks like a combination of Restore pacman's local database, Xyne's package detection script, and Identify files not owned by any package works. Although I thought my pacman log was complete and from the beginning, it seems it wasn't and a lot was missing.

The most promising way is to use the output of Xyne's script (only the 100% entries, the others will give false positives) and try to remember which packages were installed manually. Lots of packages will then come as dependencies, making the list shorter in the next round. I'm using the script this way:

./findpkgs.pl > findpkgs.log
for PKG in `cat findpkgs.log | fgrep '100%' | sed -e 's/ \+[0-9]\+%//'`; do if [ ! -d /var/lib/pacman/local/$PKG ]; then echo $PKG; fi; done
recovery-pacman -S [packages (without version numbers) chosen from the output of above]

Repeat the commands 2 and 3 until output is empty, and (important !) choose packages manually. It's possible, however, to change the sed expression in 2 to remove the version numbers and directly use the output of 2 for 3, but that's not a good idea.

At the end, check the files not owned by any package.
This is a step-by-step procedure and I won't finish it in one day.

Offline

Board footer

Powered by FluxBB