diff options
author | Joe Guo <joeg@catalyst.net.nz> | 2019-02-12 19:16:06 +1300 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2019-02-13 04:15:15 +0100 |
commit | c9fa0a05d90f8c1d84c41efe32a6938c026dc328 (patch) | |
tree | 767a57b0f9ed54e6a641bca4eb5b2bd4f096be1a /buildtools | |
parent | 22c016b12142e675c5b8ef0ea1f450385f555268 (diff) | |
download | samba-c9fa0a05d90f8c1d84c41efe32a6938c026dc328.tar.gz |
wafsamba/samba_utils.py: override symlink to allow force link
if bin is not empty and I have been sharing the samba tree into
a Vagrant environment and we run make, we get annoying linking error like this:
File "~/samba/lib/tevent/wscript", line 130, in build
installdir='python')
File "./buildtools/wafsamba/wafsamba.py", line 745, in SAMBA_SCRIPT
os.symlink(link_src, link_dst)
FileExistsError: [Errno 17] File exists: '~/samba/lib/tevent/tevent.py' -> '~/samba/bin/default/../python/tevent.py'
Makefile:7: recipe for target 'all' failed
Override the symlink method to allow force linking.
Signed-off-by: Joe Guo <joeg@catalyst.net.nz>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'buildtools')
-rw-r--r-- | buildtools/wafsamba/samba_utils.py | 13 | ||||
-rw-r--r-- | buildtools/wafsamba/wafsamba.py | 5 |
2 files changed, 16 insertions, 2 deletions
diff --git a/buildtools/wafsamba/samba_utils.py b/buildtools/wafsamba/samba_utils.py index 93ce317f114..ad97de1859b 100644 --- a/buildtools/wafsamba/samba_utils.py +++ b/buildtools/wafsamba/samba_utils.py @@ -1,6 +1,7 @@ # a waf tool to add autoconf-like macros to the configure section # and for SAMBA_ macros for building libraries, binaries etc +import errno import os, sys, re, fnmatch, shlex, inspect from optparse import SUPPRESS_HELP from waflib import Build, Options, Utils, Task, Logs, Configure, Errors, Context @@ -289,6 +290,18 @@ def recursive_dirlist(dir, relbase, pattern=None): return ret +def symlink(src, dst, force=True): + """Can create symlink by force""" + try: + os.symlink(src, dst) + except OSError as exc: + if exc.errno == errno.EEXIST and force: + os.remove(dst) + os.symlink(src, dst) + else: + raise + + def mkdir_p(dir): '''like mkdir -p''' if not dir: diff --git a/buildtools/wafsamba/wafsamba.py b/buildtools/wafsamba/wafsamba.py index 9d8251d60bf..70ab736e2a7 100644 --- a/buildtools/wafsamba/wafsamba.py +++ b/buildtools/wafsamba/wafsamba.py @@ -10,6 +10,7 @@ TaskGen.task_gen.apply_verif = Utils.nada # bring in the other samba modules from samba_utils import * +from samba_utils import symlink from samba_version import * from samba_autoconf import * from samba_patterns import * @@ -61,7 +62,7 @@ def SAMBA_BUILD_ENV(conf): for (source, target) in [('shared', 'shared'), ('modules', 'modules'), ('python', 'python')]: link_target = os.path.join(conf.env.BUILD_DIRECTORY, 'default/' + target) if not os.path.lexists(link_target): - os.symlink('../' + source, link_target) + symlink('../' + source, link_target) # get perl to put the blib files in the build directory blib_bld = os.path.join(conf.env.BUILD_DIRECTORY, 'default/pidl/blib') @@ -742,7 +743,7 @@ def SAMBA_SCRIPT(bld, name, pattern, installdir, installname=None): if os.path.exists(link_dst): os.unlink(link_dst) Logs.info("symlink: %s -> %s/%s" % (s, installdir, iname)) - os.symlink(link_src, link_dst) + symlink(link_src, link_dst) Build.BuildContext.SAMBA_SCRIPT = SAMBA_SCRIPT |