changeset 2467:fe43f6a7e6d0

Fix set-installer-version and usage.
author Jan Nieuwenhuizen <janneke@gnu.org>
date Tue, 24 Oct 2006 07:09:37 +0100
parents 6796250455ad
children b44cb33c75da
files GNUmakefile test-lily/set-installer-version.py
diffstat 2 files changed, 34 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/GNUmakefile	Tue Oct 24 06:47:22 2006 +0100
+++ b/GNUmakefile	Tue Oct 24 07:09:37 2006 +0100
@@ -71,7 +71,7 @@
 LILYPOND_VERSION=$(shell cat VERSION || echo '0.0.0')
 VERSION:
 	PATH=$(CWD)/target/local/system/usr/bin/:$(PATH) \
-		$(PYTHON) test-lily/set-installer-version.py --branch $(LILYPOND_BRANCH) $(LILYPOND_GITDIR) $(LILYPOND_CVSDIR)
+		$(PYTHON) test-lily/set-installer-version.py --branch $(LILYPOND_BRANCH) $(LILYPOND_GITDIR) $(LILYPOND_CVS_REPODIR)
 
 UPDATE-BUILDNUMBER=echo 'INSTALLER_BUILD='`python lilypondorg.py nextbuild $(LILYPOND_VERSION)` > $(BUILDNUMBER_FILE)
 
--- a/test-lily/set-installer-version.py	Tue Oct 24 06:47:22 2006 +0100
+++ b/test-lily/set-installer-version.py	Tue Oct 24 07:09:37 2006 +0100
@@ -28,10 +28,9 @@
     return o,a
 
     
-def get_cvs_version (dir):
-    f =dir + '/VERSION'
+def get_cvs_version (dir, branch):
+    f = dir + '/' + branch + '/VERSION'
     print 'getting version from cvs .. ' , f
-    
     d = misc.grok_sh_variables (f)
     return '%(MAJOR_VERSION)s.%(MINOR_VERSION)s.%(PATCH_LEVEL)s' % d
     
@@ -39,44 +38,48 @@
     print 'getting version from git .. '
     
     cmd = 'git --git-dir %(dir)s/ ' % locals ()
-    commit_id = misc.read_pipe ('%(cmd)s log --max-count=1 %(branch)s' % locals ())
+    commit_id = misc.read_pipe ('%(cmd)s log --max-count=1 %(branch)s'
+                                % locals ())
     m = re.search ('commit (.*)\n', commit_id)
-
     commit_id = m.group (1)
-
-    version_id = misc.read_pipe ('%(cmd)s ls-tree %(commit_id)s VERSION' % locals ())
+    version_id = misc.read_pipe ('%(cmd)s ls-tree %(commit_id)s VERSION'
+                                 % locals ())
     version_id = version_id.split (' ')[2]
     version_id = version_id.split ('\t')[0]
 
-    version_str = misc.read_pipe ('%(cmd)s cat-file blob %(version_id)s' % locals())
-
+    version_str = misc.read_pipe ('%(cmd)s cat-file blob %(version_id)s'
+                                  % locals())
     d = misc.grok_sh_variables_str (version_str)
-
     return '%(MAJOR_VERSION)s.%(MINOR_VERSION)s.%(PATCH_LEVEL)s' % d
 
-
-
-
-(o,args) = parse_options ()
+def scm_flavor (dir, branch):
+    if os.path.isdir (dir + '/objects'):
+        return 'git'
+    if os.path.isdir (dir + '/' + branch + '/CVS'):
+        return 'cvs'
+    return None
 
-version = ''
-for a in args:
-    if not os.path.isdir (a):
-        continue
-
-    if os.path.isdir (a + '/objects'):
-        # git:
+def version_from_scm_dir (dir, branch):
+    flavor = scm_flavor (dir, branch)
+    if flavor == 'git':
+        return get_git_version (dir, branch)
+    elif flavor == 'cvs':
+        return get_cvs_version (dir, branch)
+    return None
 
-        version = get_git_version (a, o.branch)
-    elif os.path.isdir (a + '/' + o.branch + '/CVS'):
-        version = get_cvs_version (a + '/' + o.branch)
+def main ():
+    (o, dirs) = parse_options ()
 
-    if version:
-        break
+    for dir in dirs:
+        version = version_from_scm_dir (dir, o.branch)
+        if version:
+            break
 
-if not version:
-    version = '0.0.0'
+    if not version:
+        version = '0.0.0'
 
+    print 'found version', version
+    open (o.output, 'w').write (version)
 
-print 'found version', version
-open (o.output, 'w').write (version)
+if __name__ == '__main__':
+    main ()