From b0faee1209f21ca38066d4cdc02320444e402f97 Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Wed, 8 Jan 2014 12:34:14 +0100 Subject: libexec/poole: Preserve symlinks and file metadata Preserve any symlinks and file metadata when copying files from the source to the target directory. diff --git a/libexec/poole b/libexec/poole index ea66ccb..3735f90 100755 --- a/libexec/poole +++ b/libexec/poole @@ -452,6 +452,15 @@ def build(project, opts): print(exc) sys.exit(1) + def copy(src, dst): + if os.path.islink(src): + linkto = os.readlink(src) + if os.path.isdir(dst): + dst = opj(dst, os.path.basename(src)) + os.symlink(linkto, dst) + else: + shutil.copy2(src, opj(dir_out, cwd_site)) + # ------------------------------------------------------------------------- # regex patterns and replacements # ------------------------------------------------------------------------- @@ -579,7 +588,7 @@ def build(project, opts): else: src = opj(cwd, f) try: - shutil.copy(src, opj(dir_out, cwd_site)) + copy(src, opj(dir_out, cwd_site)) except OSError: # some filesystems like FAT won't allow shutil.copy shutil.copyfile(src, opj(dir_out, cwd_site, f)) -- cgit v0.10-9-g596f