diff treepkg/util.py @ 494:31b64ebe4b42

determine upstream_version of a package original patch by Andre
author Bjoern Ricks <bricks@intevation.de>
date Wed, 13 Oct 2010 16:26:53 +0000
parents 058856954e2d
children ca95be9d033a
line wrap: on
line diff
--- a/treepkg/util.py	Sat Oct 02 10:09:05 2010 +0000
+++ b/treepkg/util.py	Wed Oct 13 16:26:53 2010 +0000
@@ -52,6 +52,37 @@
     output = run.capture_output(["dpkg-parsechangelog",  "-l" + changelog])
     return extract_value_for_key(output.splitlines(), "Version:")
 
+def extract_cmakefile_version(cmakelist):
+    """ Returns the version mentioned in a CMakeList.txt """
+    major = re.compile(r"VERSION_MAJOR\s+(\d+)", re.IGNORECASE)
+    minor = re.compile(r"VERSION_MINOR\s+(\d+)", re.IGNORECASE)
+    patch = re.compile(r"VERSION_PATCH\s+(\d+)", re.IGNORECASE)
+    version = ""
+    try:
+        for line in open(cmakelist):
+            major_match = major.match(line)
+            minor_match = minor.match(line)
+            patch_match = patch.match(line)
+        if major_match:
+            version = major_match.group(1)
+            if minor_match and version:
+                version += "." + minor_match.group(1)
+                if patch_match:
+                    version += "." + patch_match.group(1)
+    except: pass
+    finally:
+        return version
+
+def extract_configureac_version(configure_ac):
+    match = re.match(r"m4_define\(\[?my_version\]?, \[([^]]+)\]\)",
+                     line)
+    if match:
+        return match.group(1)
+
+    match = re.match(r"AC_INIT\([a-zA-Z_]+, ([0-9.]+)", line)
+    if match:
+        return match.group(1)
+    return ""
 
 def ensure_directory(directory):
     """Creates directory and all its parents.
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)