]> git.ipfire.org Git - pakfire.git/commitdiff
builder: Use standard installation routine to install source packages
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 29 Apr 2021 12:35:22 +0000 (12:35 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 29 Apr 2021 12:35:22 +0000 (12:35 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/dist.c
src/pakfire/builder.py

index 595ffe12b367939ee87a990514097c48820ff3d4..1c9fbfaacc1293c9211549a7f359e4a970f13070 100644 (file)
@@ -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
 
index e85c2971bf88e7ee2eb91e4a403eb1ccb4bb09ea..2959f8aba37dea6e85d60a1d62566774101c1732 100644 (file)
@@ -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"],