build: Do not put a .distversion file into the GIT tree
authorAndrew Bartlett <abartlet@samba.org>
Sat, 18 Aug 2012 11:25:30 +0000 (21:25 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 20 Aug 2012 11:58:06 +0000 (21:58 +1000)
This places the file only in the tarball, and shows how to
auto-generate other files for placement in the tarball.

Andrew Bartlett

wscript

diff --git a/wscript b/wscript
index 727374dee2a99565a33d06dc1fbaebcae7699736..159c486229d4e7d1a530ba0a422edcc9be3e0ead 100755 (executable)
--- a/wscript
+++ b/wscript
@@ -6,7 +6,7 @@ blddir = 'bin'
 APPNAME='samba'
 VERSION=None
 
-import sys, os
+import sys, os, tempfile
 sys.path.insert(0, srcdir+"/buildtools/wafsamba")
 import wafsamba, Options, samba_dist, Scripting, Utils, samba_version
 
@@ -245,15 +245,18 @@ def dist():
 
     if sambaversion.IS_SNAPSHOT:
         # write .distversion file and add to tar
-        f = '.distversion'
-        distversionf = open(f, 'w')
+        distversionf = tempfile.NamedTemporaryFile(mode='w', prefix='.distversion',dir=blddir)
         for field in sambaversion.vcs_fields:
             distveroption = field + '=' + str(sambaversion.vcs_fields[field])
             distversionf.write(distveroption + '\n')
+        distversionf.flush()
+        samba_dist.DIST_FILES('%s:.distversion' % distversionf.name)
+
+        samba_dist.dist()
         distversionf.close()
-        samba_dist.DIST_FILES('.distversion')
+    else:
+        samba_dist.dist()
 
-    samba_dist.dist()
 
 def distcheck():
     '''test that distribution tarball builds and installs'''