1 # customised version of 'waf dist' for Samba tools
2 # uses git ls-files to get file lists
4 import Utils, os, sys, tarfile, stat, Scripting
5 from samba_utils import *
9 def add_tarfile(tar, fname, abspath):
10 '''add a file to the tarball'''
11 tinfo = tar.gettarinfo(name=abspath, arcname=fname)
17 tar.addfile(tinfo, fileobj=fh)
22 appname = Utils.g_module.APPNAME
23 version = Utils.g_module.VERSION
25 srcdir = os.path.normpath(os.path.join(os.path.dirname(Utils.g_module.root_path), Utils.g_module.srcdir))
28 print('You must use samba_dist.DIST_DIRS() to set which directories to package')
31 dist_base = '%s-%s' % (appname, version)
32 dist_name = '%s.tar.gz' % (dist_base)
34 tar = tarfile.open(dist_name, 'w:gz')
36 for dir in dist_dirs.split():
37 if dir.find(':') != -1:
38 destdir=dir.split(':')[1]
42 absdir = os.path.join(srcdir, dir)
43 git_cmd = [ 'git', 'ls-files', '--full-name', absdir ]
45 files = Utils.cmd_output(git_cmd).split()
47 print('git command failed: %s' % ' '.join(git_cmd))
50 abspath = os.path.join(srcdir, f)
55 fname = dist_base + '/' + f
56 add_tarfile(tar, fname, abspath)
60 print('Created %s' % dist_name)
65 '''set the directories to package, relative to top srcdir'''