diff options
author | Guido Guenther <agx@sigxcpu.org> | 2007-10-03 18:00:02 +0200 |
---|---|---|
committer | Guido Guenther <agx@sigxcpu.org> | 2007-10-03 18:00:02 +0200 |
commit | 65fa3c4980f5163b00c6d13fce429b7f9cda3a5e (patch) | |
tree | e5eefdf76638a984199cc8ad396741b9708b9734 /git-import-orig | |
parent | e76a6a180a57701ae4ae381f74523cacb3152780 (diff) | |
download | git-buildpackage-65fa3c4980f5163b00c6d13fce429b7f9cda3a5e.tar.gz git-buildpackage-65fa3c4980f5163b00c6d13fce429b7f9cda3a5e.tar.bz2 git-buildpackage-65fa3c4980f5163b00c6d13fce429b7f9cda3a5e.zip |
detect upstream version from common tarball formates (Closes: #443306)
Diffstat (limited to 'git-import-orig')
-rwxr-xr-x | git-import-orig | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/git-import-orig b/git-import-orig index b9c3e8d2..54bed776 100755 --- a/git-import-orig +++ b/git-import-orig @@ -67,12 +67,22 @@ def import_source_tree(repo, orig_dir, version, upstream, filter): raise GbpError, "Import of new upstream version failed." -def get_version(tgz): - """get the version from the filename of a .orig.tar.gz""" - origre = re.compile('^[a-z\d-]+_(?P<version>[a-z\d\.\~\-]+)\.orig\.tar\.gz') - m = origre.match(os.path.basename(tgz)) - if m: - return m.group('version') +def guess_version(archive, version_regex=r''): + """ + guess the version from the filename of an upstgream archive + @archive: filename to guess to version for + @version_regex: additional version regex to apply, needs a 'version' group + """ + version_filters = [ # Debian package_<version>.orig.tar.gz: + r'^[a-z\d\-]+_(?P<version>[a-z\d\.\~\-]+)\.orig\.tar\.(gz|bz2)', + # Upstream package-<version>.tar.gz: + r'^[a-z\d\-]+-(?P<version>[a-z\d\.]+)\.tar\.(gz|bz2)' ] + if version_regex: + version_filters = version_regex + version_filters + for filter in version_filters: + m = re.match(filter, os.path.basename(archive)) + if m: + return m.group('version') def main(argv): @@ -138,7 +148,7 @@ create it otherwise use --upstream-branch to specify it. if options.version: version = options.version else: - version = get_version(archive) + version = guess_version(archive) if version: print "Upstream version is %s" % version |