From b913e798cec59122f5aff5adcf2645ace93d8906 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sun, 12 Feb 2012 01:31:23 +0100 Subject: [PATCH] Add support to create scratch builds from makefiles. --- python/pakfire/cli.py | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/python/pakfire/cli.py b/python/pakfire/cli.py index bd8a8ca74..f47bad8cb 100644 --- a/python/pakfire/cli.py +++ b/python/pakfire/cli.py @@ -21,7 +21,9 @@ import argparse import os +import shutil import sys +import tempfile import pakfire.api as pakfire @@ -841,17 +843,38 @@ class CliClient(Cli): # XXX just for now, we do only upload source pfm files. assert os.path.exists(package) - # Format arches. - if self.args.arch: - arches = self.args.arch.replace(",", " ") - else: - arches = None + # Create a temporary directory. + temp_dir = tempfile.mkdtemp() + + try: + if package.endswith(".%s" % MAKEFILE_EXTENSION): + pakfire_args = { "mode" : "server" } + + # Create a source package from the makefile. + package = pakfire.dist(package, temp_dir, **pakfire_args) + + elif package.endswith(".%s" % PACKAGE_EXTENSION): + pass - # Create a new build on the server. - build = self.client.build_create(package, arches=arches) + else: + raise Exception, "Unknown filetype: %s" % package + + # Format arches. + if self.args.arch: + arches = self.args.arch.replace(",", " ") + else: + arches = None - # XXX Print the resulting build. - print build + # Create a new build on the server. + build = self.client.build_create(package, arches=arches) + + # XXX Print the resulting build. + print build + + finally: + # Cleanup the temporary directory and all files. + if os.path.exists(temp_dir): + shutil.rmtree(temp_dir, ignore_errors=True) def handle_info(self): ret = [] -- 2.39.5