diff options
author | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2012-09-27 10:24:28 +0300 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2014-07-24 19:52:00 +0200 |
commit | d76a1a55abecf66b37594fa0e7984273ef5059e7 (patch) | |
tree | 20dfbe4ca8c9191ee42e6ec2c222b87d1d71ac6d | |
parent | fb45b7ec0e6eb24899f7a77a82642c9665ac93b1 (diff) | |
download | git-buildpackage-d76a1a55abecf66b37594fa0e7984273ef5059e7.tar.gz git-buildpackage-d76a1a55abecf66b37594fa0e7984273ef5059e7.tar.bz2 git-buildpackage-d76a1a55abecf66b37594fa0e7984273ef5059e7.zip |
UpstreamSource/guess_version: detect more compression formats
By utilizing the parse_archive_filename() function that detects e.g.
"alias suffixes" such as 'tgz'.
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
-rw-r--r-- | gbp/pkg/__init__.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/gbp/pkg/__init__.py b/gbp/pkg/__init__.py index 52d34691..18ca8125 100644 --- a/gbp/pkg/__init__.py +++ b/gbp/pkg/__init__.py @@ -352,6 +352,10 @@ class UpstreamSource(object): ('foo-bar', '0.2') >>> UpstreamSource('foo-bar_0.2.orig.tar.lzma').guess_version() ('foo-bar', '0.2') + >>> UpstreamSource('foo-bar-0.2.zip').guess_version() + ('foo-bar', '0.2') + >>> UpstreamSource('foo-bar-0.2.tlz').guess_version() + ('foo-bar', '0.2') @param extra_regex: additional regex to apply, needs a 'package' and a 'version' group @@ -360,20 +364,20 @@ class UpstreamSource(object): """ version_chars = r'[a-zA-Z\d\.\~\-\:\+]' if self.is_dir(): - extensions = '' + basename = os.path.basename(self.path) else: - extensions = r'\.tar\.(%s)' % "|".join(self.known_compressions()) + basename = parse_archive_filename(os.path.basename(self.path))[0] - version_filters = map ( lambda x: x % (version_chars, extensions), + version_filters = map ( lambda x: x % version_chars, ( # Debian upstream tarball: package_'<version>.orig.tar.gz' - r'^(?P<package>[a-z\d\.\+\-]+)_(?P<version>%s+)\.orig%s', + r'^(?P<package>[a-z\d\.\+\-]+)_(?P<version>%s+)\.orig', # Upstream 'package-<version>.tar.gz' # or directory 'package-<version>': - r'^(?P<package>[a-zA-Z\d\.\+\-]+)-(?P<version>[0-9]%s*)%s')) + r'^(?P<package>[a-zA-Z\d\.\+\-]+)-(?P<version>[0-9]%s*)')) if extra_regex: version_filters = extra_regex + version_filters for filter in version_filters: - m = re.match(filter, os.path.basename(self.path)) + m = re.match(filter, basename) if m: return (m.group('package'), m.group('version')) |