summaryrefslogtreecommitdiffstats
path: root/scripts/lnr
diff options
context:
space:
mode:
authorRoss Burton <ross.burton@intel.com>2014-03-03 20:23:34 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-03-07 14:57:39 +0000
commit6ae3b85eaffd1b0b6914422e8de7c1230723157d (patch)
tree5ded2ecc5d4a9d25b0c25de37641314e3ac6c66c /scripts/lnr
parent9e28808a6d6f47dc10ad87b878c7e912c2bbe16f (diff)
downloadopenembedded-core-contrib-6ae3b85eaffd1b0b6914422e8de7c1230723157d.tar.gz
openembedded-core-contrib-6ae3b85eaffd1b0b6914422e8de7c1230723157d.tar.bz2
openembedded-core-contrib-6ae3b85eaffd1b0b6914422e8de7c1230723157d.zip
scripts: add lnr (link relative)
lnr is a simple script to generate relative symlinks from absolute paths, similar to "ln -r" but without requiring coreutils 8.16 (Ubuntu 12.04 and others currently ship 8.13). Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Saul Wold <sgw@linux.intel.com>
Diffstat (limited to 'scripts/lnr')
-rwxr-xr-xscripts/lnr21
1 files changed, 21 insertions, 0 deletions
diff --git a/scripts/lnr b/scripts/lnr
new file mode 100755
index 0000000000..9dacebe095
--- /dev/null
+++ b/scripts/lnr
@@ -0,0 +1,21 @@
+#! /usr/bin/env python
+
+# Create a *relative* symlink, just like ln --relative does but without needing
+# coreutils 8.16.
+
+import sys, os
+
+if len(sys.argv) != 3:
+ print "$ lnr TARGET LINK_NAME"
+ sys.exit(1)
+
+target = sys.argv[1]
+linkname = sys.argv[2]
+
+if os.path.isabs(target):
+ if not os.path.isabs(linkname):
+ linkname = os.path.abspath(linkname)
+ start = os.path.dirname(linkname)
+ target = os.path.relpath(target, start)
+
+os.symlink(target, linkname)