summaryrefslogtreecommitdiff
path: root/buildtools/wafsamba/samba_dist.py
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2010-04-04 09:57:33 +1000
committerAndrew Tridgell <tridge@samba.org>2010-04-06 20:27:24 +1000
commitc8062fb65ee108fa948fd8d8ed4055ffa3af7027 (patch)
tree51aa3a475537d4cc89dc5b54965b5efdc35b6867 /buildtools/wafsamba/samba_dist.py
parent735934bfede08f37707a070f977837a9f76e3242 (diff)
downloadsamba-c8062fb65ee108fa948fd8d8ed4055ffa3af7027.tar.gz
samba-c8062fb65ee108fa948fd8d8ed4055ffa3af7027.tar.bz2
samba-c8062fb65ee108fa948fd8d8ed4055ffa3af7027.zip
s4-waf: added 'waf dist' to build the tarball
Diffstat (limited to 'buildtools/wafsamba/samba_dist.py')
-rw-r--r--buildtools/wafsamba/samba_dist.py67
1 files changed, 67 insertions, 0 deletions
diff --git a/buildtools/wafsamba/samba_dist.py b/buildtools/wafsamba/samba_dist.py
new file mode 100644
index 0000000000..88268b53ce
--- /dev/null
+++ b/buildtools/wafsamba/samba_dist.py
@@ -0,0 +1,67 @@
+# customised version of 'waf dist' for Samba tools
+# uses git ls-files to get file lists
+
+import Utils, os, sys, tarfile, stat
+from samba_utils import *
+
+def add_tarfile(tar, fname, abspath):
+ '''add a file to the tarball'''
+ tinfo = tar.gettarinfo(name=abspath, arcname=fname)
+ tinfo.uid = 0
+ tinfo.gid = 0
+ tinfo.uname = 'root'
+ tinfo.gname = 'root'
+ fh = open(abspath)
+ tar.addfile(tinfo, fileobj=fh)
+ fh.close()
+
+
+def dist(appname='', version=''):
+
+ if not appname: appname = Utils.g_module.APPNAME
+ if not version: version = Utils.g_module.VERSION
+
+ env = LOAD_ENVIRONMENT()
+ srcdir = os.path.normpath(os.path.join(os.path.dirname(Utils.g_module.root_path), Utils.g_module.srcdir))
+
+ if not env.DIST_DIRS:
+ print('You must use conf.DIST_DIRS() to set which directories to package')
+ sys.exit(1)
+
+ if not env.GIT:
+ print('You need git installed to run waf dist')
+ sys.exit(1)
+
+ dist_base = '%s-%s' % (appname, version)
+ dist_name = '%s.tar.gz' % (dist_base)
+
+ tar = tarfile.open(dist_name, 'w:gz')
+
+ for dir in env.DIST_DIRS.split():
+ if dir.find(':') != -1:
+ destdir=dir.split(':')[1]
+ dir=dir.split(':')[0]
+ else:
+ destdir = '.'
+ absdir = os.path.join(srcdir, dir)
+ git_cmd = [ env.GIT, 'ls-files', '--full-name', absdir ]
+ files = Utils.cmd_output(git_cmd).split()
+ for f in files:
+ abspath = os.path.join(srcdir, f)
+ if dir != '.':
+ f = f[len(dir)+1:]
+ if destdir != '.':
+ f = destdir + '/' + f
+ fname = dist_base + '/' + f
+ add_tarfile(tar, fname, abspath)
+
+ tar.close()
+
+ print('Created %s' % dist_name)
+
+
+@conf
+def DIST_DIRS(conf, dirs):
+ '''set the directories to package, relative to top srcdir'''
+ if not conf.env.DIST_DIRS:
+ conf.env.DIST_DIRS = dirs