* [gentoo-portage-dev] [PATCH] CONFIG_PROTECT: handle non-existent files
@ 2014-10-25 1:09 Zac Medico
2014-10-27 7:55 ` Alexander Berntsen
0 siblings, 1 reply; 2+ messages in thread
From: Zac Medico @ 2014-10-25 1:09 UTC (permalink / raw
To: gentoo-portage-dev
This fixes the ConfigProtect class, etc-update, and dispatch-conf to
account for non-existent files (rather than directories) that are
listed directly in CONFIG_PROTECT. It has been valid to list files
directly in CONFIG_PROTECT since bug #14321. However, the support for
non-existent files added for bug #523684 did not include support for
non-existent files listed directly in CONFIG_PROTECT.
Fixes: 5f7b4865ecaf ("dblink.mergeme: implement bug #523684")
X-Gentoo-Bug: 523684
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=523684
---
bin/dispatch-conf | 10 ++++++----
bin/etc-update | 5 ++++-
pym/portage/util/__init__.py | 6 ++++--
3 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/bin/dispatch-conf b/bin/dispatch-conf
index fb0a8af..6d2ae94 100755
--- a/bin/dispatch-conf
+++ b/bin/dispatch-conf
@@ -116,13 +116,15 @@ class dispatch:
for path in config_paths:
path = portage.normalize_path(
os.path.join(config_root, path.lstrip(os.sep)))
- try:
- mymode = os.stat(path).st_mode
- except OSError:
+
+ # Protect files that don't exist (bug #523684). If the
+ # parent directory doesn't exist, we can safely skip it.
+ if not os.path.isdir(os.path.dirname(path)):
continue
+
basename = "*"
find_opts = "-name '.*' -type d -prune -o"
- if not stat.S_ISDIR(mymode):
+ if not os.path.isdir(path):
path, basename = os.path.split(path)
find_opts = "-maxdepth 1"
diff --git a/bin/etc-update b/bin/etc-update
index 1a99231..7ac6f0b 100755
--- a/bin/etc-update
+++ b/bin/etc-update
@@ -74,7 +74,10 @@ scan() {
path="${EROOT%/}${path}"
if [[ ! -d ${path} ]] ; then
- [[ ! -f ${path} ]] && continue
+ # Protect files that don't exist (bug #523684). If the
+ # parent directory doesn't exist, we can safely skip it.
+ path=${path%/}
+ [[ -d ${path%/*} ]] || continue
local my_basename="${path##*/}"
path="${path%/*}"
find_opts=( -maxdepth 1 -name "._cfg????_${my_basename}" )
diff --git a/pym/portage/util/__init__.py b/pym/portage/util/__init__.py
index 4105c19..fe79942 100644
--- a/pym/portage/util/__init__.py
+++ b/pym/portage/util/__init__.py
@@ -1572,12 +1572,14 @@ class ConfigProtect(object):
for x in self.protect_list:
ppath = normalize_path(
os.path.join(self.myroot, x.lstrip(os.path.sep)))
+ # Protect files that don't exist (bug #523684). If the
+ # parent directory doesn't exist, we can safely skip it.
+ if os.path.isdir(os.path.dirname(ppath)):
+ self.protect.append(ppath)
try:
if stat.S_ISDIR(os.stat(ppath).st_mode):
self._dirs.add(ppath)
- self.protect.append(ppath)
except OSError:
- # If it doesn't exist, there's no need to protect it.
pass
self.protectmask = []
--
2.0.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [gentoo-portage-dev] [PATCH] CONFIG_PROTECT: handle non-existent files
2014-10-25 1:09 [gentoo-portage-dev] [PATCH] CONFIG_PROTECT: handle non-existent files Zac Medico
@ 2014-10-27 7:55 ` Alexander Berntsen
0 siblings, 0 replies; 2+ messages in thread
From: Alexander Berntsen @ 2014-10-27 7:55 UTC (permalink / raw
To: gentoo-portage-dev
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
LGTM, Zac. Go ahead and push.
- --
Alexander
bernalex@gentoo.org
https://secure.plaimi.net/~alexander
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iF4EAREIAAYFAlRN+lcACgkQRtClrXBQc7X2JgD/TW1qvYbXw3Rv+2wqloFiyQ/B
oezRTpqmwNHBcTqhUDsA/0JxZlhZTWlqPiB8ezR1mTbB0ciX2DZBMFgY3R09nhRE
=8wlT
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-10-27 7:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-25 1:09 [gentoo-portage-dev] [PATCH] CONFIG_PROTECT: handle non-existent files Zac Medico
2014-10-27 7:55 ` Alexander Berntsen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox