summaryrefslogtreecommitdiff
path: root/buildtools
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2010-04-12 11:09:44 +1000
committerAndrew Tridgell <tridge@samba.org>2010-04-12 11:17:35 +1000
commit9ffd6c0ec339aa6e70543cfecfb2bab93705e603 (patch)
tree67650b2b80b5cd5c569065e758bcf654c2861cb4 /buildtools
parent47c4e883d6fd833a7ca5d37f289908299f9f0c15 (diff)
downloadsamba-9ffd6c0ec339aa6e70543cfecfb2bab93705e603.tar.gz
samba-9ffd6c0ec339aa6e70543cfecfb2bab93705e603.tar.bz2
samba-9ffd6c0ec339aa6e70543cfecfb2bab93705e603.zip
build: cope with symlinks between build components in waf dist
This will allow us to have autogen-waf.sh be a symlink to ../buildtools/scripts/autogen-waf.sh in each library. That will prevent people from updating only the script in source4/, and forgetting to udpate the scripts in the other libs, as happened with commit f3f82496
Diffstat (limited to 'buildtools')
-rw-r--r--buildtools/wafsamba/samba_dist.py52
1 files changed, 50 insertions, 2 deletions
diff --git a/buildtools/wafsamba/samba_dist.py b/buildtools/wafsamba/samba_dist.py
index aea45c5770..0586550814 100644
--- a/buildtools/wafsamba/samba_dist.py
+++ b/buildtools/wafsamba/samba_dist.py
@@ -6,8 +6,56 @@ from samba_utils import *
dist_dirs = None
-def add_tarfile(tar, fname, abspath):
+def add_symlink(tar, fname, abspath, basedir):
+ '''handle symlinks to directories that may move during packaging'''
+ if not os.path.islink(abspath):
+ return False
+ tinfo = tar.gettarinfo(name=abspath, arcname=fname)
+ tgt = os.readlink(abspath)
+
+ if dist_dirs:
+ # we need to find the target relative to the main directory
+ # this is here to cope with symlinks into the buildtools
+ # directory from within the standalone libraries in Samba. For example,
+ # a symlink to ../../builtools/scripts/autogen-waf.sh needs
+ # to be rewritten as a symlink to buildtools/scripts/autogen-waf.sh
+ # when the tarball for talloc is built
+
+ # the filename without the appname-version
+ rel_fname = '/'.join(fname.split('/')[1:])
+
+ # join this with the symlink target
+ tgt_full = os.path.join(os.path.dirname(rel_fname), tgt)
+
+ # join with the base directory
+ tgt_base = os.path.normpath(os.path.join(basedir, tgt_full))
+
+ # see if this is inside one of our dist_dirs
+ for dir in dist_dirs.split():
+ if dir.find(':') != -1:
+ destdir=dir.split(':')[1]
+ dir=dir.split(':')[0]
+ else:
+ destdir = '.'
+ if dir == basedir:
+ # internal links don't get rewritten
+ continue
+ if dir == tgt_base[0:len(dir)] and tgt_base[len(dir)] == '/':
+ new_tgt = destdir + tgt_base[len(dir):]
+ tinfo.linkname = new_tgt
+ break
+
+ tinfo.uid = 0
+ tinfo.gid = 0
+ tinfo.uname = 'root'
+ tinfo.gname = 'root'
+ tar.addfile(tinfo)
+ return True
+
+def add_tarfile(tar, fname, abspath, basedir):
'''add a file to the tarball'''
+ if add_symlink(tar, fname, abspath, basedir):
+ return
try:
tinfo = tar.gettarinfo(name=abspath, arcname=fname)
except OSError:
@@ -61,7 +109,7 @@ def dist(appname='',version=''):
if destdir != '.':
f = destdir + '/' + f
fname = dist_base + '/' + f
- add_tarfile(tar, fname, abspath)
+ add_tarfile(tar, fname, abspath, dir)
tar.close()