From f54f3406308406a158737c468c5e61ddb1eb61a2 Mon Sep 17 00:00:00 2001 From: Martin André Date: Tue, 4 Jul 2017 15:31:35 +0200 Subject: Make set_configs.py work with symlinks Closes-Bug: #1702305 Change-Id: I92a404b8d301937dc1847d42576e30db43951990 --- docker/base/set_configs.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'docker') diff --git a/docker/base/set_configs.py b/docker/base/set_configs.py index 53678a287..b6c56ca97 100644 --- a/docker/base/set_configs.py +++ b/docker/base/set_configs.py @@ -75,12 +75,16 @@ class ConfigFile(object): self._delete_path(dest) # dest endswith / means copy the to folder LOG.info('Copying %s to %s', source, dest) - shutil.copy(source, dest) - self._set_properties(source, dest) + if os.path.islink(source): + link_target = os.readlink(source) + os.symlink(link_target, dest) + else: + shutil.copy(source, dest) + self._set_properties(source, dest) def _merge_directories(self, source, dest): if os.path.isdir(source): - if os.path.exists(dest) and not os.path.isdir(dest): + if os.path.lexists(dest) and not os.path.isdir(dest): self._delete_path(dest) if not os.path.isdir(dest): LOG.info('Creating directory %s', dest) @@ -95,7 +99,7 @@ class ConfigFile(object): self._copy_file(source, dest) def _delete_path(self, path): - if not os.path.exists(path): + if not os.path.lexists(path): return LOG.info('Deleting %s', path) if os.path.isdir(path): -- cgit v1.2.3