From e0b99370cccbc9e2af7c05133cdb94a57c3a633b Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sat, 30 Apr 2011 13:01:59 +0000 Subject: [PATCH] Make localinstall command work again. --- pakfire/api.py | 5 +++++ pakfire/base.py | 39 ++++++++++++++++++++++++++++++++++++++ pakfire/cli.py | 16 +++------------- po/pakfire.pot | 50 ++++++++++++++++++++++++------------------------- 4 files changed, 72 insertions(+), 38 deletions(-) diff --git a/pakfire/api.py b/pakfire/api.py index 6757e52f6..940de91fe 100644 --- a/pakfire/api.py +++ b/pakfire/api.py @@ -11,6 +11,11 @@ def install(requires, **pakfire_args): return pakfire.install(requires) +def localinstall(files, **pakfire_args): + pakfire = Pakfire(**pakfire_args) + + return pakfire.localinstall(files) + def remove(**pakfire_args): pass diff --git a/pakfire/base.py b/pakfire/base.py index cc8d66c1f..5ea411150 100644 --- a/pakfire/base.py +++ b/pakfire/base.py @@ -98,6 +98,45 @@ class Pakfire(object): t.run() + def localinstall(self, files): + repo_name = "localinstall" + + # Create a new repository that holds all packages we passed on + # the commandline. + repo = self.solver.pool.create_repo(repo_name) + + # Open all passed files and try to open them. + for file in files: + pkg = packages.open(self, None, file) + + if not isinstance(pkg, packages.BinaryPackage): + logging.warning("Skipping package which is a wrong format: %s" % file) + continue + + # Add the package information to the solver. + self.solver.add_package(pkg, repo_name) + + # Break if no packages were added at all. + if not repo.size(): + logging.critical("There are no packages to install.") + return + + # Create a new request which contains all solvabled from the CLI and + # try to solve it. + request = self.solver.create_request() + for solvable in repo: + print solvable + request.install(solvable) + + t = self.solver.solve(request) + + # If solving was not possible, we exit here. + if not t: + return + + # Otherwise we run the transcation. + t.run() + def update(self, pkgs): # XXX needs to be done pass diff --git a/pakfire/cli.py b/pakfire/cli.py index a7f8d7e76..8de62a3c6 100644 --- a/pakfire/cli.py +++ b/pakfire/cli.py @@ -191,21 +191,11 @@ class Cli(object): def handle_update(self): pakfire.update(self.args.package, **self.pakfire_args) - def handle_install(self, local=False): - if local: - repo = repository.FileSystemRepository(self.pakfire) - - pkgs = [] - for pkg in self.args.package: - if local and os.path.exists(pkg): - pkg = packages.BinaryPackage(self.pakfire, repo, pkg) - - pkgs.append(pkg) - - pakfire.install(pkgs, **self.pakfire_args) + def handle_install(self): + pakfire.install(self.args.package, **self.pakfire_args) def handle_localinstall(self): - return self.handle_install(local=True, **self.pakfire_args) + pakfire.localinstall(self.args.package, **self.pakfire_args) def handle_provides(self): pkgs = pakfire.provides(self.args.pattern, **self.pakfire_args) diff --git a/po/pakfire.pot b/po/pakfire.pot index a2bb874fe..7e8fcb855 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-04-29 21:17+0200\n" +"POT-Creation-Date: 2011-04-30 12:49+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -114,7 +114,7 @@ msgstr "" msgid "Package" msgstr "" -#: ../pakfire/repository/transaction.py:278 ../pakfire/cli.py:237 +#: ../pakfire/repository/transaction.py:278 ../pakfire/cli.py:227 msgid "Repository" msgstr "" @@ -264,94 +264,94 @@ msgstr "" msgid "List all currently enabled repositories." msgstr "" -#: ../pakfire/cli.py:237 +#: ../pakfire/cli.py:227 msgid "Enabled" msgstr "" -#: ../pakfire/cli.py:237 +#: ../pakfire/cli.py:227 msgid "Priority" msgstr "" -#: ../pakfire/cli.py:252 +#: ../pakfire/cli.py:242 msgid "Pakfire builder command line interface." msgstr "" -#: ../pakfire/cli.py:294 +#: ../pakfire/cli.py:284 msgid "Update the package indexes." msgstr "" -#: ../pakfire/cli.py:300 +#: ../pakfire/cli.py:290 msgid "Build one or more packages." msgstr "" -#: ../pakfire/cli.py:302 +#: ../pakfire/cli.py:292 msgid "Give name of at least one package to build." msgstr "" -#: ../pakfire/cli.py:306 +#: ../pakfire/cli.py:296 msgid "Build the package for the given architecture." msgstr "" -#: ../pakfire/cli.py:308 ../pakfire/cli.py:330 +#: ../pakfire/cli.py:298 ../pakfire/cli.py:320 msgid "Path were the output files should be copied to." msgstr "" -#: ../pakfire/cli.py:313 +#: ../pakfire/cli.py:303 msgid "Go into a shell." msgstr "" -#: ../pakfire/cli.py:315 +#: ../pakfire/cli.py:305 msgid "Give name of a package." msgstr "" -#: ../pakfire/cli.py:319 +#: ../pakfire/cli.py:309 msgid "Emulated architecture in the shell." msgstr "" -#: ../pakfire/cli.py:324 +#: ../pakfire/cli.py:314 msgid "Generate a source package." msgstr "" -#: ../pakfire/cli.py:326 +#: ../pakfire/cli.py:316 msgid "Give name(s) of a package(s)." msgstr "" -#: ../pakfire/cli.py:395 +#: ../pakfire/cli.py:385 msgid "Pakfire repo command line interface." msgstr "" -#: ../pakfire/cli.py:414 +#: ../pakfire/cli.py:404 msgid "Repository management commands." msgstr "" -#: ../pakfire/cli.py:422 +#: ../pakfire/cli.py:412 msgid "Create a new repository index." msgstr "" -#: ../pakfire/cli.py:423 +#: ../pakfire/cli.py:413 msgid "Path to the packages." msgstr "" -#: ../pakfire/cli.py:424 +#: ../pakfire/cli.py:414 msgid "Path to input packages." msgstr "" -#: ../pakfire/cli.py:436 +#: ../pakfire/cli.py:426 msgid "Pakfire master command line interface." msgstr "" -#: ../pakfire/cli.py:458 +#: ../pakfire/cli.py:448 msgid "Update the sources." msgstr "" -#: ../pakfire/cli.py:468 +#: ../pakfire/cli.py:458 msgid "Pakfire slave command line interface." msgstr "" -#: ../pakfire/cli.py:492 +#: ../pakfire/cli.py:482 msgid "Request a build job from the server." msgstr "" -#: ../pakfire/cli.py:498 +#: ../pakfire/cli.py:488 msgid "Send a keepalive to the server." msgstr "" -- 2.39.5