From 4989a9dd7c89e446e59e9faf7cbe4a9a6b0083a8 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Wed, 12 Sep 2012 17:01:40 +0200 Subject: build:waf dist: factor out function to add list of files to the tarball Pair-Programmed-With: Stefan Metzmacher --- buildtools/wafsamba/samba_dist.py | 51 ++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 22 deletions(-) (limited to 'buildtools') diff --git a/buildtools/wafsamba/samba_dist.py b/buildtools/wafsamba/samba_dist.py index 1f56f2e3ec..871c111019 100644 --- a/buildtools/wafsamba/samba_dist.py +++ b/buildtools/wafsamba/samba_dist.py @@ -99,6 +99,34 @@ def vcs_dir_contents(path): def dist(appname='',version=''): + + def add_files_to_tarball(tar, srcdir, srcsubdir, dstdir, dstsubdir, blacklist, files): + if blacklist == None: + blacklist = [] + for f in files: + abspath = os.path.join(srcdir, f) + + if srcsubdir != '.': + f = f[len(srcsubdir)+1:] + + # Remove files in the blacklist + if f in blacklist: + continue + blacklisted = False + # Remove directories in the blacklist + for d in blacklist: + if f.startswith(d): + blacklisted = True + if blacklisted: + continue + if os.path.isdir(abspath): + continue + if dstsubdir != '.': + f = dstsubdir + '/' + f + fname = dstdir + '/' + f + add_tarfile(tar, fname, abspath, srcsubdir) + + if not isinstance(appname, str) or not appname: # this copes with a mismatch in the calling arguments for dist() appname = Utils.g_module.APPNAME @@ -135,28 +163,7 @@ def dist(appname='',version=''): except Exception, e: Logs.error('unable to get contents of %s: %s' % (absdir, e)) sys.exit(1) - for f in files: - abspath = os.path.join(srcdir, f) - - if dir != '.': - f = f[len(dir)+1:] - - # Remove files in the blacklist - if f in blacklist: - continue - blacklisted = False - # Remove directories in the blacklist - for d in blacklist: - if f.startswith(d): - blacklisted = True - if blacklisted: - continue - if os.path.isdir(abspath): - continue - if destdir != '.': - f = destdir + '/' + f - fname = dist_base + '/' + f - add_tarfile(tar, fname, abspath, dir) + add_files_to_tarball(tar, srcdir, dir, dist_base, destdir, blacklist, files) if dist_files: for file in dist_files.split(): -- cgit