From: Michael Tremer Date: Thu, 29 Apr 2021 12:35:22 +0000 (+0000) Subject: builder: Use standard installation routine to install source packages X-Git-Tag: 0.9.28~1285^2~190 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=57411b1539cd513f865d0278b0a5682f5f40a71e;p=pakfire.git builder: Use standard installation routine to install source packages Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/dist.c b/src/libpakfire/dist.c index 595ffe12b..1c9fbfaac 100644 --- a/src/libpakfire/dist.c +++ b/src/libpakfire/dist.c @@ -54,7 +54,14 @@ PAKFIRE_EXPORT int pakfire_read_makefile(PakfireParser* parser, Pakfire pakfire, goto ERROR; } - // XXX set defaults + // Set BASEDIR + char* dirname = pakfire_dirname(path); + if (dirname) { + const char* root = pakfire_get_path(pakfire); + + pakfire_parser_set(*parser, NULL, "BASEDIR", pakfire_path_relpath(root, dirname)); + free(dirname); + } // Find all macros diff --git a/src/pakfire/builder.py b/src/pakfire/builder.py index e85c2971b..2959f8aba 100644 --- a/src/pakfire/builder.py +++ b/src/pakfire/builder.py @@ -19,7 +19,7 @@ # # ############################################################################### -import errno +import glob import os import uuid @@ -217,88 +217,45 @@ class BuilderContext(object): # Setup the environment self._setup() - # Open the package archive - archive = _pakfire.Archive(self.pakfire, path) + # Install the package + self._install([path]) - # Parse all metadata - package = archive.get_package() + for makefile in glob.glob("%s/usr/src/packages/*/*.nm" % self.pakfire.path): + # Parse the makefile + makefile = self.pakfire.read_makefile(makefile) - requires = archive.get("dependencies", "requires") - if requires: - packages = requires.splitlines() + # Execute stages + for stage in ("prepare", "build", "test", "install"): + # Fetch build script + script = makefile.expand("build", BUILD_SCRIPT % stage) + if not script: + continue - # Setup the environment including any build dependencies - self._install(packages) + self.log.debug("Running stage '%s'" % stage) - # Extract the source archive (if we have one) - if archive: - archive.extract("%s/usr/src" % self.pakfire.path) + # Run it + try: + self.pakfire.execute_script(script, logging_callback=self.log.log, + enable_network=False, interactive=False) - # Read the makefile - makefile = self.pakfire.read_makefile("%s/usr/src/%s/%s.nm" \ - % (self.pakfire.path, package, package.name)) + # Handle if the build script failed + except CommandExecutionError as e: + # Drop into a shell if requested + if shell: + self.pakfire.execute(["/usr/bin/bash", "--login"], + environ=self.environ, enable_network=True, interactive=True) - # Set BASEDIR - makefile.set(None, "BASEDIR", "/usr/src/%s" % package) - - print(makefile) - - # Execute stages - for stage in ("prepare", "build", "test", "install"): - # Fetch build script - script = makefile.expand("build", BUILD_SCRIPT % stage) - if not script: - continue - - self.log.debug("Running stage '%s'" % stage) - - # Run it - try: - self.pakfire.execute_script(script, logging_callback=self.log.log, - enable_network=False, interactive=False) - - # Handle if the build script failed - except CommandExecutionError as e: - # Drop into a shell if requested - if shell: - self.pakfire.execute(["/usr/bin/bash", "--login"], - environ=self.environ, enable_network=True, interactive=True) - - # Raise otherwise - raise e + # Raise otherwise + raise e def shell(self, packages=[], install=None): # Setup the environment self._setup() - archives = [] - - 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) - - # Install any packages the user requested - if not install: - install = [] - - # Install all build requirements for archives - for archive in archives: - requires = archive.get("dependencies.requires") - if requires: - install += requires.splitlines() - - # Install all required packages if install: - self._install(install) + packages += install - # Extract archives - for archive in archives: - archive.extract("%s/build" % self.pakfire.path) + self._install(packages) # Enter the shell self.pakfire.execute(["/usr/bin/bash", "--login"],