]> git.ipfire.org Git - pakfire.git/commitdiff
Drop user to a shell if running on an interactive console.
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 26 Feb 2011 08:23:30 +0000 (09:23 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 26 Feb 2011 08:23:30 +0000 (09:23 +0100)
pakfire/__init__.py
pakfire/builder.py
pakfire/cli.py
pakfire/util.py

index 57630ce04b448496a1e47779c3669486d088fc4a..37cdc0a48728a7ca3bfae750eedac9ebb887893f 100644 (file)
@@ -126,6 +126,10 @@ class Pakfire(object):
                                        continue
 
                                b.copy_result(resultdir)
+
+               except BuildError:
+                       b.shell()
+
                finally:
                        b.cleanup()
 
index 04b7af68335b1959ae76fb2ddc7ebdfff30c9d4c..f62ace738466baddf397c1b7040a51f617cc1952 100644 (file)
@@ -19,7 +19,7 @@ import transaction
 import util
 
 from constants import *
-from errors import BuildRootLocked
+from errors import BuildError, BuildRootLocked, Error
 
 
 class Builder(object):
@@ -532,7 +532,11 @@ class Builder(object):
        def build(self):
                self.create_icecream_toolchain()
 
-               self.make("build")
+               try:
+                       self.make("build")
+
+               except Error:
+                       raise BuildError, "The build command failed."
 
                for pkg in reversed(self.packages):
                        packager = packages.Packager(self.pakfire, pkg, self)
@@ -542,6 +546,10 @@ class Builder(object):
                self.pkg.dist(self)
 
        def shell(self, args=[]):
+               if not util.cli_is_interactive():
+                       logging.warning("Cannot run shell on non-interactive console.")
+                       return
+
                # XXX need to set CFLAGS here
                command = "/usr/sbin/chroot %s /usr/bin/chroot-shell %s" % \
                        (self.chrootPath(), " ".join(args))
index 40bd3e9b048ae94053a70be20148ec6dc5a7a9c2..8d544a5f929ac19eff613dfd951e02d55aae4eeb 100644 (file)
@@ -5,6 +5,7 @@ import sys
 
 import packages
 import repository
+import util
 
 from pakfire import Pakfire
 
@@ -20,7 +21,7 @@ def ask_user(question):
                If the software is running in a non-inteactive shell, no question
                is asked at all and the answer is always "yes".
        """
-       if not sys.stdin.isatty() or not sys.stdout.isatty() or not sys.stderr.isatty():
+       if not util.cli_is_interactive():
                return True
 
        print _("%s [y/N]") % question,
index 1e03ad9ee00f266ed3925dbfcaae4c2bd1f1fd96..ad40a38ac196413a998aaf582148e2975ce79fd7 100644 (file)
@@ -22,6 +22,15 @@ _libc.unshare.argtypes = [ctypes.c_int,]
 _libc.unshare.restype = ctypes.c_int
 CLONE_NEWNS = 0x00020000
 
+def cli_is_interactive():
+       """
+               Say weather a shell is interactive or not.
+       """
+       if sys.stdin.isatty() and sys.stdout.isatty() and sys.stderr.isatty():
+               return True
+
+       return False
+
 def rm(path, *args, **kargs):
        """
                version of shutil.rmtree that ignores no-such-file-or-directory errors,