# 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",
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