Fix the breakage of /lib on amd64 caused by tar replacing the symlink with a dir.
[catalyst.git] / catalyst
index e050987ed0250c8334094a742ba559dc5378d171..33e121fd115347720a05fb24d253cabe9d7b3798 100755 (executable)
--- a/catalyst
+++ b/catalyst
@@ -1,8 +1,11 @@
 #!/usr/bin/python -OO
 
 # Maintained in full by:
+# Catalyst Team <catalyst@gentoo.org>
+# Release Engineering Team <releng@gentoo.org>
 # Andrew Gaffney <agaffney@gentoo.org>
-# Chris Gianelloni <wolf31o2@gentoo.org>
+# Chris Gianelloni <wolf31o2@wolf31o2.org>
+# $Id$
 
 import os, sys, imp, string, getopt
 import pdb
@@ -15,8 +18,8 @@ sys.path.append(__selfpath__ + "/modules")
 import catalyst.config
 import catalyst.util
 
-__maintainer__="Chris Gianelloni <wolf31o2@gentoo.org>"
-__version__="2.99"
+__maintainer__="Catalyst <catalyst@gentoo.org>"
+__version__="2.0.11"
 
 conf_values={}
 
@@ -31,6 +34,7 @@ def usage():
        print " -h --help       print this help message"
        print " -p --purge      clear tmp dirs,package cache and autoresume flags"
        print " -P --purgeonly  clear tmp dirs,package cache and autoresume flags and exit"
+       print " -T --purgetmponly  clear tmp dirs and autoresume flags and exit"
        print " -s --snapshot   generate a release snapshot"
        print " -V --version    display version information"
        print " -v --verbose    verbose output"
@@ -49,7 +53,7 @@ def usage():
 def version():
        print "Catalyst, version "+__version__
        print "Copyright 2003-2008 Gentoo Foundation"
-       print "Copyright 2008 various authors"
+       print "Copyright 2008-2012 various authors"
        print "Distributed under the GNU General Public License version 2.1\n"
 
 def parse_config(myconfig):
@@ -148,10 +152,6 @@ def parse_config(myconfig):
                print "Snapshot cache support enabled."
                conf_values["SNAPCACHE"]="1"
 
-       if "metadata_overlay" in conf_values["options"].split():
-               print "Use of metadata_overlay module for portage enabled."
-               conf_values["METADATA_OVERLAY"]="1"
-
 #      if "tarball" in string.split(conf_values["options"]):
 #              print "Tarball creation enabled."
 #              conf_values["TARBALL"]="1"
@@ -167,9 +167,35 @@ def parse_config(myconfig):
 
 def import_modules():
        # import catalyst's own modules (i.e. catalyst_support and the arch modules)
-       import catalyst.target
+       targetmap={}
+
+       try:
+               for x in required_build_targets:
+                       try:
+                               fh=open(conf_values["sharedir"]+"/modules/"+x+".py")
+                               module=imp.load_module(x,fh,"modules/"+x+".py",(".py","r",imp.PY_SOURCE))
+                               fh.close()
+
+                       except IOError:
+                               raise CatalystError,"Can't find "+x+".py plugin in "+\
+                                       conf_values["sharedir"]+"/modules/"
+
+               for x in valid_build_targets:
+                       try:
+                               fh=open(conf_values["sharedir"]+"/modules/"+x+".py")
+                               module=imp.load_module(x,fh,"modules/"+x+".py",(".py","r",imp.PY_SOURCE))
+                               module.register(targetmap)
+                               fh.close()
+
+                       except IOError:
+                               raise CatalystError,"Can't find "+x+".py plugin in "+\
+                                       conf_values["sharedir"]+"/modules/"
+
+       except ImportError:
+               print "!!! catalyst: Python modules not found in "+\
+                       conf_values["sharedir"]+"/modules; exiting."
+               sys.exit(1)
 
-       targetmap = catalyst.target.build_target_map()
        return targetmap
 
 def build_target(addlargs, targetmap):
@@ -202,7 +228,7 @@ if __name__ == "__main__":
 
        # parse out the command line arguments
        try:
-               opts,args = getopt.getopt(sys.argv[1:], "apPhvdc:C:f:FVs:", ["purge", "purgeonly", "help", "version", "debug",\
+               opts,args = getopt.getopt(sys.argv[1:], "apPThvdc:C:f:FVs:", ["purge", "purgeonly", "purgetmponly", "help", "version", "debug",\
                        "clear-autoresume", "config=", "cli=", "file=", "fetch", "verbose","snapshot="])
        
        except getopt.GetoptError:
@@ -274,6 +300,9 @@ if __name__ == "__main__":
                if o in ("-P", "--purgeonly"):
                        conf_values["PURGEONLY"] = "1"
 
+               if o in ("-T", "--purgetmponly"):
+                       conf_values["PURGETMPONLY"] = "1"
+
                if o in ("-a", "--clear-autoresume"):
                        conf_values["CLEAR_AUTORESUME"] = "1"
 
@@ -284,10 +313,11 @@ if __name__ == "__main__":
 
        # import configuration file and import our main module using those settings
        parse_config(myconfig)
-
+       sys.path.append(conf_values["sharedir"]+"/modules")
        from catalyst_support import *
        
-       # Start checking that digests are valid now that the hash_map was imported from catalyst_support
+       # Start checking that digests are valid now that the hash_map was imported
+       # from catalyst_support
        if conf_values.has_key("digests"):
                for i in conf_values["digests"].split():
                        if not hash_map.has_key(i):
@@ -309,7 +339,8 @@ if __name__ == "__main__":
        if conf_values.has_key("hash_function"):
                if not hash_map.has_key(conf_values["hash_function"]):
                        print
-                       print conf_values["hash_function"]+" is not a valid hash_function entry"
+                       print conf_values["hash_function"]+\
+                               " is not a valid hash_function entry"
                        print "Valid hash_function entries:"
                        print hash_map.keys()
                        print