Skip to content

Commit 216a448

Browse files
committed
waf: Generate sccs-info file
This has been broken for a long time right now, this is a quick fix to get the generation working again. This enables us to build the Debian packages again with: $ dpkg-buildpackage WAF still needs to go though :)
1 parent 8ddb627 commit 216a448

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

‎wscript_build‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import Utils,Node,Options,Logs,Scripting,Environment,Build,Configure
1010
from os import unlink as _unlink, makedirs as _makedirs, getcwd as _getcwd, chdir as _chdir
1111
from os.path import abspath as _abspath, basename as _basename, dirname as _dirname, exists as _exists, isdir as _isdir, split as _split, join as _join, sep, pathsep, pardir, curdir
1212
from glob import glob as _glob
13+
from subprocess import Popen as _Popen,PIPE
1314
try: set([1,2,3])
1415
except Exception: from Sets import set
1516
import re
@@ -31,7 +32,49 @@ filelist = bld.path.ant_glob
3132
distdir = Utils.relpath(_join(sourcedir,"dist"))
3233
targetdir = Utils.relpath(_join(sourcedir,"target"))
3334

35+
def gitinfo(dir=None):
36+
if dir and not _isdir(dir): return ''
37+
try: p = _Popen(['git','remote','show','-n','origin'],stdin=PIPE,stdout=PIPE,stderr=PIPE,cwd=dir)
38+
except OSError,e:
39+
if e.errno == 2: return '' # svn command is not installed
40+
raise
41+
stdout,stderr = p.communicate('')
42+
retcode = p.wait()
43+
# If the guess fails, just return nothing.
44+
if retcode: return
45+
stdout = [ s.strip() for s in stdout.splitlines() ]
46+
try: url = [ s[11:] for s in stdout if s.startswith("Fetch URL") ][0]
47+
except IndexError: url = [ s[5:] for s in stdout if s.startswith("URL") ][0]
48+
assert url
49+
50+
p = _Popen(['git','log','-1'],stdin=PIPE,stdout=PIPE,stderr=PIPE,cwd=dir)
51+
stdout,stderr = p.communicate('')
52+
retcode = p.wait()
53+
if retcode: return
54+
# If the guess fails, just return nothing.
55+
stdout = [ s.strip() for s in stdout.splitlines() ]
56+
commitid = [ s.split()[1] for s in stdout if s.startswith("commit") ][0]
57+
assert commitid
58+
59+
return "Git Revision: %s"%commitid + "\n" + "Git URL: %s"%url + "\n"
60+
3461
def build_utils_docs ():
62+
stdout = gitinfo()
63+
if stdout:
64+
f = file("sccs-info","w")
65+
f.write(stdout)
66+
f.flush()
67+
f.close()
68+
else:
69+
if _exists("sccs-info"):
70+
# If the file already existed, we preserve it
71+
return
72+
else:
73+
f = file("sccs-info","w")
74+
f.write("No revision control information could be detected when the source distribution was built.")
75+
f.flush()
76+
f.close()
77+
3578
sccsinfo = _join(sourcedir,"sccs-info")
3679
if _exists(sccsinfo): bld.install_files("${DOCDIR}","sccs-info")
3780

0 commit comments

Comments
 (0)