]> git.ipfire.org Git - pakfire.git/commitdiff
Automatically run the prepare stage before entering the shell.
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 4 Oct 2012 12:20:31 +0000 (14:20 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 4 Oct 2012 12:20:31 +0000 (14:20 +0200)
python/pakfire/base.py
python/pakfire/builder.py
python/pakfire/cli.py

index 54485a517b9e76a61b5c82f5200cedfb6e175102..83663ec3a4e2dc31e8cadb2892195a02cc51b5fb 100644 (file)
@@ -678,11 +678,15 @@ class Pakfire(object):
                finally:
                        b.stop()
 
-       def _build(self, pkg, resultdir, nodeps=False, **kwargs):
+       def _build(self, pkg, resultdir, nodeps=False, prepare=False, **kwargs):
                b = builder.Builder(self, pkg, resultdir, **kwargs)
 
+               stages = None
+               if prepare:
+                       stages = ("prepare",)
+
                try:
-                       b.build()
+                       b.build(stages=stages)
 
                except Error:
                        raise BuildError, _("Build command has failed.")
@@ -696,6 +700,12 @@ class Pakfire(object):
 
                try:
                        b.start()
+
+                       try:
+                               b.build(prepare=True)
+                       except BuildError:
+                               pass
+
                        b.shell()
                finally:
                        b.stop()
index 863ade324f6184e915b15050b387f659dc5baecf..a766f166c037979985cf3eee43bae88f14b90c9b 100644 (file)
@@ -709,7 +709,7 @@ class BuildEnviron(object):
 
                return ret
 
-       def build(self, install_test=True):
+       def build(self, install_test=True, prepare=False):
                if not self.pkg:
                        raise BuildError, _("You cannot run a build when no package was given.")
 
@@ -733,11 +733,14 @@ class BuildEnviron(object):
                        "--resultdir=/result",
                ]
 
+               if prepare:
+                       build_command.append("--prepare")
+
                try:
                        self.do(" ".join(build_command), logger=self.log)
 
                        # Perform the install test after the actual build.
-                       if install_test:
+                       if install_test and not prepare:
                                self.install_test()
 
                except Error:
@@ -745,6 +748,10 @@ class BuildEnviron(object):
 
                        raise BuildError, _("The build command failed. See logfile for details.")
 
+               # Don't sign packages in prepare mode.
+               if prepare:
+                       return
+
                # Sign all built packages with the host key (if available).
                if self.settings.get("sign_packages"):
                        host_key = self.keyring.get_host_key_id()
@@ -1055,7 +1062,7 @@ class Builder(object):
 
                return f.name
 
-       def build(self):
+       def build(self, stages=None):
                # Create buildroot and remove all content if it was existant.
                util.rm(self.buildroot)
                os.makedirs(self.buildroot)
@@ -1063,9 +1070,19 @@ class Builder(object):
                # Build icecream toolchain if icecream is installed.
                self.create_icecream_toolchain()
 
-               for stage in ("prepare", "build", "test", "install"):
+               if stages is None:
+                       stages = ("prepare", "build", "test", "install")
+                       stop_early = False
+               else:
+                       stop_early = True
+
+               for stage in stages:
                        self.build_stage(stage)
 
+               # Stop if only the prepare stage is wanted.
+               if stop_early:
+                       return
+
                # Run post-build stuff.
                self.post_compress_man_pages()
                self.post_remove_static_libs()
index 419e9a043b777492fbf3b2c6d0f4ad782bb37b30..5b56b450145ff88fdd79613cbdc7d759fa1badfd 100644 (file)
@@ -764,6 +764,8 @@ class CliBuilderIntern(Cli):
                        help=_("Mode to run in. Is either 'release' or 'development' (default)."))
                sub_build.add_argument("--nodeps", action="store_true",
                        help=_("Do not verify build dependencies."))
+               sub_build.add_argument("--prepare", action="store_true",
+                       help=_("Only run the prepare stage."))
 
        def handle_build(self):
                # Get the package descriptor from the command line options
@@ -787,6 +789,7 @@ class CliBuilderIntern(Cli):
                        "builder_mode"  : self.args.mode,
                        "config"        : conf,
                        "disable_repos" : disable_repos,
+                       "prepare"       : self.args.prepare,
                        "resultdir"     : self.args.resultdir,
                }