From 022c792a00279c2472aa008d54174f91648fe02f Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sun, 31 Jul 2011 15:12:59 +0000 Subject: [PATCH] Fix localinstall. There have been several issues when installing packages from the filesystem. We are now creating a temporary repository, add all packages to the repository index and install from that. Finally, the temporary repository is removed. --- pakfire/base.py | 55 +++++++++++++++++++++---------------- pakfire/packages/solv.py | 10 +++++-- pakfire/repository/local.py | 5 ++++ pakfire/transaction.py | 2 +- po/pakfire.pot | 20 ++++++++------ 5 files changed, 58 insertions(+), 34 deletions(-) diff --git a/pakfire/base.py b/pakfire/base.py index 40b37e16..034e4248 100644 --- a/pakfire/base.py +++ b/pakfire/base.py @@ -161,36 +161,45 @@ class Pakfire(object): # Create a new repository that holds all packages we passed on # the commandline. - repo = repository.RepositoryDir(self, repo_name, repo_desc, ".") + repo = repository.RepositoryDir(self, repo_name, repo_desc, + os.path.join(LOCAL_TMP_PATH, "repo_%s" % util.random_string())) - # Add all packages to the repository index. - for file in files: - repo.collect_packages(file) + # Register the repository. + self.repos.add_repo(repo) - # Break if no packages were added at all. - if not len(repo): - logging.critical("There are no packages to install.") - return + try: + # Add all packages to the repository index. + for file in files: + repo.collect_packages(file) - # 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) + # Break if no packages were added at all. + if not len(repo): + logging.critical(_("There are no packages to install.")) + return - solver = self.create_solver() - t = solver.solve(request) + # 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) - # If solving was not possible, we exit here. - if not t: - return + solver = self.create_solver() + t = solver.solve(request) - # Ask the user if this is okay. - if not t.cli_yesno(): - return + # If solving was not possible, we exit here. + if not t: + return - # If okay, run the transcation. - t.run() + # Ask the user if this is okay. + if not t.cli_yesno(): + return + + # If okay, run the transcation. + t.run() + + finally: + # Remove the temporary copy of the repository we have created earlier. + repo.remove() def update(self, pkgs): request = self.create_request() diff --git a/pakfire/packages/solv.py b/pakfire/packages/solv.py index 3020fc6c..2cfe57aa 100644 --- a/pakfire/packages/solv.py +++ b/pakfire/packages/solv.py @@ -169,8 +169,14 @@ class SolvPackage(base.Package): path = None if self.repo.local: - path = os.path.join(self.repo.path, self.arch, self.filename) - return binary.BinaryPackage(self.pakfire, self.repo, path) + # Search for a file in the local repository. It can be either in + # the root directory of the repository or in a subdirectory that + # is named by the architecture. + for i in ("", self.arch,): + path = os.path.join(self.repo.path, i, self.filename) + + if os.path.exists(path): + return binary.BinaryPackage(self.pakfire, self.repo, path) else: filename = "packages/%s" % self.filename diff --git a/pakfire/repository/local.py b/pakfire/repository/local.py index be4cd99f..ddfb7d8a 100644 --- a/pakfire/repository/local.py +++ b/pakfire/repository/local.py @@ -39,6 +39,11 @@ class RepositoryDir(base.RepositoryFactory): """ return 10 + @property + def local(self): + # Yes, this is local. + return True + def collect_packages(self, *args, **kwargs): """ Proxy function to add packages to the index. diff --git a/pakfire/transaction.py b/pakfire/transaction.py index d2bbb169..94e92d1a 100644 --- a/pakfire/transaction.py +++ b/pakfire/transaction.py @@ -13,7 +13,7 @@ import util from constants import * from i18n import _ -PKG_DUMP_FORMAT = " %-21s %-8s %-21s %-19s %5s " +PKG_DUMP_FORMAT = " %-21s %-8s %-21s %-18s %6s " # Import all actions directly. from actions import * diff --git a/po/pakfire.pot b/po/pakfire.pot index 88c92272..19b689f5 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-31 13:37+0200\n" +"POT-Creation-Date: 2011-07-31 15:12+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -33,6 +33,10 @@ msgstr "" msgid "Downgrading" msgstr "" +#: ../pakfire/base.py:177 +msgid "There are no packages to install." +msgstr "" + #: ../pakfire/builder.py:259 #, python-format msgid "Extracting: %s (source)" @@ -350,33 +354,33 @@ msgstr "" msgid "Loading installed packages" msgstr "" -#: ../pakfire/satsolver.py:110 +#: ../pakfire/satsolver.py:113 msgid "The solver returned one problem:" msgstr "" #. Ask the user if he or she want to modify the request. If not, just exit. -#: ../pakfire/satsolver.py:126 +#: ../pakfire/satsolver.py:129 msgid "Do you want to manually alter the request?" msgstr "" -#: ../pakfire/satsolver.py:129 +#: ../pakfire/satsolver.py:132 msgid "You can now try to satisfy the solver by modifying your request." msgstr "" -#: ../pakfire/satsolver.py:134 +#: ../pakfire/satsolver.py:137 msgid "Which problem to you want to resolve?" msgstr "" -#: ../pakfire/satsolver.py:136 +#: ../pakfire/satsolver.py:139 msgid "Press enter to try to re-solve the request." msgstr "" -#: ../pakfire/satsolver.py:167 +#: ../pakfire/satsolver.py:170 #, python-format msgid " Solution: %s" msgstr "" -#: ../pakfire/satsolver.py:176 +#: ../pakfire/satsolver.py:179 msgid " Solutions:" msgstr "" -- 2.39.2