Makefile: Re-join man page generation
[catalyst.git] / modules / generic_stage_target.py
index 92ec3817ace937e62435a5f45ece6f732d8c7851..c4ef239c17bb489f16d827332a8e64f7f5dd25cd 100644 (file)
@@ -1,9 +1,3 @@
-
-"""
-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 *
@@ -11,7 +5,10 @@ from stat 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"])
@@ -813,11 +810,12 @@ class generic_stage_target(generic_target):
                        # 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")
 
@@ -829,10 +827,8 @@ class generic_stage_target(generic_target):
                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")
 
@@ -937,7 +933,7 @@ class generic_stage_target(generic_target):
 
        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()
@@ -949,7 +945,7 @@ class generic_stage_target(generic_target):
                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)
@@ -972,18 +968,6 @@ class generic_stage_target(generic_target):
                                        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
@@ -996,16 +980,19 @@ class generic_stage_target(generic_target):
                                        "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')
 
@@ -1042,9 +1029,9 @@ class generic_stage_target(generic_target):
                                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):
@@ -1089,7 +1076,7 @@ class generic_stage_target(generic_target):
                        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 """
@@ -1246,6 +1233,10 @@ class generic_stage_target(generic_target):
                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
@@ -1638,15 +1629,16 @@ class generic_stage_target(generic_target):
 
        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()