From dd2d8d906462703934eaa2100dec79cf6dafee36 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Mon, 31 Oct 2022 10:55:57 +0000 Subject: [PATCH] builder: Allow building multiple packages one after the other Signed-off-by: Michael Tremer --- src/scripts/pakfire-builder.in | 36 ++++++++++++++++------------------ 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/src/scripts/pakfire-builder.in b/src/scripts/pakfire-builder.in index 08a5d9806..b3d4d4960 100644 --- a/src/scripts/pakfire-builder.in +++ b/src/scripts/pakfire-builder.in @@ -48,7 +48,7 @@ class Cli(object): # build build = subparsers.add_parser("build", help=_("Build one or more packages")) - build.add_argument("package", nargs=1, + build.add_argument("package", nargs="+", help=_("Give name of at least one package to build")) build.set_defaults(func=self._build) build.add_argument("--id", type=uuid.UUID, dest="build_id", @@ -179,31 +179,29 @@ class Cli(object): def _build(self, ns): """ - Builds a package + Builds one or more packages """ - package, = ns.package + # Initialise a builder instance and build these packages + p = self.pakfire(ns) # Create a temporary directory if we need to call dist - tmp = tempfile.TemporaryDirectory(prefix="pakfire-builder-") + with tempfile.TemporaryDirectory(prefix="pakfire-builder-") as tmp: + packages = [] - try: - # Initialise a builder instance and build this package - p = self.pakfire(ns) + # Run dist on packages where necessary + for path in ns.package: + if path.endswith(".nm"): + path = p.dist(path, tmp) - # Package any makefiles - if package.endswith(".nm"): - package = p.dist(package, tmp.name) + packages.append(path) # Run build - p.build( - package, - build_id="%s" % ns.build_id if ns.build_id else None, - disable_snapshot=ns.disable_snapshot, - ) - - # Cleanup the temporary directory - finally: - tmp.cleanup() + for package in packages: + p.build( + package, + build_id="%s" % ns.build_id if ns.build_id else None, + disable_snapshot=ns.disable_snapshot, + ) def _dist(self, ns): # Get the packages from the command line options -- 2.39.5