Skip to contentSkip to conversation

lib/oe/path.py: Add relsymlink()

PATCH New Joshua Watt 1 participant 2 messages Dec 20, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 lib/oe/path.py: Add relsymlink()

Adds API to make a relative symbolic link between two directories. The arguments are the same as oe.path.symlink()

---
 meta/lib/oe/path.py | 3 +++
 1 file changed, 3 insertions(+)
meta/lib/oe/path.py +3 -0
index e2f1913a35c..5d21cdcbdff 100644
@@ -172,6 +172,9 @@ def symlink(source, destination, force=False):
         if e.errno != errno.EEXIST or os.readlink(destination) != source:
             raise
 
+def relsymlink(target, name, force=False):
+    symlink(os.path.relpath(target, os.path.dirname(name)), name, force=force)
+
 def find(dir, **walkoptions):
     """ Given a directory, recurses into that directory,
     returning all files as absolute paths. """
Signature · 1 line
2.34.1
#1 lore raw

PATCH 2/2 lib/packagedata.py: Fix broken symlinks for providers with a '/'

If a package had a provider with a '/' in it (e.g. "/bin/sh", "/bin/bash", etc.), the generated symlinks were broken due to being at a hard coded depth. Use oe.path.relsymlink() instead to make a correct relative symbolic link

---
 meta/lib/oe/packagedata.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
meta/lib/oe/packagedata.py +2 -2
index 162ff60d72f..d59f6f5a569 100644
@@ -317,7 +317,7 @@ fi
             for p in bb.utils.explode_deps(rprov):
                 subdata_sym = pkgdatadir + "/runtime-rprovides/%s/%s" % (p, pkg)
                 bb.utils.mkdirhier(os.path.dirname(subdata_sym))
-                oe.path.symlink("../../runtime/%s" % pkg, subdata_sym, True)
+                oe.path.relsymlink(subdata_file, subdata_sym, True)
 
         allow_empty = d.getVar('ALLOW_EMPTY:%s' % pkg)
         if not allow_empty:
@@ -328,7 +328,7 @@ fi
         if g or allow_empty == "1":
             # Symlinks needed for reverse lookups (from the final package name)
             subdata_sym = pkgdatadir + "/runtime-reverse/%s" % pkgval
-            oe.path.symlink("../runtime/%s" % pkg, subdata_sym, True)
+            oe.path.relsymlink(subdata_file, subdata_sym, True)
 
             packagedfile = pkgdatadir + '/runtime/%s.packaged' % pkg
             open(packagedfile, 'w').close()
Signature · 1 line
2.34.1