diff --git a/src/bin/pungi.py b/src/bin/pungi.py index 5f92c412..51e659b5 100755 --- a/src/bin/pungi.py +++ b/src/bin/pungi.py @@ -62,6 +62,15 @@ def main(): else: print >> sys.stdout, "Warning: Reusing existing destination directory." + if not os.path.exists(config.get('pungi', 'workdirbase')): + try: + os.makedirs(config.get('pungi', 'workdirbase')) + except OSError, e: + print >> sys.stderr, "Error: Cannot create working base dir %s" % config.get('pungi', 'workdirbase') + sys.exit(1) + else: + print >> sys.stdout, "Warning: Reusing existing working base directory." + cachedir = config.get('pungi', 'cachedir') if not os.path.exists(cachedir): @@ -242,6 +251,9 @@ if __name__ == '__main__': help='Multilib method; can be specified multiple times; recommended: devel, runtime') parser.add_option("--lookaside-repo", action="append", dest="lookaside_repos", metavar="NAME", help='Specify lookaside repo name(s) (packages will used for depsolving but not be included in the output)') + parser.add_option("--workdirbase", dest="workdirbase", type="string", + action="callback", callback=set_config, callback_args=(config, ), + help='base working directory (defaults to destdir + /work)') parser.add_option("-c", "--config", dest="config", help='Path to kickstart config file') diff --git a/src/pypungi/__init__.py b/src/pypungi/__init__.py index 6c65bc92..e8cdf964 100644 --- a/src/pypungi/__init__.py +++ b/src/pypungi/__init__.py @@ -124,8 +124,7 @@ class PungiBase(object): self.compatible_arches[i] = arch_module.get_compatible_arches(i) self.doLoggerSetup() - self.workdir = os.path.join(self.config.get('pungi', 'destdir'), - 'work', + self.workdir = os.path.join(self.config.get('pungi', 'workdirbase'), self.config.get('pungi', 'flavor'), self.tree_arch) diff --git a/src/pypungi/config.py b/src/pypungi/config.py index 68759a8a..e0bcf6fc 100644 --- a/src/pypungi/config.py +++ b/src/pypungi/config.py @@ -40,6 +40,7 @@ class Config(SafeConfigParser): self.set('pungi', 'version', time.strftime('%Y%m%d', time.localtime())) self.set('pungi', 'flavor', '') self.set('pungi', 'destdir', os.getcwd()) + self.set('pungi', 'workdirbase', "%s/work" % self.get('pungi', 'destdir')) self.set('pungi', 'bugurl', 'https://bugzilla.redhat.com') self.set('pungi', 'cdsize', '695.0') self.set('pungi', 'debuginfo', "True")