From e412b8dcfead21f325692e54d156b01f9d4a72bd Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Fri, 4 Mar 2011 13:33:25 +0100 Subject: [PATCH] Add possibility for multiple makefiles to pass to "dist" command. --- pakfire/__init__.py | 26 +++++++++++++++------ pakfire/builder.py | 23 ++++++++++++++++++- pakfire/cli.py | 29 +++++++++++------------ po/pakfire.pot | 56 ++++++++++++++++++++++++--------------------- 4 files changed, 86 insertions(+), 48 deletions(-) diff --git a/pakfire/__init__.py b/pakfire/__init__.py index ecbab20e5..440353abb 100644 --- a/pakfire/__init__.py +++ b/pakfire/__init__.py @@ -146,9 +146,12 @@ class Pakfire(object): finally: b.destroy() - def dist(self, pkg, resultdirs=None): + def dist(self, pkgs, resultdirs=None): self.check_build_mode() + # Select first package out of pkgs. + pkg = pkgs[0] + b = builder.Builder(pakfire=self, pkg=pkg) try: b.prepare() @@ -165,14 +168,23 @@ class Pakfire(object): resultdirs.append(self.repos.local_build.path) try: - b.dist() + for pkg in pkgs: + # Change package of the builder to current one. + b.pkg = pkg + b.extract(build_deps=False) - # Copy-out all resultfiles - for resultdir in resultdirs: - if not resultdir: - continue + # Run the actual dist. + b.dist() - b.copy_result(resultdir) + # Copy-out all resultfiles + for resultdir in resultdirs: + if not resultdir: + continue + + b.copy_result(resultdir) + + # Cleanup all the stuff from pkg. + b.cleanup() finally: b.destroy() diff --git a/pakfire/builder.py b/pakfire/builder.py index daddaa356..8eee69711 100644 --- a/pakfire/builder.py +++ b/pakfire/builder.py @@ -329,11 +329,32 @@ class Builder(object): os.mknod(filename, mode, device) def destroy(self): - logging.debug("Cleanup environment %s" % self.path) + logging.debug("Destroying environment %s" % self.path) if os.path.exists(self.path): util.rm(self.path) + def cleanup(self): + logging.debug("Cleaning environemnt.") + + # Run make clean and let it cleanup its stuff. + self.make("clean") + + # Remove the build directory and buildroot. + dirs = ("build", self.buildroot, "result") + + for d in dirs: + d = self.chrootPath(d) + if not os.path.exists(d): + continue + + util.rm(d) + os.makedirs(d) + + # Clear make_info cache. + if hasattr(self, "_make_info"): + del self._make_info + def _mountall(self): self.log.debug("Mounting environment") for cmd, mountpoint in self.mountpoints: diff --git a/pakfire/cli.py b/pakfire/cli.py index 8d544a5f9..26f8c3cef 100644 --- a/pakfire/cli.py +++ b/pakfire/cli.py @@ -257,8 +257,8 @@ class CliBuilder(Cli): # Implement the "dist" command. sub_dist = self.sub_commands.add_parser("dist", help=_("Generate a source package.")) - sub_dist.add_argument("package", nargs=1, - help=_("Give name of a package.")) + sub_dist.add_argument("package", nargs="+", + help=_("Give name(s) of a package(s).")) sub_dist.add_argument("action", action="store_const", const="dist") sub_dist.add_argument("--resultdir", nargs="?", @@ -312,22 +312,23 @@ class CliBuilder(Cli): self.pakfire.shell(pkg, arch=self.args.arch) def handle_dist(self): - print self.args - # Get the package descriptor from the command line options - pkg = self.args.package[0] + # Get the packages from the command line options + pkgs = [] - # Check, if we got a regular file - if os.path.exists(pkg): - pkg = os.path.abspath(pkg) + for pkg in self.args.package: + # Check, if we got a regular file + if os.path.exists(pkg): + pkg = os.path.abspath(pkg) - if pkg.endswith(MAKEFILE_EXTENSION): - pkg = packages.Makefile(self.pakfire, pkg) + if pkg.endswith(MAKEFILE_EXTENSION): + pkg = packages.Makefile(self.pakfire, pkg) + pkgs.append(pkg) - else: - # XXX walk through the source tree and find a matching makefile - pass + else: + # XXX walk through the source tree and find a matching makefile + pass - self.pakfire.dist(pkg, resultdirs=[self.args.resultdir,]) + self.pakfire.dist(pkgs, resultdirs=[self.args.resultdir,]) class CliServer(Cli): def __init__(self): diff --git a/po/pakfire.pot b/po/pakfire.pot index b43873ddd..00df40d7d 100644 --- a/po/pakfire.pot +++ b/po/pakfire.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-02-28 16:41+0100\n" +"POT-Creation-Date: 2011-03-04 13:23+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -118,7 +118,7 @@ msgstr "" msgid "Go into a shell." msgstr "" -#: ../pakfire/cli.py:250 ../pakfire/cli.py:261 +#: ../pakfire/cli.py:250 msgid "Give name of a package." msgstr "" @@ -130,97 +130,101 @@ msgstr "" msgid "Generate a source package." msgstr "" -#: ../pakfire/cli.py:335 +#: ../pakfire/cli.py:261 +msgid "Give name(s) of a package(s)." +msgstr "" + +#: ../pakfire/cli.py:336 msgid "Pakfire server command line interface." msgstr "" -#: ../pakfire/cli.py:360 +#: ../pakfire/cli.py:361 msgid "Repository management commands." msgstr "" -#: ../pakfire/cli.py:368 +#: ../pakfire/cli.py:369 msgid "Create a new repository index." msgstr "" -#: ../pakfire/cli.py:369 +#: ../pakfire/cli.py:370 msgid "Path to the packages." msgstr "" -#: ../pakfire/cli.py:370 +#: ../pakfire/cli.py:371 msgid "Path to input packages." msgstr "" -#: ../pakfire/depsolve.py:217 +#: ../pakfire/depsolve.py:220 msgid "Package" msgstr "" -#: ../pakfire/depsolve.py:217 ../pakfire/packages/base.py:55 +#: ../pakfire/depsolve.py:220 ../pakfire/packages/base.py:55 msgid "Arch" msgstr "" -#: ../pakfire/depsolve.py:217 ../pakfire/packages/base.py:56 +#: ../pakfire/depsolve.py:220 ../pakfire/packages/base.py:56 msgid "Version" msgstr "" -#: ../pakfire/depsolve.py:217 +#: ../pakfire/depsolve.py:220 msgid "Repository" msgstr "" -#: ../pakfire/depsolve.py:217 ../pakfire/packages/base.py:58 +#: ../pakfire/depsolve.py:220 ../pakfire/packages/base.py:58 msgid "Size" msgstr "" -#: ../pakfire/depsolve.py:220 +#: ../pakfire/depsolve.py:223 msgid "Installing:" msgstr "" -#: ../pakfire/depsolve.py:221 +#: ../pakfire/depsolve.py:224 msgid "Installing for dependencies:" msgstr "" -#: ../pakfire/depsolve.py:222 +#: ../pakfire/depsolve.py:225 msgid "Updating:" msgstr "" -#: ../pakfire/depsolve.py:223 +#: ../pakfire/depsolve.py:226 msgid "Updating for dependencies:" msgstr "" -#: ../pakfire/depsolve.py:224 +#: ../pakfire/depsolve.py:227 msgid "Removing:" msgstr "" -#: ../pakfire/depsolve.py:225 +#: ../pakfire/depsolve.py:228 msgid "Removing for dependencies:" msgstr "" -#: ../pakfire/depsolve.py:227 +#: ../pakfire/depsolve.py:230 msgid "Transaction Summary" msgstr "" -#: ../pakfire/depsolve.py:233 +#: ../pakfire/depsolve.py:236 msgid "Install" msgstr "" -#: ../pakfire/depsolve.py:234 ../pakfire/depsolve.py:238 -#: ../pakfire/depsolve.py:242 +#: ../pakfire/depsolve.py:237 ../pakfire/depsolve.py:241 +#: ../pakfire/depsolve.py:245 msgid "Package(s)" msgstr "" -#: ../pakfire/depsolve.py:237 +#: ../pakfire/depsolve.py:240 msgid "Updates" msgstr "" -#: ../pakfire/depsolve.py:241 +#: ../pakfire/depsolve.py:244 msgid "Remove" msgstr "" -#: ../pakfire/depsolve.py:248 +#: ../pakfire/depsolve.py:251 #, python-format msgid "Total download size: %s" msgstr "" -#: ../pakfire/__init__.py:191 +#: ../pakfire/__init__.py:203 msgid "Is this okay?" msgstr "" -- 2.39.5