[OE-core] [PATCH v2] package_rpm.bbclass: support packaging of symlinks to directories

Patrick Ohly patrick.ohly at intel.com
Wed Feb 25 14:51:15 UTC 2015


os.walk() returns symlinks to directories in the "dirs" lists, but then never
enters them by default. As a result, the old code applied neither the
directory handling (because that is active once a directory gets entered) nor
the file handling, and thus never packaged such symlinks.

The fix is simple: find such special directory entries and move them to the
"files" list. However, one has to be careful about the undefined behavior of
modifying a list while iterating over it.

This fix was required for packaging a modified base-files that created
symlinks into /usr for /sbin /lib and /sbin.

Signed-off-by: Patrick Ohly <patrick.ohly at intel.com>
---
 meta/classes/package_rpm.bbclass | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/meta/classes/package_rpm.bbclass b/meta/classes/package_rpm.bbclass
index 4f9f813..e305e8b 100644
--- a/meta/classes/package_rpm.bbclass
+++ b/meta/classes/package_rpm.bbclass
@@ -199,10 +199,13 @@ python write_specfile () {
 
             # Treat all symlinks to directories as normal files.
             # os.walk() lists them as directories.
-            for i, entry in enumerate(dirs):
-                if os.path.islink(os.path.join(rootpath, entry)):
-                    del dirs[i]
-                    files.append(entry)
+            def move_to_files(dir):
+                if os.path.islink(os.path.join(rootpath, dir)):
+                    files.append(dir)
+                    return True
+                else:
+                    return False
+            dirs[:] = [dir for dir in dirs if not move_to_files(dir)]
 
             # Directory handling can happen in two ways, either DIRFILES is not set at all
             # in which case we fall back to the older behaviour of packages owning all their
-- 
1.8.4.5




More information about the Openembedded-core mailing list