From d0403e48ee4c53416bdcfd2a632f0d7c3f52ac0f Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Thu, 2 Oct 2014 10:57:11 -0700 Subject: [PATCH] FEATURES=case-insensitive-fs for bug #524236 When case-insensitive-fs is enabled in FEATURES, the dblink.isowner method and the _owners_db class will be case-insensitive. This causes the collision-protect and unmerge code to behave correctly for a case-insensitive file system. If the file system is case-insensitive but case-preserving, then case is preserved in the CONTENTS data of installed packages. X-Gentoo-Bug: 524236 X-Gentoo-Url: https://bugs.gentoo.org/show_bug.cgi?id=524236 --- man/make.conf.5 | 4 ++++ pym/portage/const.py | 1 + pym/portage/dbapi/vartree.py | 22 ++++++++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/man/make.conf.5 b/man/make.conf.5 index 84e894b..7b7daa4 100644 --- a/man/make.conf.5 +++ b/man/make.conf.5 @@ -265,6 +265,10 @@ Build binary packages for just packages in the system set. Enable a special progress indicator when \fBemerge\fR(1) is calculating dependencies. .TP +.B case\-insensitive\-fs +Use case\-insensitive file name comparisions when merging and unmerging +files. +.TP .B ccache Enable portage support for the ccache package. If the ccache dir is not present in the user's environment, then portage will default to diff --git a/pym/portage/const.py b/pym/portage/const.py index acb90f9..5545a84 100644 --- a/pym/portage/const.py +++ b/pym/portage/const.py @@ -125,6 +125,7 @@ SUPPORTED_FEATURES = frozenset([ "buildpkg", "buildsyspkg", "candy", + "case-insensitive-fs", "ccache", "cgroup", "chflags", diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index b46ba0b..e232fc7 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -1052,6 +1052,11 @@ class vardbapi(dbapi): def add(self, cpv): eroot_len = len(self._vardb._eroot) contents = self._vardb._dblink(cpv).getcontents() + + if "case-insensitive-fs" in self._vardb.settings.features: + contents = dict((k.lower(), v) + for k, v in contents.items()) + pkg_hash = self._hash_pkg(cpv) if not contents: # Empty path is a code used to represent empty contents. @@ -1189,6 +1194,8 @@ class vardbapi(dbapi): hash_pkg = owners_cache._hash_pkg hash_str = owners_cache._hash_str base_names = self._vardb._aux_cache["owners"]["base_names"] + case_insensitive = "case-insensitive-fs" \ + in vardb.settings.features dblink_cache = {} @@ -1205,6 +1212,8 @@ class vardbapi(dbapi): while path_iter: path = path_iter.pop() + if case_insensitive: + path = path.lower() is_basename = os.sep != path[:1] if is_basename: name = path @@ -1236,6 +1245,8 @@ class vardbapi(dbapi): if is_basename: for p in dblink(cpv).getcontents(): + if case_insensitive: + p = p.lower() if os.path.basename(p) == name: owners.append((cpv, p[len(root):])) else: @@ -1265,8 +1276,12 @@ class vardbapi(dbapi): if not path_list: return + case_insensitive = "case-insensitive-fs" \ + in self._vardb.settings.features path_info_list = [] for path in path_list: + if case_insensitive: + path = path.lower() is_basename = os.sep != path[:1] if is_basename: name = path @@ -1285,6 +1300,8 @@ class vardbapi(dbapi): for path, name, is_basename in path_info_list: if is_basename: for p in dblnk.getcontents(): + if case_insensitive: + p = p.lower() if os.path.basename(p) == name: search_pkg.results.append((dblnk, p[len(root):])) else: @@ -2762,6 +2779,11 @@ class dblink(object): filename.lstrip(os_filename_arg.path.sep))) pkgfiles = self.getcontents() + + if "case-insensitive-fs" in self.settings.features: + destfile = destfile.lower() + pkgfiles = dict((k.lower(), v) for k, v in pkgfiles.items()) + if pkgfiles and destfile in pkgfiles: return destfile if pkgfiles: -- 1.8.5.5