Mercurial > treepkg > treepkg
comparison 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 |
comparison
equal
deleted
inserted
replaced
493:e075ce66e085 | 494:31b64ebe4b42 |
---|---|
50 def debian_changelog_version(changelog): | 50 def debian_changelog_version(changelog): |
51 """Returns the newest version in a debian changelog.""" | 51 """Returns the newest version in a debian changelog.""" |
52 output = run.capture_output(["dpkg-parsechangelog", "-l" + changelog]) | 52 output = run.capture_output(["dpkg-parsechangelog", "-l" + changelog]) |
53 return extract_value_for_key(output.splitlines(), "Version:") | 53 return extract_value_for_key(output.splitlines(), "Version:") |
54 | 54 |
55 def extract_cmakefile_version(cmakelist): | |
56 """ Returns the version mentioned in a CMakeList.txt """ | |
57 major = re.compile(r"VERSION_MAJOR\s+(\d+)", re.IGNORECASE) | |
58 minor = re.compile(r"VERSION_MINOR\s+(\d+)", re.IGNORECASE) | |
59 patch = re.compile(r"VERSION_PATCH\s+(\d+)", re.IGNORECASE) | |
60 version = "" | |
61 try: | |
62 for line in open(cmakelist): | |
63 major_match = major.match(line) | |
64 minor_match = minor.match(line) | |
65 patch_match = patch.match(line) | |
66 if major_match: | |
67 version = major_match.group(1) | |
68 if minor_match and version: | |
69 version += "." + minor_match.group(1) | |
70 if patch_match: | |
71 version += "." + patch_match.group(1) | |
72 except: pass | |
73 finally: | |
74 return version | |
75 | |
76 def extract_configureac_version(configure_ac): | |
77 match = re.match(r"m4_define\(\[?my_version\]?, \[([^]]+)\]\)", | |
78 line) | |
79 if match: | |
80 return match.group(1) | |
81 | |
82 match = re.match(r"AC_INIT\([a-zA-Z_]+, ([0-9.]+)", line) | |
83 if match: | |
84 return match.group(1) | |
85 return "" | |
55 | 86 |
56 def ensure_directory(directory): | 87 def ensure_directory(directory): |
57 """Creates directory and all its parents. | 88 """Creates directory and all its parents. |
58 | 89 |
59 Unlike os.makedirs, this function doesn't throw an exception | 90 Unlike os.makedirs, this function doesn't throw an exception |