Warn only if link target is not relative and outside of the install prefix (#15512)

This commit is contained in:
Patrick Gartung 2020-03-16 18:43:11 -05:00 committed by GitHub
parent c9a715b190
commit e48d24ee45
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -682,19 +682,18 @@ def relocate_links(linknames, old_layout_root, new_layout_root,
link_names = [os.path.join(new_install_prefix, linkname)
for linkname in linknames]
for link_name in link_names:
old_link_target = os.readlink(link_name)
old_link_target = re.sub(placeholder, old_layout_root, old_link_target)
if old_link_target.startswith(old_install_prefix):
link_target = os.readlink(link_name)
link_target = re.sub(placeholder, old_layout_root, link_target)
if link_target.startswith(old_install_prefix):
new_link_target = re.sub(
old_install_prefix, new_install_prefix, old_link_target)
old_install_prefix, new_install_prefix, link_target)
os.unlink(link_name)
os.symlink(new_link_target, link_name)
else:
msg = 'Old link target %s' % old_link_target
if (os.path.isabs(link_target) and
not link_target.startswith(new_install_prefix)):
msg = 'Link target %s' % link_target
msg += ' for symbolic link %s is outside' % link_name
msg += ' of the old install prefix %s.\n' % old_install_prefix
msg += 'This symbolic link will not be relocated'
msg += ' and might break relocation.'
msg += ' of the newinstall prefix %s.\n' % new_install_prefix
tty.warn(msg)