From 47230b239d9ce12ef55611ce191e6838a9ab9e0d Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Thu, 4 Oct 2012 14:20:31 +0200 Subject: [PATCH] Automatically run the prepare stage before entering the shell. --- python/pakfire/base.py | 14 ++++++++++++-- python/pakfire/builder.py | 25 +++++++++++++++++++++---- python/pakfire/cli.py | 3 +++ 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/python/pakfire/base.py b/python/pakfire/base.py index 54485a517..83663ec3a 100644 --- a/python/pakfire/base.py +++ b/python/pakfire/base.py @@ -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() diff --git a/python/pakfire/builder.py b/python/pakfire/builder.py index 863ade324..a766f166c 100644 --- a/python/pakfire/builder.py +++ b/python/pakfire/builder.py @@ -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() diff --git a/python/pakfire/cli.py b/python/pakfire/cli.py index 419e9a043..5b56b4501 100644 --- a/python/pakfire/cli.py +++ b/python/pakfire/cli.py @@ -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, } -- 2.39.5