]> git.ipfire.org Git - pakfire.git/commitdiff
builder: Add option to disable snapshots
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 1 May 2021 13:02:53 +0000 (13:02 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 1 May 2021 13:02:53 +0000 (13:02 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/builder.py
src/pakfire/cli.py

index 9b3e2ccf9af67ab5d24cc0a91562dde28122a85c..26242abb00014218dfb67f2dd92253f956c193c5 100644 (file)
@@ -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:"))
index edeacf62cfe0b17cf8696e4f8d7e3ca616840779..4a7ab30f78a6d1b4a872adbe5393cd0cde4e34c9 100644 (file)
@@ -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