diff options
author | Michael E Brown <mebrown@michaels-house.net> | 2009-01-23 08:26:41 -0600 |
---|---|---|
committer | Michael E Brown <mebrown@michaels-house.net> | 2009-01-23 08:26:41 -0600 |
commit | 534b3148fd64ca6b1a8eee6dbe40bdfb61706c00 (patch) | |
tree | d39a19e06f06fa48d0894a4725ad7a99500c8966 /py/mock.py | |
parent | 3e9969f8c50b85f8380c3fe00155ae5b9970fac2 (diff) | |
parent | 305c142babcbc5150b716b38e63cd8f9de6f4ef7 (diff) | |
download | mock-534b3148fd64ca6b1a8eee6dbe40bdfb61706c00.tar.gz mock-534b3148fd64ca6b1a8eee6dbe40bdfb61706c00.tar.xz mock-534b3148fd64ca6b1a8eee6dbe40bdfb61706c00.zip |
Merge branch 'buildsrpm'
* buildsrpm:
unlink->rmdir
another srpm -> spec change in buildsrpm. add state for building srpm.
cant use srpm var, use spec file instead. its ofr info only.
initial work to copy spec/sources and build srpm.
Diffstat (limited to 'py/mock.py')
-rwxr-xr-x | py/mock.py | 43 |
1 files changed, 43 insertions, 0 deletions
@@ -72,6 +72,9 @@ def command_parse(config_opts): parser.add_option("--rebuild", action="store_const", const="rebuild", dest="mode", default='rebuild', help="rebuild the specified SRPM(s)") + parser.add_option("--buildsrpm", action="store_const", const="buildsrpm", + dest="mode", + help="Build a SRPM from spec (--spec ...) and sources (--sources ...)") parser.add_option("--shell", action="store_const", const="shell", dest="mode", help="run the specified command interactively within the chroot." @@ -157,6 +160,11 @@ def command_parse(config_opts): help="Change to the specified directory (relative to the chroot)" " before running command when using --chroot") + parser.add_option("--spec", action="store", + help="Specifies spec file to use to build an SRPM (used only with --buildsrpm)") + parser.add_option("--sources", action="store", + help="Specifies sources to use to build an SRPM (used only with --buildsrpm)") + # verbosity parser.add_option("-v", "--verbose", action="store_const", const=2, dest="verbose", default=1, help="verbose build") @@ -377,6 +385,38 @@ def do_rebuild(config_opts, chroot, srpms): chroot.clean() raise +def do_buildsrpm(config_opts, chroot, options, args): + start = time.time() + try: + # TODO: validate spec path (exists) + # TODO: validate SOURCES path (exists) + + log.info("Start(%s) Config(%s)" % (os.path.basename(options.spec), chroot.sharedRootName)) + if config_opts['clean'] and chroot.state() != "clean": + chroot.clean() + chroot.init() + + chroot.buildsrpm(spec=options.spec, sources=options.sources, timeout=config_opts['rpmbuild_timeout']) + + elapsed = time.time() - start + log.info("Done(%s) Config(%s) %d minutes %d seconds" + % (os.path.basename(options.spec), config_opts['chroot_name'], elapsed//60, elapsed%60)) + log.info("Results and/or logs in: %s" % chroot.resultdir) + + if config_opts["cleanup_on_success"]: + log.info("Cleaning up build root ('clean_on_success=True')") + chroot.clean() + + except (Exception, KeyboardInterrupt): + elapsed = time.time() - start + log.error("Exception(%s) Config(%s) %d minutes %d seconds" + % (os.path.basename(options.spec), chroot.sharedRootName, elapsed//60, elapsed%60)) + log.info("Results and/or logs in: %s" % chroot.resultdir) + if config_opts["cleanup_on_failure"]: + log.info("Cleaning up build root ('clean_on_failure=True')") + chroot.clean() + raise + def main(ret): "Main executable entry point." # drop unprivleged to parse args, etc. @@ -578,6 +618,9 @@ def main(ret): elif options.mode == 'rebuild': do_rebuild(config_opts, chroot, args) + elif options.mode == 'buildsrpm': + do_buildsrpm(config_opts, chroot, options, args) + elif options.mode == 'orphanskill': mock.util.orphansKill(chroot.makeChrootPath()) elif options.mode == 'copyin': |