From de7fba8f73cc61de34c5cf83cec7e9d54fc24a36 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Fri, 29 Jul 2011 19:01:57 +0000 Subject: [PATCH] Implement "localinstall" command. --- pakfire/base.py | 31 +++++++++++---------------- pakfire/repository/index.py | 18 +++++++++------- po/pakfire.pot | 42 ++++++++++++++++--------------------- 3 files changed, 41 insertions(+), 50 deletions(-) diff --git a/pakfire/base.py b/pakfire/base.py index 97c4f29e7..e9544771e 100644 --- a/pakfire/base.py +++ b/pakfire/base.py @@ -153,33 +153,26 @@ class Pakfire(object): t.run() def localinstall(self, files): - repo_name = "localinstall" + repo_name = repo_desc = "localinstall" # Create a new repository that holds all packages we passed on # the commandline. - repo = self.solver.pool.create_repo(repo_name) + repo = repository.RepositoryDir(self, repo_name, repo_desc, ".") - # Open all passed files and try to open them. + # Add all packages to the repository index. 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) + repo.collect_packages(file) # Break if no packages were added at all. - if not repo.size(): + if not len(repo): 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: - request.install(solvable) + # Create a new request that installs all solvables from the + # repository. + request = self.create_request() + for solv in [p.solvable for p in repo]: + request.install(solv) solver = self.create_solver() t = solver.solve(request) @@ -189,8 +182,8 @@ class Pakfire(object): return # Ask the user if this is okay. - #if not t.cli_yesno(): - # return + if not t.cli_yesno(): + return # If okay, run the transcation. t.run() diff --git a/pakfire/repository/index.py b/pakfire/repository/index.py index cf6d6676c..57eab3802 100644 --- a/pakfire/repository/index.py +++ b/pakfire/repository/index.py @@ -295,14 +295,18 @@ class IndexDir(Index): # Get a filelist of all files that could possibly be packages. files = [] - for dir, subdirs, _files in os.walk(path): - for file in sorted(_files): - # Skip files that do not have the right extension - if not file.endswith(".%s" % PACKAGE_EXTENSION): - continue - file = os.path.join(dir, file) - files.append(file) + if os.path.isdir(path): + for dir, subdirs, _files in os.walk(path): + for file in sorted(_files): + # Skip files that do not have the right extension + if not file.endswith(".%s" % PACKAGE_EXTENSION): + continue + + file = os.path.join(dir, file) + files.append(file) + elif os.path.isfile(path) and path.endswith(".%s" % PACKAGE_EXTENSION): + files.append(path) if not files: return pkgs diff --git a/po/pakfire.pot b/po/pakfire.pot index 389d63ad3..c120265b4 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-07-29 17:32+0200\n" +"POT-Creation-Date: 2011-07-29 18:51+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -187,11 +187,11 @@ msgstr "" msgid "Build the package for the given architecture." msgstr "" -#: ../pakfire/cli.py:318 ../pakfire/cli.py:344 +#: ../pakfire/cli.py:318 ../pakfire/cli.py:342 msgid "Path were the output files should be copied to." msgstr "" -#: ../pakfire/cli.py:320 ../pakfire/cli.py:333 +#: ../pakfire/cli.py:320 msgid "Mode to run in. Is either 'release' or 'development' (default)." msgstr "" @@ -207,55 +207,55 @@ msgstr "" msgid "Emulated architecture in the shell." msgstr "" -#: ../pakfire/cli.py:338 +#: ../pakfire/cli.py:336 msgid "Generate a source package." msgstr "" -#: ../pakfire/cli.py:340 +#: ../pakfire/cli.py:338 msgid "Give name(s) of a package(s)." msgstr "" -#: ../pakfire/cli.py:416 +#: ../pakfire/cli.py:413 msgid "Pakfire repo command line interface." msgstr "" -#: ../pakfire/cli.py:441 +#: ../pakfire/cli.py:438 msgid "Repository management commands." msgstr "" -#: ../pakfire/cli.py:449 +#: ../pakfire/cli.py:446 msgid "Create a new repository index." msgstr "" -#: ../pakfire/cli.py:450 +#: ../pakfire/cli.py:447 msgid "Path to the packages." msgstr "" -#: ../pakfire/cli.py:451 +#: ../pakfire/cli.py:448 msgid "Path to input packages." msgstr "" -#: ../pakfire/cli.py:463 +#: ../pakfire/cli.py:460 msgid "Pakfire master command line interface." msgstr "" -#: ../pakfire/cli.py:491 +#: ../pakfire/cli.py:488 msgid "Update the sources." msgstr "" -#: ../pakfire/cli.py:501 +#: ../pakfire/cli.py:498 msgid "Pakfire server command line interface." msgstr "" -#: ../pakfire/cli.py:533 +#: ../pakfire/cli.py:530 msgid "Request a build job from the server." msgstr "" -#: ../pakfire/cli.py:539 +#: ../pakfire/cli.py:536 msgid "Send a keepalive to the server." msgstr "" -#: ../pakfire/cli.py:546 +#: ../pakfire/cli.py:543 msgid "Update all repositories." msgstr "" @@ -333,13 +333,13 @@ msgid "%s: package database" msgstr "" #. Create progress bar. -#: ../pakfire/repository/index.py:311 +#: ../pakfire/repository/index.py:315 #, python-format msgid "Loading from %s" msgstr "" #. Add all packages from the database to the index. -#: ../pakfire/repository/index.py:364 +#: ../pakfire/repository/index.py:368 msgid "Loading installed packages" msgstr "" @@ -347,12 +347,6 @@ msgstr "" msgid "The solver returned one problem:" msgstr "" -#. Print information about the problem to the user. -#: ../pakfire/satsolver.py:118 -#, python-format -msgid " #%d: %s" -msgstr "" - #. Ask the user if he or she want to modify the request. If not, just exit. #: ../pakfire/satsolver.py:126 msgid "Do you want to manually alter the request?" -- 2.39.5