View previous topic :: View next topic |
Author |
Message |
brain Apprentice


Joined: 16 May 2002 Posts: 229 Location: Farmington Hills, MI
|
Posted: Fri Apr 16, 2004 5:20 pm Post subject: Rebuilding /var/db/pkg |
|
|
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 |
|
 |
Halcy0n Developer


Joined: 17 Sep 2003 Posts: 1682 Location: Freehold, NJ
|
Posted: Fri Apr 16, 2004 8:41 pm Post subject: |
|
|
regenworld didn't do what you needed? _________________ Mark Loeser
http://www.halcy0n.com |
|
Back to top |
|
 |
tomk Bodhisattva


Joined: 23 Sep 2003 Posts: 7221 Location: Sat in front of my computer
|
Posted: Sat Apr 17, 2004 3:43 pm Post subject: |
|
|
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 |
|
 |
Halcy0n Developer


Joined: 17 Sep 2003 Posts: 1682 Location: Freehold, NJ
|
Posted: Sat Apr 17, 2004 9:19 pm Post subject: |
|
|
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 |
|
 |
chugadie n00b

Joined: 19 Apr 2004 Posts: 17
|
Posted: Mon Apr 19, 2004 1:55 pm Post subject: |
|
|
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 |
|
 |
|