From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id AAF46138CCE for ; Sat, 16 May 2015 22:37:13 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 1ACA4E082D; Sat, 16 May 2015 22:37:12 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id B0C35E082D for ; Sat, 16 May 2015 22:37:11 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 9F507340FC5 for ; Sat, 16 May 2015 22:37:10 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 24E499AA for ; Sat, 16 May 2015 22:37:09 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <1431815762.28d5b7e78e0fdad2479685ec257ab5b858195007.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: bin/, pym/portage/repository/ X-VCS-Repository: proj/portage X-VCS-Files: bin/egencache pym/portage/repository/config.py X-VCS-Directories: bin/ pym/portage/repository/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 28d5b7e78e0fdad2479685ec257ab5b858195007 X-VCS-Branch: master Date: Sat, 16 May 2015 22:37:09 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: ac84d19e-569e-40b4-a0ae-61b6ebdbf8f5 X-Archives-Hash: 9f7c385d05431dd809fd03534ffbbdd7 commit: 28d5b7e78e0fdad2479685ec257ab5b858195007 Author: Zac Medico gentoo org> AuthorDate: Sat May 16 20:57:11 2015 +0000 Commit: Zac Medico gentoo org> CommitDate: Sat May 16 22:36:02 2015 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=28d5b7e7 egencache --update-pkg-desc-index: handle read-only repo (bug 549616) If the repo is read-only, write the cache to /var/cache/edb/dep where IndexedPortdb searches for it. X-Gentoo-Bug: 549616 X-Gentoo-Bug-url: https://bugs.gentoo.org/show_bug.cgi?id=549616 Acked-by: Brian Dolbec gentoo.org> bin/egencache | 17 ++++++++++++++++- pym/portage/repository/config.py | 12 ++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/bin/egencache b/bin/egencache index f97432f..6075ccf 100755 --- a/bin/egencache +++ b/bin/egencache @@ -1086,8 +1086,23 @@ def egencache_main(args): ret.append(scheduler.returncode) if options.update_pkg_desc_index: + if repo_config.writable: + writable_location = repo_config.location + else: + writable_location = os.path.join(portdb.depcachedir, + repo_config.location.lstrip(os.sep)) + msg = [ + "WARNING: Repository is not writable: %s" % ( + repo_config.location,), + " Using cache directory instead: %s" % ( + writable_location,) + ] + msg = "".join(line + '\n' for line in msg) + writemsg_level(msg, + level=logging.WARNING, noiselevel=-1) + gen_index = GenPkgDescIndex(portdb, os.path.join( - repo_config.location, "metadata", "pkg_desc_index")) + writable_location, "metadata", "pkg_desc_index")) gen_index.run() ret.append(gen_index.returncode) diff --git a/pym/portage/repository/config.py b/pym/portage/repository/config.py index e44b619..05eedbe 100644 --- a/pym/portage/repository/config.py +++ b/pym/portage/repository/config.py @@ -26,6 +26,7 @@ from portage.env.loaders import KeyValuePairFileLoader from portage.util import (normalize_path, read_corresponding_eapi_file, shlex_split, stack_lists, writemsg, writemsg_level, _recursive_file_list) from portage.util._path import exists_raise_eaccess, isdir_raise_eaccess +from portage.util.path import first_existing from portage.localization import _ from portage import _unicode_decode from portage import _unicode_encode @@ -346,6 +347,17 @@ class RepoConfig(object): if new_repo.name is not None: self.missing_repo_name = new_repo.missing_repo_name + @property + def writable(self): + """ + Check if self.location is writable, or permissions are sufficient + to create it if it does not exist yet. + @rtype: bool + @return: True if self.location is writable or can be created, + False otherwise + """ + return os.access(first_existing(self.location), os.W_OK) + @staticmethod def _read_valid_repo_name(repo_path): name, missing = RepoConfig._read_repo_name(repo_path)