diff options
author | Martin Langhoff <martin@laptop.org> | 2012-07-20 14:38:22 (GMT) |
---|---|---|
committer | Daniel Drake <dsd@laptop.org> | 2012-08-20 20:32:30 (GMT) |
commit | 14ed75647fdd7aed4330ce1c973ca84073bc1c19 (patch) | |
tree | 998dbaefb68ca1b11978cdf417fcd39c3cfc5f92 /osbuilder.py | |
parent | 92a911f8c468c42f6c3880aeee824f2e13438670 (diff) |
Introduce --cache-only boolean option, propagate to modules
Along the way, add basic support for handling boolean
values in python and shell scripts in modules.
[dsd: trivial tweaks: renamed to --cache-only, use variable presence in
environment for boolean testing, add documentation]
Diffstat (limited to 'osbuilder.py')
-rwxr-xr-x | osbuilder.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/osbuilder.py b/osbuilder.py index 0cddd94..ce8e723 100755 --- a/osbuilder.py +++ b/osbuilder.py @@ -71,6 +71,9 @@ class Stage(object): env['oob_config_dir'] = os.path.dirname(self.osb.build_configs[0]) + if self.osb.cacheonly: + env['OOB__cacheonly'] = 'True' + envpath = env['PATH'].split(':') for dir in ('/sbin', '/usr/sbin'): if envpath.count(dir) == 0: @@ -278,6 +281,9 @@ class OsBuilder(object): self.statedir = os.path.join(self.builddir, 'state') self.fsmount = os.path.join(self.builddir, 'mnt-fs') + # gets set in build() + self.cacheonly = False + # load config to find module list # and set interpolation default for oob_config_dir self.cfg = SafeConfigParser({'oob_config_dir': @@ -363,13 +369,17 @@ class OsBuilder(object): # cleanup stage not listed here as its a bit of a special case ) - def build(self, clean_output=True, clean_intermediates=True): + def build(self, clean_output=True, clean_intermediates=True, cacheonly=False): # cleanup from previous runs if clean_intermediates and os.path.exists(self.intermediatesdir): shutil.rmtree(self.intermediatesdir) if clean_output and os.path.exists(self.outputdir): shutil.rmtree(self.outputdir) + self.cacheonly = cacheonly + if cacheonly and not os.path.exists(self.cachedir): + raise OsBuilderException("Missing cache, cannot use --cache-only") + for dir in (self.builddir, self.cachedir, self.intermediatesdir, self.outputdir, self.statedir, self.fsmount): if not os.path.exists(dir): @@ -407,6 +417,10 @@ def main(): op.add_option('--no-clean-intermediates', dest="clean_intermediates", action="store_false", default=True, help="Don't clean intermediates directory on startup or exit") + op.add_option('--cache-only', dest="cacheonly", + action="store_true", default=False, + help="Run entirely from cache") + (options, args) = op.parse_args() if len(args) < 1: @@ -415,7 +429,8 @@ def main(): try: osb = OsBuilder(args) osb.build(clean_output=options.clean_output, - clean_intermediates=options.clean_intermediates) + clean_intermediates=options.clean_intermediates, + cacheonly=options.cacheonly) except OsBuilderException, e: print >>sys.stderr, "ERROR:", e sys.exit(1) |