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

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
brain
Apprentice
Apprentice


Joined: 16 May 2002
Posts: 229
Location: Farmington Hills, MI

PostPosted: Fri Apr 16, 2004 5:20 pm    Post subject: Rebuilding /var/db/pkg Reply with quote

A PHP programming friend of mine accidentally deleted /var/db/pkg, and understandably was frustrated with the fact that there's no real set method of rebuilding the world database.

He whipped up this PHP script that will rebuild your world database. I have not personally used it yet, but he has and claims it works great. Use at your own risk :)

Code:

<?php
//Written by Mark Kimsal (markkimsal@quickenloans.com)

$dump = `find /var/tmp/portage/ -type d -maxdepth 1| grep -v temp | grep -v work | grep -v build-info | sed -e "s/\/var\/tmp\/portage\///g"`;

$files = explode("\n",trim($dump));
unset($dump);

$cnt_files = count($files);

for ($x =0; $x < $cnt_files; ++$x ) {

   //(ex zsh-4.1.1-r5)
   $filename = $files[$x];

   //get the version number (ex -4.1.1-r5)
   $flag = preg_match("/\-[0-9].*$/",$filename,$matches);
   $version = $matches[0];

   //get the packagename (ex zsh)
   $packagename = substr(
         $filename, 0, strpos($filename,$version)
         );
   //find the portage category (ex app-shells)
   $find =  `find /usr/portage/ -type d -maxdepth 2 -name '$packagename'`;
   //chop off characters in "/usr/portage/" (13)
   $categoryname = trim(substr( $find, 13 ));


   print $packagename ."\n";
   print $version ."\n";

   print $categoryname . $version ."\n\n";
   $completepackage = $categoryname.$version;

   echo "emerge inject $completepackage\n\n\n";
   `emerge inject $completepackage`;
}

?>

_________________
--brain
Back to top
View user's profile Send private message
Halcy0n
Developer
Developer


Joined: 17 Sep 2003
Posts: 1682
Location: Freehold, NJ

PostPosted: Fri Apr 16, 2004 8:41 pm    Post subject: Reply with quote

regenworld didn't do what you needed?
_________________
Mark Loeser
http://www.halcy0n.com
Back to top
View user's profile Send private message
tomk
Bodhisattva
Bodhisattva


Joined: 23 Sep 2003
Posts: 7221
Location: Sat in front of my computer

PostPosted: Sat Apr 17, 2004 3:43 pm    Post subject: Reply with quote

This script is different from regenworld. What this does is have a look in /var/tmp/portage to find out which packages have been emerged and then emerge injects them. The main problem is that many people delete the contents of /var/tmp/portage when they get low on disk space.

Regenworld rebuilds your world file using your emerge log.
_________________
Search | Read | Answer | Report | Strip
Back to top
View user's profile Send private message
Halcy0n
Developer
Developer


Joined: 17 Sep 2003
Posts: 1682
Location: Freehold, NJ

PostPosted: Sat Apr 17, 2004 9:19 pm    Post subject: Reply with quote

Yea, I understand its alittle different, I was just curious if it didn't do exactly what he wanted, or if he didn't know about it :)
_________________
Mark Loeser
http://www.halcy0n.com
Back to top
View user's profile Send private message
chugadie
n00b
n00b


Joined: 19 Apr 2004
Posts: 17

PostPosted: Mon Apr 19, 2004 1:55 pm    Post subject: Reply with quote

HaLCy0n wrote:
Yea, I understand its alittle different, I was just curious if it didn't do exactly what he wanted, or if he didn't know about it :)


I didn't know about it. I did some searching on rebuilding the portage list and didn't find any mention of regenworld. This script is really only usefull if you are trying to free up disk space and you remove /var/db/pkg instead of /var/tmp/portage.

Why does something so critical to the system not have the words gentoo / portage in the directory? I though /var/db/pkg was just the sandbox or something.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks 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