Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Restoring /var/db/pkg?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
G-LiTe`
Tux's lil' helper
Tux's lil' helper


Joined: 06 May 2003
Posts: 147

PostPosted: Mon Jun 02, 2003 2:46 pm    Post subject: Restoring /var/db/pkg? Reply with quote

So I did and emerge sync today, however it crashed during fixpackages. (lost the traceback) So I wiped /usr/portage/packages (knowing it wouldn't do harm) and tried again in vain. It mentioned /var/db/pkg in there so I thought, what the hell, wipe that too. (great idea, huh? stupid me didn't know what the consequences were. :( )
So now portage thinks there's absolutely no packages installed... And I don't really feel like recompiling X, gnome, kde, firebird, etc.
Is there anyway to regenerate /var/db/pkg or maybe some other fix? I know I'm stupid but please help me. :oops:
Back to top
View user's profile Send private message
dberkholz
Retired Dev
Retired Dev


Joined: 18 Mar 2003
Posts: 1008
Location: Minneapolis, MN, USA

PostPosted: Mon Jun 02, 2003 10:45 pm    Post subject: Reply with quote

Edit: Cyfred has a script. See below.
I asked a few people in #gentoo, and all we came up with was recompiling everything with 'emerge -e world'.


Last edited by dberkholz on Tue Jun 03, 2003 10:00 pm; edited 1 time in total
Back to top
View user's profile Send private message
Pythonhead
Developer
Developer


Joined: 16 Dec 2002
Posts: 1801
Location: Redondo Beach, Republic of Calif.

PostPosted: Mon Jun 02, 2003 11:05 pm    Post subject: Reply with quote



Last edited by Pythonhead on Tue Nov 16, 2004 7:09 pm; edited 1 time in total
Back to top
View user's profile Send private message
cyfred
Retired Dev
Retired Dev


Joined: 23 Aug 2002
Posts: 596

PostPosted: Mon Jun 02, 2003 11:40 pm    Post subject: Reply with quote

Give me a few hours and I can make up a script for this. I did have one half done just now but then I realised that qpkg and emerge are not going to reflect the current state of your system. So there are a few more fancier tricks that need to be applied.

Note using the script that im _trying_ to write isnt totally recommended as it will not restore everything -- some packages never get mentioned. So you will need to probably emerge -e some packages.
Back to top
View user's profile Send private message
cyfred
Retired Dev
Retired Dev


Joined: 23 Aug 2002
Posts: 596

PostPosted: Tue Jun 03, 2003 4:57 am    Post subject: Reply with quote

OK here is the script.

Please note that this is a bit of a hack way of doing things and will result in "orphaned" files as spyderous put it too me on #gentoo. This script is functional and should restore all of your packages but will probably miss one or two somewhere, if you get a complaint later then just re-emerge that package that was missed.

Please read the comments at the end of the process, in summary
1) Run regenworld
2) Run emerge -up world

http://www.volutin.net/~andrew/GENTOO/tools/regenpkgdb -- changed host use below
EDIT http://www.volutin.net/andrew/GENTOO/tools/regenpkgdb


This is a bash script so you will need to chmod +x it to execute it.
Download and save this script to /root and then
cd /root
chmod 700 regenpkgdb
./regenpkgdb

The script should take half a minute (roughly) on a 2Ghz machine.


Last edited by cyfred on Tue Jul 01, 2003 8:06 am; edited 1 time in total
Back to top
View user's profile Send private message
dberkholz
Retired Dev
Retired Dev


Joined: 18 Mar 2003
Posts: 1008
Location: Minneapolis, MN, USA

PostPosted: Tue Jun 03, 2003 5:43 am    Post subject: Reply with quote

So to regenerate the pkg db in a more "real" way, perhaps we should try fooling portage into thinking it's compiled (and downloaded if possible), then getting it to add itself to /var/db/pkg. Using ebuild instead of emerge is a possibility.
man ebuild /qmerge wrote:
This function installs all the files in the install directory to the live filesystem. The process works as follows: first, the pkg_preinst() function (if specified) is run. Then, the files are merged into the live filesystem, and the installed files' md5 digests are recorded in /var/db/pkg/${CATEGORY}/${PN}-[version-rev]/CONTENTS. After all the files have been merged, the pkg_postinst() function (if specified) is executed.

Seems like this may be the right idea, since it at least does something involving /var/db/pkg.
Cyfred and I discussed this on #gentoo, but I'm trying to keep a record somewhere.
Back to top
View user's profile Send private message
G-LiTe`
Tux's lil' helper
Tux's lil' helper


Joined: 06 May 2003
Posts: 147

PostPosted: Tue Jun 03, 2003 11:35 am    Post subject: Reply with quote

cyfred wrote:
OK here is the script.

Please note that this is a bit of a hack way of doing things and will result in "orphaned" files as spyderous put it too me on #gentoo. This script is functional and should restore all of your packages but will probably miss one or two somewhere, if you get a complaint later then just re-emerge that package that was missed.

Please read the comments at the end of the process, in summary
1) Run regenworld
2) Run emerge -up world

http://www.volutin.net/~andrew/GENTOO/tools/regenpkgdb

This is a bash script so you will need to chmod +x it to execute it.
Download and save this script to /root and then
cd /root
chmod 700 regenpkgdb
./regenpkgdb

The script should take half a minute (roughly) on a 2Ghz machine.


Thx. :) It seems that worked almost perfectly. Though it, ofcourse, injected the wrong version of certain packages. (There were certain packages portage tried to downgrade before, because I was using a masked or beta version, such as galeon 1.3. I expected this to happen though.)

Maybe you can use the /usr/share/docs directory to get the version of certain packages? I wouldn't know if it's possible to do this in bash though. If for example you're trying to inject pam, you can't just find look for a documentation directory called "pam-*" because it might trigger on "pam-login-*" too. I know only the basics of shell scripting though. Does bash have a wildcard that only triggers on numbers? If so you could use that.

Also, "emerge -up --deep world" might be a better idea. :)
And it took less than a minute here. ;)
Anyways, thx a million times, Portage will probably fix the small problems left in time. I'm just glad I don't have to recompile everything right now. :)
Back to top
View user's profile Send private message
G-LiTe`
Tux's lil' helper
Tux's lil' helper


Joined: 06 May 2003
Posts: 147

PostPosted: Tue Jun 03, 2003 11:42 am    Post subject: Reply with quote

Hmmm... some more things. When I tried to merge a package, it gave a whole bunch of the following:

Code:
portage: COUNTER for app-admin/gentoolkit-0.1.25 was corrupted; resetting to value of 0
portage: COUNTER for app-arch/unzip-5.50-r1 was corrupted; resetting to value of 0
.......


It also seems neither gnome nor kde are in my world profile though I both upgraded/reinstalled them and even seperate packages several times. So it still tries to recompile those. (And that's a whole lot of packages)
Back to top
View user's profile Send private message
dberkholz
Retired Dev
Retired Dev


Joined: 18 Mar 2003
Posts: 1008
Location: Minneapolis, MN, USA

PostPosted: Tue Jun 03, 2003 3:08 pm    Post subject: Reply with quote

G-LiTe` wrote:
It also seems neither gnome nor kde are in my world profile though I both upgraded/reinstalled them and even seperate packages several times. So it still tries to recompile those. (And that's a whole lot of packages)

They aren't "real" packages, they're groupings of other packages, and cause all of the kde (or gnome) stuff to be emerged. How to deal with that? Guess for gnome and kde, we'd have to check if all of the parts are emerged, then say that gnome is emerged if all parts of gnome are emerged, same w/ kde. I'm not sure if any other "packages" are set up like that. Your solution would be to either bug Cyfred about it, or take a look at the script he already gave you, and touch the appropriate files in /var/db/pkg/kde-base/kde-3.1.2 (or other version), and the same with gnome (presumably in /var/db/pkg/gnome-base/gnome-version, but I'm not sure since I don't use it).

Perhaps the whole virtual thing also needs to be taken into consideration via /var/cache/edb/virtuals in some way. That could be of assistance, but I'm not sure how yet.
Back to top
View user's profile Send private message
cyfred
Retired Dev
Retired Dev


Joined: 23 Aug 2002
Posts: 596

PostPosted: Wed Jun 04, 2003 10:44 am    Post subject: Reply with quote

G-Lite the issue with the COUNTER errors is because I didnt have the script actually place values into the files under /var/db/pkg/*/*/XYZ -- That can sortof be ignored, but noted so that maybe can be fixed later.

You should note that what happens here is technically not an injection.
Injected packages do NOT get upgraded, this method though will gauruntee that your packages get upgraded.

KDE (or GNOME) probably need to have the respective /var/db/pkg entry created manually, provided that you already have all of the packages listed by emerge kde installed. This is something that I overlooked in the script, actually it didnt occur to me because my dev machine only has kdebase/libs installed.

Will look at that in the future...
Back to top
View user's profile Send private message
cyfred
Retired Dev
Retired Dev


Joined: 23 Aug 2002
Posts: 596

PostPosted: Tue Jul 01, 2003 11:37 am    Post subject: Reply with quote

Wether or not this is still a relevent feature may yet to be seen, but I have just resumed working on this project. The script is now based in python, thanks very muchly to rvdp for porting the above efforts.

The next script will be complete as I can get it, and should restore not only your portage tree database but the files that make up the package information.

The main problem Im having is actually how to establish a list of all the files that a package owns (aka /var/db/pkg/*/*/CONTENTS), which is normally listed by
Code:
qpkg -l <pkg_name>


If anyone has some brilliant ideas on this please drop us a line. :D
Back to top
View user's profile Send private message
G-LiTe`
Tux's lil' helper
Tux's lil' helper


Joined: 06 May 2003
Posts: 147

PostPosted: Tue Jul 01, 2003 11:41 am    Post subject: Reply with quote

The only way to do that afaik is to check the contents of the package in /usr/portage/packages.
If the package is deleted however, you're screwed. :D
Back to top
View user's profile Send private message
ecatmur
Advocate
Advocate


Joined: 20 Oct 2003
Posts: 3595
Location: Edinburgh

PostPosted: Mon May 03, 2004 2:14 am    Post subject: Reply with quote

I think that probably the best way to get an idea of CONTENTS is by timestamp.

I have written a small script that does something similar - given an orphaned file, it guesses which package it belongs to by checking the portage log to create a set of intervals and checking to see which interval the mtime of the file falls under. It's a little slow (2 seconds) with just one file but most of that time is spent loading Python, importing portage.py and parsing the logfile, it scales well with multiple files.

You can get it under the GPL 2 from http://catmur.co.uk/my-bin/cruft-blame.py - it should be simple to adjust it to find owners for the full filesystem (well, avoiding the non--Portage-managed parts).
_________________
No more cruft
dep: Revdeps that work
Using command-line ACCEPT_KEYWORDS?
Back to top
View user's profile Send private message
torres
n00b
n00b


Joined: 10 Aug 2004
Posts: 24
Location: burgos

PostPosted: Tue Nov 16, 2004 6:19 pm    Post subject: Reply with quote

Quote:

http://www.volutin.net/~andrew/GENTOO/tools/regenpkgdb -- changed host use below
EDIT http://www.volutin.net/andrew/GENTOO/tools/regenpkgdb


sorry but i am not able to download any of those to files. Could you please repair them? thanks
_________________
born to run linux
Back to top
View user's profile Send private message
dberkholz
Retired Dev
Retired Dev


Joined: 18 Mar 2003
Posts: 1008
Location: Minneapolis, MN, USA

PostPosted: Tue Nov 16, 2004 6:21 pm    Post subject: Reply with quote

torres wrote:
Quote:

http://www.volutin.net/~andrew/GENTOO/tools/regenpkgdb -- changed host use below
EDIT http://www.volutin.net/andrew/GENTOO/tools/regenpkgdb


sorry but i am not able to download any of those to files. Could you please repair them? thanks

http://dev.gentoo.org/~spyderous/scripts/regenpkgdb
Back to top
View user's profile Send private message
defenderBG
l33t
l33t


Joined: 20 Jun 2006
Posts: 817

PostPosted: Mon Dec 18, 2006 8:38 pm    Post subject: Reply with quote

dberkholz wrote:
http://dev.gentoo.org/~spyderous/scripts/regenpkgdb


The link is dead, can u pls repost it, tnx :)
Back to top
View user's profile Send private message
dberkholz
Retired Dev
Retired Dev


Joined: 18 Mar 2003
Posts: 1008
Location: Minneapolis, MN, USA

PostPosted: Mon Dec 18, 2006 8:51 pm    Post subject: Reply with quote

defenderBG wrote:
dberkholz wrote:
http://dev.gentoo.org/~spyderous/scripts/regenpkgdb


The link is dead, can u pls repost it, tnx :)

http://dev.gentoo.org/~dberkholz/scripts/regenpkgdb
Back to top
View user's profile Send private message
defenderBG
l33t
l33t


Joined: 20 Jun 2006
Posts: 817

PostPosted: Tue Dec 19, 2006 4:01 am    Post subject: Reply with quote

tnx, now I have to emerge only 80 packages.... meaning ~220 spared :)
Back to top
View user's profile Send private message
fuzzythebear
Guru
Guru


Joined: 28 Nov 2004
Posts: 317

PostPosted: Thu Dec 28, 2006 6:50 pm    Post subject: Reply with quote

tried regenpkgdb and regenworld and both failed
to give adequate results .. ideas ?
is there another way , even if it's a pain , to regen that
database even on a one by one package basis ?
note : the /var/log/emerge.log is complete since june this year
and covers all this installations from a to z ..
_________________
There's this once i thought i had made a mistake .. but i was wrong :|
Back to top
View user's profile Send private message
hielvc
Advocate
Advocate


Joined: 19 Apr 2002
Posts: 2805
Location: Oceanside, Ca

PostPosted: Fri Dec 29, 2006 6:53 pm    Post subject: Reply with quote

I wrote a script that can regen most of /var/db/pkg.The prob with it is if you had 2 pkg's with the same name but are in different categories youll only get one of them.

You can put a date string in to use emerge.log from such and such a date, hint the last time you did an emerge world -e. deleted /var/db/pkg [solved]

After running the script run dep -dp to see if there is anything you need to add.
_________________
An A-Z Index of the Linux BASH command line
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum