From 062b6fc1bfb05890867af0d07d821e2044ccaeb0 Mon Sep 17 00:00:00 2001 From: Jeffrey Townsend Date: Wed, 8 Aug 2018 01:09:41 +0000 Subject: [PATCH] Fix symbolic link handling in the 'links' package section. The 'links' section specifies symbolic links which should be added to the package in key : value format. The key is the source of the link. It must be exist in the filesystem already (as part of the 'files' section) and be relative to the root of the filesystem. The value is the name of the link, and can be relative or absolute to the final filesystem. For example, given that a package produces the real binary "/usr/bin/foobar" and you want /usr/bin/foobar-link -> /usr/bin/foobar it will be specified as follows: links: /usr/bin/foobar : /usr/bin/foobar-link --- tools/onlpm.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/onlpm.py b/tools/onlpm.py index 3d89e6d9..4701daed 100755 --- a/tools/onlpm.py +++ b/tools/onlpm.py @@ -362,9 +362,14 @@ class OnlPackage(object): if os.path.exists(src): OnlPackage.copyf(src, dst, root) - for (link,src) in self.pkg.get('links', {}).iteritems(): + for (link, src) in self.pkg.get('links', {}).iteritems(): logger.info("Linking %s -> %s..." % (link, src)) - link = os.path.join(root, link) + # The source must be relative to the existing root directory. + if link.startswith('/'): + link = "%s%s" % (root, link) + else: + link = "%s/%s" % (root, link) + # The link must be relative or absolute to the final filesystem. os.symlink(src, link) #