]> git.ipfire.org Git - pakfire.git/commitdiff
pakfire-builder: Automatically run dist when passed makefiles
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 22 Jul 2021 13:22:06 +0000 (13:22 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 22 Jul 2021 13:22:06 +0000 (13:22 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/scripts/pakfire-builder.in

index 565b18b4ef8fb8f130e163c364b9d947048bb61a..28fb374e61dd3501954b61f3e97a1505ac4fb2ce 100644 (file)
@@ -24,6 +24,7 @@ import logging
 import os.path
 import sys
 import systemd.journal
+import tempfile
 import uuid
 
 import pakfire
@@ -195,12 +196,27 @@ class Cli(object):
                """
                package, = ns.package
 
-               # Initialise a builder instance and build this package
-               p = self.pakfire(ns)
-               p.build(
-                       package,
-                       build_id="%s" % ns.build_id,
-               )
+               # Create a temporary directory if we need to call dist
+               tmp = tempfile.TemporaryDirectory(prefix="pakfire-builder-")
+
+               try:
+                       # Initialise a builder instance and build this package
+                       p = self.pakfire(ns)
+
+                       # Package any makefiles
+                       if package.endswith(".nm"):
+                               package = p.dist(package, tmp.name)
+                               print(package)
+
+                       # Run build
+                       p.build(
+                               package,
+                               build_id="%s" % ns.build_id if ns.build_id else None,
+                       )
+
+               # Cleanup the temporary directory
+               finally:
+                       tmp.cleanup()
 
        def _dist(self, ns):
                # Get the packages from the command line options