summaryrefslogtreecommitdiffstats
path: root/scripts
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:58:45 +0000
commit1412dda5609a544d46f4b67bd3a27bbe2c7f4fea (patch)
tree17c5648d1e9ac92b683f1f69b221a6045372ac31 /scripts
parenta8dc6aed550f18c290adbc83b64bff009a9ca5e3 (diff)
downloadpoky-1412dda5609a544d46f4b67bd3a27bbe2c7f4fea.tar.gz
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). (From OE-Core rev: 6ae3b85eaffd1b0b6914422e8de7c1230723157d) Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-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 @@
1#! /usr/bin/env python
2
3# Create a *relative* symlink, just like ln --relative does but without needing
4# coreutils 8.16.
5
6import sys, os
7
8if len(sys.argv) != 3:
9 print "$ lnr TARGET LINK_NAME"
10 sys.exit(1)
11
12target = sys.argv[1]
13linkname = sys.argv[2]
14
15if os.path.isabs(target):
16 if not os.path.isabs(linkname):
17 linkname = os.path.abspath(linkname)
18 start = os.path.dirname(linkname)
19 target = os.path.relpath(target, start)
20
21os.symlink(target, linkname)