From eda38fa33ca9dbd2e2df4ecf3844a3d71fe69faa Mon Sep 17 00:00:00 2001 From: Brian Dolbec Date: Wed, 19 Dec 2012 18:07:45 -0800 Subject: [PATCH] make more configured defaults and add them to our catalyst.conf. --- catalyst | 68 ++++++++++++++++++++++++++++++----------------------- files/catalyst.conf | 34 +++++++++++++++++++++------ 2 files changed, 65 insertions(+), 37 deletions(-) diff --git a/catalyst b/catalyst index 3d31599..f5b4534 100755 --- a/catalyst +++ b/catalyst @@ -25,7 +25,7 @@ conf_values={} def usage(): print "Usage catalyst [options] [-C variable=value...] [ -s identifier]" - print " -a --clear-autoresume clear autoresume flags" + print " -a --clear-autoresume clear autoresume flags" print " -c --config use specified configuration file" print " -C --cli catalyst commandline (MUST BE LAST OPTION)" print " -d --debug enable debugging" @@ -61,12 +61,20 @@ def parse_config(myconfig): myconf={} config_file="" - confdefaults={ "storedir":"/var/tmp/catalyst",\ - "sharedir":"/usr/share/catalyst","distdir":"/usr/portage/distfiles",\ - "portdir":"/usr/portage","options":"",\ - "snapshot_cache":"/var/tmp/catalyst/snapshot_cache",\ - "hash_function":"crc32"} - + confdefaults={ + "storedir": "/var/tmp/catalyst", + "sharedir": "/usr/lib/catalyst", + "distdir": "/var/cache/distfiles", + "repo_name": "gentoo", + "portdir": "/var/cache/repositories/gentoo", + "packagedir": "/var/cache/packages", + "port_tmpdir": "/var/tmp/portage", + "options": "", + "snapshot_name": "portage-", + "snapshot_cache": "/var/tmp/catalyst/snapshot_cache", + "hash_function": "crc32", + } + # first, try the one passed (presumably from the cmdline) if myconfig: if os.path.exists(myconfig): @@ -77,12 +85,12 @@ def parse_config(myconfig): print "!!! catalyst: Could not use specified configuration file "+\ myconfig sys.exit(1) - + # next, try the default location elif os.path.exists("/etc/catalyst/catalyst.conf"): print "Using default Catalyst configuration file, /etc/catalyst/catalyst.conf" config_file="/etc/catalyst/catalyst.conf" - + # can't find a config file (we are screwed), so bail out else: print "!!! catalyst: Could not find a suitable configuration file" @@ -93,11 +101,11 @@ def parse_config(myconfig): # execfile(config_file, myconf, myconf) myconfig = catalyst.config.ConfigParser(config_file) myconf.update(myconfig.get_values()) - + except: print "!!! catalyst: Unable to parse configuration file, "+myconfig sys.exit(1) - + # now, load up the values into conf_values so that we can use them for x in confdefaults.keys(): if myconf.has_key(x): @@ -120,9 +128,9 @@ def parse_config(myconfig): print "Cleaning autoresume flags support enabled." conf_values["CLEAR_AUTORESUME"]="1" -# if "compress" in string.split(conf_values["options"]): -# print "Compression enabled." -# conf_values["COMPRESS"]="1" + #if "compress" in string.split(conf_values["options"]): + #print "Compression enabled." + #conf_values["COMPRESS"]="1" if "distcc" in string.split(conf_values["options"]): print "Distcc support enabled." @@ -152,9 +160,9 @@ def parse_config(myconfig): print "Snapshot cache support enabled." conf_values["SNAPCACHE"]="1" -# if "tarball" in string.split(conf_values["options"]): -# print "Tarball creation enabled." -# conf_values["TARBALL"]="1" +# if "tarball" in string.split(conf_values["options"]): +# print "Tarball creation enabled." +# conf_values["TARBALL"]="1" if myconf.has_key("digests"): conf_values["digests"]=myconf["digests"] @@ -208,9 +216,9 @@ def build_target(addlargs, targetmap): try: if not targetmap.has_key(addlargs["target"]): raise CatalystError,"Target \""+addlargs["target"]+"\" not available." - + mytarget=targetmap[addlargs["target"]](conf_values, addlargs) - + mytarget.run() except: @@ -220,7 +228,7 @@ def build_target(addlargs, targetmap): if __name__ == "__main__": targetmap={} - + version() if os.getuid() != 0: # catalyst cannot be run as a normal user due to chroots, mounts, etc @@ -236,11 +244,11 @@ if __name__ == "__main__": try: 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: usage() sys.exit(2) - + # defaults for commandline opts debug=False verbose=False @@ -261,7 +269,7 @@ if __name__ == "__main__": if o in ("-h", "--help"): usage() sys.exit(1) - + if o in ("-V", "--version"): print "Catalyst version "+__version__ sys.exit(1) @@ -279,14 +287,14 @@ if __name__ == "__main__": while x < len(sys.argv): mycmdline.append(sys.argv[x]) x=x+1 - + if o in ("-f", "--file"): run = True myspecfile=a if o in ("-F", "--fetchonly"): conf_values["FETCH"]="1" - + if o in ("-v", "--verbose"): conf_values["VERBOSE"]="1" @@ -299,7 +307,7 @@ if __name__ == "__main__": run = True mycmdline.append("target=snapshot") mycmdline.append("version_stamp="+a) - + if o in ("-p", "--purge"): conf_values["PURGE"] = "1" @@ -321,7 +329,7 @@ if __name__ == "__main__": 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 if conf_values.has_key("digests"): @@ -365,11 +373,11 @@ if __name__ == "__main__": targetmap=import_modules() addlargs={} - + if myspecfile: spec = catalyst.config.SpecParser(myspecfile) addlargs.update(spec.get_values()) - + if mycmdline: try: cmdline = catalyst.config.ConfigParser() @@ -385,7 +393,7 @@ if __name__ == "__main__": # everything is setup, so the build is a go try: build_target(addlargs, targetmap) - + except CatalystError: print print "Catalyst aborting...." diff --git a/files/catalyst.conf b/files/catalyst.conf index e2def66..6fbf17a 100644 --- a/files/catalyst.conf +++ b/files/catalyst.conf @@ -24,17 +24,13 @@ digests="md5 sha1 sha512 whirlpool" # If this variable is empty, no .CONTENTS will be generated at all. contents="auto" -# distdir specifies where your distfiles are located. This setting should -# work fine for most default installations. -distdir="/usr/portage/distfiles" - # envscript allows users to set options such as http proxies, MAKEOPTS, # GENTOO_MIRRORS, or any other environment variables needed for building. # The envscript file sets environment variables like so: # export FOO="bar" envscript="/etc/catalyst/catalystrc" -# Internal hash function catalyst should use for things like autoresume, +# Internal hash function catalyst should use for things like autoresume, # seedcache, etc. The default and fastest is crc32. You should not ever need # to change this unless your OS does not support it. # Supported hashes: @@ -51,7 +47,7 @@ hash_function="crc32" # ( This option is not fully tested, bug reports welcome ) # ccache = enables build time ccache support # distcc = enable distcc support for building. You have to set distcc_hosts in -# your spec file. +# your spec file. # icecream = enables icecream compiler cluster support for building # kerncache = keeps a tbz2 of your built kernel and modules (useful if your # build stops in livecd-stage2) @@ -66,13 +62,37 @@ hash_function="crc32" # (These options can be used together) options="autoresume kerncache pkgcache seedcache snapcache" +# fixme get this from portage instead +# target repo directory name (make it configurable) +repo_name= "gentoo" + +# fixme get this from portage instead # portdir specifies the source portage tree used by the snapshot target. -portdir="/usr/portage" +portdir="/var/cache/repositories/%(repo_name)s" + +# fixme get this from portage instead +# distdir specifies where your distfiles are located. This setting should +# work fine for most default installations. +distdir="/var/cache/distfiles" + +# fixme get this from portage instead +# packagdir specifies where the binpkgs are stored +packagedir="/var/cache/packages" + +# local_overlay path +local_verlay="/var/cache/repositories/local" + +# fixme get this from portage instead +# portage temp dir +port_tmpdir="/var/tmp/portage" # sharedir specifies where all of the catalyst runtime executables are. Most # users do not need to change this. sharedir="/usr/lib/catalyst" +# snapshot_name the name to use for creating the snapshot +snapshot_name="portage-" + # snapshot_cache specifies where the snapshots will be cached to if snapcache is # enabled in the options. snapshot_cache="/var/tmp/catalyst/snapshot_cache" -- 1.8.0