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)
21 def dist(appname='',version=''):
22 if not isinstance(appname, str):
23 # this copes with a mismatch in the calling arguments for dist()
24 appname = Utils.g_module.APPNAME
25 version = Utils.g_module.VERSION
27 version = Utils.g_module.VERSION
29 srcdir = os.path.normpath(os.path.join(os.path.dirname(Utils.g_module.root_path), Utils.g_module.srcdir))
32 print('You must use samba_dist.DIST_DIRS() to set which directories to package')
35 dist_base = '%s-%s' % (appname, version)
36 dist_name = '%s.tar.gz' % (dist_base)
38 tar = tarfile.open(dist_name, 'w:gz')
40 for dir in dist_dirs.split():
41 if dir.find(':') != -1:
42 destdir=dir.split(':')[1]
46 absdir = os.path.join(srcdir, dir)
47 git_cmd = [ 'git', 'ls-files', '--full-name', absdir ]
49 files = Utils.cmd_output(git_cmd).split()
51 print('git command failed: %s' % ' '.join(git_cmd))
54 abspath = os.path.join(srcdir, f)
59 fname = dist_base + '/' + f
60 add_tarfile(tar, fname, abspath)
64 print('Created %s' % dist_name)
70 '''set the directories to package, relative to top srcdir'''