misc (install): use os.symlink instead of distutils.file_util.copy_file to avoid error when --root is used

This commit is contained in:
Goffi 2014-09-03 17:18:27 +02:00
commit 2507eea6a5

View file

@ -121,13 +121,20 @@ class CustomInstall(install):
"""Create symbolic links to executables"""
# the script which launch the daemon
for source, dest in self.sh_script_links:
if os.path.islink(dest) and os.readlink(dest) != source:
os.remove(dest) # copy_file doesn't force the link update
dest_name, copied = copy_file(source, dest, link='sym')
assert copied
# we change the perm in the same way as in the original install_scripts
mode = ((os.stat(dest_name)[ST_MODE]) | 0555) & 07777
os.chmod(dest_name, mode)
if self.root is None:
if os.path.islink(dest) and os.readlink(dest) != source:
os.remove(dest) # copy_file doesn't force the link update
dest_name, copied = copy_file(source, dest, link='sym')
assert copied
# we change the perm in the same way as in the original install_scripts
mode = ((os.stat(dest_name)[ST_MODE]) | 0555) & 07777
os.chmod(dest_name, mode)
else:
# if root is not None, source probably doesn't exist yet
# this is not managed by copy_file, so we must use os.symlink directly
if os.path.islink(dest):
os.remove(dest) # symlink doesn't force the link update
os.symlink(source, dest)
def run(self):
ignore_idx = 0 if self.root is None else len(self.root)