If git build sccs file is present, catenate it to standard output with these brand new commands

This commit is contained in:
Manuel Amador (Rudd-O) 2010-08-11 18:14:55 -07:00
parent 70a52991ba
commit 07addfed62
5 changed files with 42 additions and 5 deletions

View File

@ -44,6 +44,7 @@ intelligent cloud implementation.
%package utils
Summary: Cloud.com utility library
Requires: java >= 1.6.0
Requires: python
Group: System Environment/Libraries
Obsoletes: vmops-utils < %{version}-%{release}
%description utils

2
debian/control vendored
View File

@ -22,7 +22,7 @@ Provides: vmops-utils
Conflicts: vmops-utils
Replaces: vmops-utils
Architecture: any
Depends: openjdk-6-jre
Depends: openjdk-6-jre, python
Description: Cloud.com utility library
The Cloud.com utility libraries provide a set of Java classes used
in the Cloud.com Cloud Stack.

View File

@ -0,0 +1,13 @@
#!/usr/bin/env python
import os, sys
path = os.path.join("@DOCDIR@","sccs-info")
try: text = file(path).read(-1)
except IOError,e:
if e.errno == 2:
sys.stderr.write("error: SCCS info file %r cannot be found\n"%path)
sys.exit(1)
else: raise
lines = [ s.strip() for s in text.split("\n") if s.startswith('Git Revision: ') ]
print " ".join( [ s[14:] for s in lines ] )

12
utils/bindir/cloud-sccs.in Executable file
View File

@ -0,0 +1,12 @@
#!/usr/bin/env python
import os, sys
path = os.path.join("@DOCDIR@","sccs-info")
try: text = file(path).read(-1)
except IOError,e:
if e.errno == 2:
sys.stderr.write("error: SCCS info file %r cannot be found\n"%path)
sys.exit(1)
else: raise
print text

19
wscript
View File

@ -144,8 +144,9 @@ def svninfo(*args):
else: url = "SVN " + url[0].strip()
return rev + "\n" + url
def gitinfo(*args):
try: p = _Popen(['git','remote','show','-n','origin']+list(args),stdin=PIPE,stdout=PIPE,stderr=PIPE)
def gitinfo(dir=None):
if dir and not _isdir(dir): return ''
try: p = _Popen(['git','remote','show','-n','origin'],stdin=PIPE,stdout=PIPE,stderr=PIPE,cwd=dir)
except OSError,e:
if e.errno == 2: return '' # svn command is not installed
raise
@ -158,7 +159,7 @@ def gitinfo(*args):
except IndexError: url = [ s[5:] for s in stdout if s.startswith("URL") ][0]
assert url
p = _Popen(['git','log','-1']+list(args),stdin=PIPE,stdout=PIPE,stderr=PIPE)
p = _Popen(['git','log','-1'],stdin=PIPE,stdout=PIPE,stderr=PIPE,cwd=dir)
stdout,stderr = p.communicate('')
retcode = p.wait()
if retcode: return
@ -169,6 +170,15 @@ def gitinfo(*args):
return "Git Revision: %s"%commitid + "\n" + "Git URL: %s"%url
def allgitinfo():
t = gitinfo()
if not t: return t
u = gitinfo(_join(pardir,"cloudstack-proprietary"))
if not u: return t
return t + "\n\ncloustack-proprietary:\n" + u
def _getbuildnumber(): # FIXME implement for git
n = Options.options.BUILDNUMBER
if n:
@ -230,6 +240,7 @@ def discover_ant_targets_and_properties(files):
propsinpropfiles = [ l.strip().split("=",1) for f in files if f.endswith(".properties") for l in file(f).readlines() if "=" in l and not l.startswith("#") ]
props = dict( propsinxml + propsinpropfiles )
props["base.dir"] = '.'
props["p.base.dir"] = '.'
result = []
for name,target in targets.items():
@ -528,7 +539,7 @@ def dist_hook():
if Options.options.OSS:
[ shutil.rmtree(f) for f in "cloudstack-proprietary".split() if _exists(f) ]
stdout = svninfo("..") or gitinfo()
stdout = svninfo("..") or allgitinfo()
if stdout:
f = file("sccs-info","w")
f.write(stdout)