summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavier Jardón <jjardon@gnome.org>2015-04-29 22:52:43 +0100
committerBaserock Gerrit <gerrit@baserock.org>2015-04-30 17:15:46 +0000
commit703edae4dc4a284c5710ffa41ed79bd095af8b43 (patch)
tree8670e93d0a9c5db20ea001f542fd4594bd5ae407
parent7e475f6dc71ae5fb453d91db8cefbf731c9123d2 (diff)
downloaddefinitions-703edae4dc4a284c5710ffa41ed79bd095af8b43.tar.gz
install-files.configure: make possible to overwrite symlinks
os.symlink will fail if the origin file/link already exist Change-Id: I8175c8dce699e55c3e39e35dfd45c0c19b8bd96d
-rwxr-xr-xinstall-files.configure11
1 files changed, 10 insertions, 1 deletions
diff --git a/install-files.configure b/install-files.configure
index c2970243..341cce61 100755
--- a/install-files.configure
+++ b/install-files.configure
@@ -24,6 +24,7 @@ to install into the target system.
import cliapp
import os
+import errno
import re
import sys
import shlex
@@ -53,6 +54,14 @@ class InstallFilesConfigureExtension(cliapp.Application):
for entry in entries:
self.install_entry(entry, manifest_dir, target_root)
+ def force_symlink(self, source, link_name):
+ try:
+ os.symlink(source, link_name)
+ except OSError as e:
+ if e.errno == errno.EEXIST:
+ os.remove(link_name)
+ os.symlink(source, link_name)
+
def install_entry(self, entry, manifest_root, target_root):
m = re.match('(template )?(overwrite )?'
'([0-7]+) ([0-9]+) ([0-9]+) (\S+)', entry)
@@ -91,7 +100,7 @@ class InstallFilesConfigureExtension(cliapp.Application):
else:
linkdest = os.readlink(os.path.join(manifest_root,
'./' + path))
- os.symlink(linkdest, dest_path)
+ self.force_symlink(linkdest, dest_path)
os.lchown(dest_path, uid, gid)
elif stat.S_ISREG(mode):