* [gentoo-portage-dev] [PATCH] egencache --update-pkg-desc-index: handle read-only repo (bug 549616)
@ 2015-05-16 20:59 Zac Medico
2015-05-16 22:31 ` Brian Dolbec
0 siblings, 1 reply; 2+ messages in thread
From: Zac Medico @ 2015-05-16 20:59 UTC (permalink / raw
To: gentoo-portage-dev; +Cc: Zac Medico
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
---
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)
--
2.3.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [gentoo-portage-dev] [PATCH] egencache --update-pkg-desc-index: handle read-only repo (bug 549616)
2015-05-16 20:59 [gentoo-portage-dev] [PATCH] egencache --update-pkg-desc-index: handle read-only repo (bug 549616) Zac Medico
@ 2015-05-16 22:31 ` Brian Dolbec
0 siblings, 0 replies; 2+ messages in thread
From: Brian Dolbec @ 2015-05-16 22:31 UTC (permalink / raw
To: gentoo-portage-dev
On Sat, 16 May 2015 13:59:14 -0700
Zac Medico <zmedico@gentoo.org> wrote:
> 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
> ---
> 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)
Yeah, looks good
--
Brian Dolbec <dolsen>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-05-16 22:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-16 20:59 [gentoo-portage-dev] [PATCH] egencache --update-pkg-desc-index: handle read-only repo (bug 549616) Zac Medico
2015-05-16 22:31 ` Brian Dolbec
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox