From: Michael Tremer Date: Sat, 1 May 2021 13:02:53 +0000 (+0000) Subject: builder: Add option to disable snapshots X-Git-Tag: 0.9.28~1285^2~166 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1c2ff7a335c6ab2e3c78476bb210b5b2cfdb5497;p=pakfire.git builder: Add option to disable snapshots Signed-off-by: Michael Tremer --- diff --git a/src/pakfire/builder.py b/src/pakfire/builder.py index 9b3e2ccf9..26242abb0 100644 --- a/src/pakfire/builder.py +++ b/src/pakfire/builder.py @@ -77,7 +77,8 @@ class Builder(object): # Settings array. self.settings = { - "enable_ccache" : True, + "enable_ccache" : True, + "enable_snapshot" : True, } # Add settings from keyword arguments @@ -173,20 +174,24 @@ class BuilderContext(object): """ Sets up the environment by installing some basic packages """ + enable_snapshot = self.builder.settings.get("enable_snapshot", True) + snapshot_path = self.pakfire.make_cache_path("snapshot.tar.zst") # Restore the snapshot if available - try: - self.pakfire.restore_snapshot(snapshot_path) + if enable_snapshot: + try: + self.pakfire.restore_snapshot(snapshot_path) - # Ignore if no snapshot was present - except FileNotFoundError: - pass + # Ignore if no snapshot was present + 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) + if enable_snapshot: + self.pakfire.create_snapshot(snapshot_path) def _install(self, packages): self.log.debug(_("Installing packages in build environment:")) diff --git a/src/pakfire/cli.py b/src/pakfire/cli.py index edeacf62c..4a7ab30f7 100644 --- a/src/pakfire/cli.py +++ b/src/pakfire/cli.py @@ -401,6 +401,8 @@ class CliBuilder(Cli): help=_("Run pakfire for the given architecture")) parser.add_argument("--distro", nargs="?", default="ipfire3", # XXX for now help=_("Choose the distribution configuration to use for build")) + parser.add_argument("--disable-snapshot", action="store_true", + help=_("Disable using snapshots")) # build build = subparsers.add_parser("build", help=_("Build one or more packages")) @@ -485,7 +487,11 @@ class CliBuilder(Cli): # Find distro configuration file conf = os.path.join(CONFIG_DISTRO_DIR, "%s.conf" % ns.distro) - return builder.Builder(conf=conf, arch=ns.arch) + return builder.Builder( + conf=conf, + arch=ns.arch, + enable_snapshot=not ns.disable_snapshot + ) def handle_build(self, ns): package, = ns.package