-
-"""
-This class does all of the chroot setup, copying of files, etc. It is
-the driver class for pretty much everything that Catalyst does.
-"""
-
import os,string,imp,types,shutil
from catalyst_support import *
from generic_target import *
import catalyst_lock
class generic_stage_target(generic_target):
-
+ """
+ This class does all of the chroot setup, copying of files, etc. It is
+ the driver class for pretty much everything that Catalyst does.
+ """
def __init__(self,myspec,addlargs):
self.required_values.extend(["version_stamp","target","subarch",\
"rel_type","profile","snapshot","source_subpath"])
# TODO: zmedico and I discussed making this a directory and pushing
# in a parent file, as well as other user-specified configuration.
print "Configuring profile link..."
- cmd("rm -f "+self.settings["chroot_path"]+"/etc/make.profile",\
+ cmd("rm -f "+self.settings["chroot_path"]+"/etc/portage/make.profile",\
"Error zapping profile link",env=self.env)
- cmd("ln -sf ../usr/portage/profiles/"+\
+ cmd("mkdir -p "+self.settings["chroot_path"]+"/etc/portage/")
+ cmd("ln -sf ../../usr/portage/profiles/"+\
self.settings["target_profile"]+" "+\
- self.settings["chroot_path"]+"/etc/make.profile",\
+ self.settings["chroot_path"]+"/etc/portage/make.profile",\
"Error creating profile link",env=self.env)
touch(self.settings["autoresume_path"]+"config_profile_link")
else:
if self.settings.has_key("portage_confdir"):
print "Configuring /etc/portage..."
- cmd("rm -rf "+self.settings["chroot_path"]+"/etc/portage",\
- "Error zapping /etc/portage",env=self.env)
- cmd("cp -R "+self.settings["portage_confdir"]+"/ "+\
- self.settings["chroot_path"]+"/etc/portage",\
+ cmd("rsync -a "+self.settings["portage_confdir"]+"/ "+\
+ self.settings["chroot_path"]+"/etc/portage/",\
"Error copying /etc/portage",env=self.env)
touch(self.settings["autoresume_path"]+"setup_confdir")
def chroot_setup(self):
self.makeconf=read_makeconf(self.settings["chroot_path"]+\
- "/etc/make.conf")
+ "/etc/portage/make.conf")
self.override_cbuild()
self.override_chost()
self.override_cflags()
else:
print "Setting up chroot..."
- #self.makeconf=read_makeconf(self.settings["chroot_path"]+"/etc/make.conf")
+ #self.makeconf=read_makeconf(self.settings["chroot_path"]+"/etc/portage/make.conf")
cmd("cp /etc/resolv.conf "+self.settings["chroot_path"]+"/etc",\
"Could not copy resolv.conf into place.",env=self.env)
self.settings["chroot_path"]+"/tmp/envscript",\
"Could not copy envscript into place.",env=self.env)
- """ Setup metadata_overlay """
- if self.settings.has_key("METADATA_OVERLAY") \
- and not self.settings.has_key("portage_confdir"):
- if not os.path.exists(self.settings["chroot_path"]+\
- "/etc/portage"):
- cmd("mkdir "+self.settings["chroot_path"]+"/etc/portage")
- myf=open(self.settings["chroot_path"]+\
- "/etc/portage/modules","a")
- myf.write("portdbapi.auxdbmodule = cache.metadata_overlay.database\n")
- myf.close()
-
-
"""
Copy over /etc/hosts from the host in case there are any
specialties in there
"Could not copy /etc/hosts",env=self.env)
""" Modify and write out make.conf (for the chroot) """
- cmd("rm -f "+self.settings["chroot_path"]+"/etc/make.conf",\
+ cmd("rm -f "+self.settings["chroot_path"]+"/etc/portage/make.conf",\
"Could not remove "+self.settings["chroot_path"]+\
- "/etc/make.conf",env=self.env)
- myf=open(self.settings["chroot_path"]+"/etc/make.conf","w")
+ "/etc/portage/make.conf",env=self.env)
+ myf=open(self.settings["chroot_path"]+"/etc/portage/make.conf","w")
myf.write("# These settings were set by the catalyst build script that automatically\n# built this stage.\n")
myf.write("# Please consult /usr/share/portage/config/make.conf.example for a more\n# detailed example.\n")
if self.settings.has_key("CFLAGS"):
myf.write('CFLAGS="'+self.settings["CFLAGS"]+'"\n')
if self.settings.has_key("CXXFLAGS"):
- myf.write('CXXFLAGS="'+self.settings["CXXFLAGS"]+'"\n')
+ if self.settings["CXXFLAGS"]!=self.settings["CFLAGS"]:
+ myf.write('CXXFLAGS="'+self.settings["CXXFLAGS"]+'"\n')
+ else:
+ myf.write('CXXFLAGS="${CFLAGS}"\n')
else:
myf.write('CXXFLAGS="${CFLAGS}"\n')
myf.write('PORTDIR_OVERLAY="/usr/local/portage"\n')
myf.close()
- cmd("cp "+self.settings["chroot_path"]+"/etc/make.conf "+\
- self.settings["chroot_path"]+"/etc/make.conf.catalyst",\
- "Could not backup /etc/make.conf",env=self.env)
+ cmd("cp "+self.settings["chroot_path"]+"/etc/portage/make.conf "+\
+ self.settings["chroot_path"]+"/etc/portage/make.conf.catalyst",\
+ "Could not backup /etc/portage/make.conf",env=self.env)
touch(self.settings["autoresume_path"]+"chroot_setup")
def fsscript(self):
cmd("rm -rf "+self.settings["chroot_path"]+"/usr/local/portage",\
"Could not remove /usr/local/portage",env=self.env)
cmd("sed -i '/^PORTDIR_OVERLAY/d' "+self.settings["chroot_path"]+\
- "/etc/make.conf",\
+ "/etc/portage/make.conf",\
"Could not remove PORTDIR_OVERLAY from make.conf",env=self.env)
""" Clean up old and obsoleted files in /etc """
if self.settings.has_key("CLEAR_AUTORESUME"):
self.clear_autoresume()
+ if self.settings.has_key("PURGETMPONLY"):
+ self.purge()
+ return
+
if self.settings.has_key("PURGEONLY"):
self.purge()
return
def purge(self):
countdown(10,"Purging Caches ...")
- if self.settings.has_key("PURGE") or self.settings.has_key("PURGEONLY"):
+ if self.settings.has_key("PURGE") or self.settings.has_key("PURGEONLY") or self.settings.has_key("PURGETMPONLY"):
print "clearing autoresume ..."
self.clear_autoresume()
print "clearing chroot ..."
self.clear_chroot()
- print "clearing package cache ..."
- self.clear_packages()
+ if not self.settings.has_key("PURGETMPONLY"):
+ print "clearing package cache ..."
+ self.clear_packages()
print "clearing kerncache ..."
self.clear_kerncache()