]> git.ipfire.org Git - pakfire.git/commitdiff
builder: Extract packages into the build environment
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 13 Feb 2021 15:31:20 +0000 (15:31 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 13 Feb 2021 15:31:20 +0000 (15:31 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/builder.py
src/pakfire/cli.py

index 37d09ea7aa4c27e6e296b1a032f15b8a2ef2ba51..438714588f1e3845d09c01ff9d2c99965cb91d2a 100644 (file)
@@ -331,18 +331,28 @@ class BuilderContext(object):
                archive = _pakfire.Archive(self.pakfire, package)
 
                requires = archive.get("dependencies.requires")
-               packages += requires.splitlines()
+               if requires:
+                       packages += requires.splitlines()
 
                # Setup the environment including any build dependencies
                self._install(packages)
 
-               # XXX perform build
+               # Extract the source archive (if we have one)
+               if archive:
+                       archive.extract("%s/build" % self.pakfire.path)
+
+       def shell(self, packages=[], install=None):
+               archives = []
 
-       def shell(self, install=None):
                if not util.cli_is_interactive():
                        self.log.warning("Cannot run shell on non-interactive console.")
                        return
 
+               # Open all archives
+               for path in packages:
+                       archive = _pakfire.Archive(self.pakfire, path)
+                       archives.append(archive)
+
                # Collect packages to install
                packages = []
 
@@ -353,9 +363,19 @@ class BuilderContext(object):
                if install:
                        packages += install
 
+               # Install all build requirements for archives
+               for archive in archives:
+                       requires = archive.get("dependencies.requires")
+                       if requires:
+                               packages += requires.splitlines()
+
                # Install all required packages
                self._install(packages)
 
+               # Extract archives
+               for archive in archives:
+                       archive.extract("%s/build" % self.pakfire.path)
+
                # Enter the shell
                self.pakfire.execute(["/usr/bin/bash", "--login"],
                        environ=self.environ, enable_network=True, interactive=True)
index b0b82b7fb2ec835a5a905dabc66238e76e8a532d..c887e2ff3d12a7458fa7f3a95128638f9deb3933 100644 (file)
@@ -469,7 +469,7 @@ class CliBuilder(Cli):
 
                # shell
                shell = subparsers.add_parser("shell", help=_("Go into a build shell"))
-               shell.add_argument("package", nargs="?", help=_("Give name of a package"))
+               shell.add_argument("package", nargs="*", help=_("Give name of a package"))
                shell.add_argument("--install", nargs="*",
                        help=_("Packages that should be installed in the shell"))
                shell.set_defaults(func=self.handle_shell)
@@ -497,7 +497,7 @@ class CliBuilder(Cli):
 
        def handle_shell(self, ns):
                with self.builder(ns) as b:
-                       b.shell(install=ns.install)
+                       b.shell(packages=ns.package, install=ns.install)
 
        def handle_dist(self, ns):
                # Get the packages from the command line options