diff mbox series

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

Message ID 20231220180102.3501941-1-JPEWhacker@gmail.com
State Accepted, archived
Commit 3eeec7f3412e881e51763ef947c82772d3858f09
Headers show
Series [1/2] lib/oe/path.py: Add relsymlink() | expand

Commit Message

Joshua Watt Dec. 20, 2023, 6:01 p.m. UTC
Adds API to make a relative symbolic link between two directories. The
arguments are the same as oe.path.symlink()

Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
---
 meta/lib/oe/path.py | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/meta/lib/oe/path.py b/meta/lib/oe/path.py
index e2f1913a35c..5d21cdcbdff 100644
--- a/meta/lib/oe/path.py
+++ b/meta/lib/oe/path.py
@@ -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. """