"""
+BUILD_PACKAGES = [
+ "@Build",
+ "ccache",
+ "pakfire-build",
+ "/bin/bash",
+
+ # Handy shell tools
+ "elinks",
+ "less",
+ "vim",
+]
+
BUILD_SCRIPT = """#!/bin/bash --login
set -e
# Get a reference to the logger
self.log = self.builder.log
+ # Setup the environment
+ self._setup()
+
@property
def environ(self):
# Build a minimal environment for executing, but try to inherit TERM and LANG
return env
+ def _setup(self):
+ """
+ Sets up the environment by installing some basic packages
+ """
+ # XXX this needs to be unique for each distribution
+ snapshot_path = "/tmp/pakfire-snapshot.tar.zst"
+
+ # Restore the snapshot if available
+ try:
+ self.pakfire.restore_snapshot(snapshot_path)
+ except FileNotFoundError:
+ pass
+
+ # Install any updates and essential packages
+ # If there have been updates, or on a fresh install, re-create the snapshot
+ if self._install(BUILD_PACKAGES):
+ self.pakfire.create_snapshot(snapshot_path)
+
def _install(self, packages):
self.log.debug(_("Installing packages in build environment:"))
for package in packages:
# Install all required packages
transaction = p.install(packages)
+ # Return how many packages were installed/changed
+ ret = len(transaction)
+
# Dump transaction to log
t = transaction.dump()
self.log.info(t)
# Run the transaction
transaction.run()
- def build(self, path, shell=True):
- # Install build environment
- packages = [
- "@Build",
- ]
-
- # If we have ccache enabled, we need to install it, too
- if self.builder.settings.get("enable_ccache"):
- packages.append("ccache")
+ return ret
+ def build(self, path, shell=True):
# Open the package archive
archive = _pakfire.Archive(self.pakfire, path)
requires = archive.get("dependencies", "requires")
if requires:
- packages += requires.splitlines()
+ packages = requires.splitlines()
- # Setup the environment including any build dependencies
- self._install(packages)
+ # Setup the environment including any build dependencies
+ self._install(packages)
# Extract the source archive (if we have one)
if archive:
archive = _pakfire.Archive(self.pakfire, path)
archives.append(archive)
- # Collect packages to install
- packages = []
-
- # Install our standard shell packages
- packages += SHELL_PACKAGES
-
# Install any packages the user requested
- if install:
- packages += install
+ if not install:
+ install = []
# Install all build requirements for archives
for archive in archives:
requires = archive.get("dependencies.requires")
if requires:
- packages += requires.splitlines()
+ install += requires.splitlines()
# Install all required packages
- self._install(packages)
+ if install:
+ self._install(install)
# Extract archives
for archive in archives: