Anthony E. Caudel wrote:
Help! I inadvertantly deleted my /var/db/pkg directory (and indeed my
entire /var (Don't ask!)).  Is there ANY way to regenerate it or am I
SOL?

The system still works, just not emerge.  If necessary I can rebuild and
migrate the apps but I'm hopeing...

Tony

If you have FEATURES="buildpkg" then it is possible to recover all of the /var/db/pkg 
data from the tbz2 files.  Attached is a "quick and dirty" little script to do that.  
This dumps everything, including multiple versions of the same package if they exist.

Zac
#!/usr/bin/env python

import os, sys

sys.path = ["/usr/lib/portage/pym"]+sys.path
import xpak

if __name__ == "__main__":
	if len(sys.argv)!=3:
		sys.stderr.write("usage: %s <tbz2 dir> <output dir>" % sys.argv[0]+"\n")
		sys.exit(1)
	tbz2_dir=sys.argv[1]
	output_dir=sys.argv[2]
	tb2_list=os.listdir(tbz2_dir)
	for tbz2_file in tb2_list:
		tbz2=xpak.tbz2(os.path.join(tbz2_dir,tbz2_file))
		pkg_dir=os.path.join(output_dir,tbz2.getfile("CATEGORY"),tbz2.getfile("PF"))
		os.makedirs(pkg_dir)
		for name in tbz2.filelist():
			f=file(os.path.join(pkg_dir,name),"w")
			f.write(tbz2.getfile(name))
			f.close()

Reply via email to