[OE-core] [PATCH] package_rpm: only claim ownership of empty directories
Ross Burton
ross.burton at intel.com
Tue Jul 22 15:05:13 UTC 2014
Previous every package claimed ownership via %dir of every directory, which lead
to e.g. every package claiming to own /usr. This destroys the concept of
directory ownership, so instead only use %dir to ensure empty directories are
packaged.
Signed-off-by: Ross Burton <ross.burton at intel.com>
---
meta/classes/package_rpm.bbclass | 45 +++++++++++++++++++++-----------------
1 file changed, 25 insertions(+), 20 deletions(-)
diff --git a/meta/classes/package_rpm.bbclass b/meta/classes/package_rpm.bbclass
index 0a32b3e..9e6b103 100644
--- a/meta/classes/package_rpm.bbclass
+++ b/meta/classes/package_rpm.bbclass
@@ -186,28 +186,33 @@ python write_specfile () {
array.append("%s: %s" % (tag, dep))
def walk_files(walkpath, target, conffiles):
- # We can race against the ipk/deb backends which create CONTROL or DEBIAN directories
- # when packaging. We just ignore these files which are created in
- # packages-split/ and not package/
- # We have the odd situation where the CONTROL/DEBIAN directory can be removed in the middle of
- # of the walk, the isdir() test would then fail and the walk code would assume its a file
- # hence we check for the names in files too.
for rootpath, dirs, files in os.walk(walkpath):
- path = rootpath.replace(walkpath, "")
- if path.endswith("DEBIAN") or path.endswith("CONTROL"):
- continue
- for dir in dirs:
- if dir == "CONTROL" or dir == "DEBIAN":
- continue
- # All packages own the directories their files are in...
- target.append('%dir "' + path + '/' + dir + '"')
- for file in files:
- if file == "CONTROL" or file == "DEBIAN":
- continue
- if conffiles.count(path + '/' + file):
- target.append('%config "' + path + '/' + file + '"')
+ # Ignore the CONTROL and DEBIAN directories, created by ipkg and
+ # dpkg during packaging. As they can be removed while this is
+ # running (and so the isdir() test fails) ignore both files and
+ # directories.
+ for n in ("CONTROL", "DEBIAN"):
+ try:
+ dirs.remove(n)
+ files.remove(n)
+ except ValueError:
+ pass
+
+ # When rootpath is walkpath the replace will return "" so handle
+ # that and set path to /.
+ path = rootpath.replace(walkpath, "") or "/"
+
+ # Packages own only empty directories, but handle / specially as we
+ # don't want empty packages to contain a %dir / entry.
+ if (path != '/' and not files and not dirs):
+ target.append('%dir "' + path + '"')
+
+ for f in files:
+ f = os.path.join(path, f)
+ if f in conffiles:
+ target.append('%config "' + f + '"')
else:
- target.append('"' + path + '/' + file + '"')
+ target.append('"' + f + '"')
# Prevent the prerm/postrm scripts from being run during an upgrade
def wrap_uninstall(scriptvar):
--
1.7.10.4
More information about the Openembedded-core
mailing list