# #
###############################################################################
-import errno
+import glob
import os
import uuid
# 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"],