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
This commit is contained in:
Jeffrey Townsend
2018-08-08 01:09:41 +00:00
parent a2901b27bf
commit 062b6fc1bf

View File

@@ -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)
#