]> git.ipfire.org Git - pakfire.git/commitdiff
Add support to create scratch builds from makefiles.
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 12 Feb 2012 00:31:23 +0000 (01:31 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 12 Feb 2012 00:31:23 +0000 (01:31 +0100)
python/pakfire/cli.py

index bd8a8ca74b6d8e334b77cedeae49fad7baf74104..f47bad8cbfae670a41741c35f739dbf601b7e48f 100644 (file)
@@ -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 = []