]> git.ipfire.org Git - pakfire.git/commitdiff
builder: Fall back into a shell if build fails
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 4 Mar 2021 22:51:05 +0000 (22:51 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 4 Mar 2021 22:59:58 +0000 (22:59 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/builder.py
src/pakfire/errors.py

index e53ed4fbb8f20cb415f8bea6b1c1e955b0d0cb45..35918570f4711b0bffd2b2aeed075e2ed8c85c75 100644 (file)
@@ -46,7 +46,7 @@ log = logging.getLogger("pakfire.builder")
 from .system import system
 from .constants import *
 from .i18n import _
-from .errors import BuildError, Error
+from .errors import *
 
 
 BUILD_LOG_HEADER = """
@@ -376,8 +376,19 @@ class BuilderContext(object):
                        self.log.debug("Running stage '%s'" % stage)
 
                        # Run it
-                       self.pakfire.execute_script(script, logging_callback=self.log.log,
-                               enable_network=False, interactive=False)
+                       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
 
        def shell(self, packages=[], install=None):
                archives = []
index 69ca8b8727111b9ab2513656ec91acdf1508d815..ad33975e4d608a2b91530731006f48e176fb4f0d 100644 (file)
 
 from .i18n import _
 
-from ._pakfire import DependencyError
+from ._pakfire import (
+       CommandExecutionError,
+       DependencyError,
+)
 
 class commandTimeoutExpired(Exception):
        pass # XXX cannot be as is