]> code.ossystems Code Review - openembedded-core.git/commitdiff
package_rpm.bbclass: support packaging of symlinks to directories
authorPatrick Ohly <patrick.ohly@intel.com>
Wed, 25 Feb 2015 14:53:29 +0000 (06:53 -0800)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 27 Feb 2015 07:39:31 +0000 (07:39 +0000)
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@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes/package_rpm.bbclass

index b87e634f1b04e8c374c8e152955bd02845ace50a..e305e8b4ab931025d8724d4c559d16f172a53f4a 100644 (file)
@@ -197,6 +197,16 @@ python write_specfile () {
             if path.endswith("DEBIAN") or path.endswith("CONTROL"):
                 continue
 
+            # Treat all symlinks to directories as normal files.
+            # os.walk() lists them as directories.
+            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
             # directories