diff options
author | Guido Günther <agx@sigxcpu.org> | 2012-01-22 16:46:51 +0100 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2012-01-22 17:27:20 +0100 |
commit | 98222133e548f1c88a28a26bbc9e23f1d42a4007 (patch) | |
tree | 761e554921a6626fb928d45445f796d2d19e426b /gbp | |
parent | 3a381ec683bda6b8366252967d72217befffbd61 (diff) |
deb: Add UpstreamSource.build_tarball_name
to build a tarball name from a (package, version, compression) triplet
optionally adding a directory.
Diffstat (limited to 'gbp')
-rw-r--r-- | gbp/deb/__init__.py | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/gbp/deb/__init__.py b/gbp/deb/__init__.py index 92d893ab..b02c5fa8 100644 --- a/gbp/deb/__init__.py +++ b/gbp/deb/__init__.py @@ -277,6 +277,34 @@ class UpstreamSource(object): if m: return (m.group('package'), m.group('version')) + @staticmethod + def build_tarball_name(name, version, compression, dir=None): + """ + Given a source package's I{name}, I{version} and I{compression} + return the name of the corresponding upstream tarball. + + >>> UpstreamSource.build_tarball_name('foo', '1.0', 'bzip2') + 'foo_1.0.orig.tar.bz2' + >>> UpstreamSource.build_tarball_name('bar', '0.0~git1234', 'xz') + 'bar_0.0~git1234.orig.tar.xz' + + @param name: the source package's name + @type name: C{str} + @param version: the upstream version + @type version: C{str} + @param compression: the desired compression + @type compression: C{str} + @param dir: a directory to prepend + @type dir: C{str} + @return: the tarballs name corresponding to the input parameters + @rtype: C{str} + """ + ext = compressor_opts[compression][1] + tarball = "%s_%s.orig.tar.%s" % (name, version, ext) + if dir: + tarball = os.path.join(dir, tarball) + return tarball + class DscFile(object): """Keeps all needed data read from a dscfile""" @@ -397,8 +425,10 @@ def orig_file(cp, compression): >>> orig_file({'Source': 'bar', 'Upstream-Version': '0.0~git1234'}, "xz") 'bar_0.0~git1234.orig.tar.xz' """ - ext = compressor_opts[compression][1] - return "%s_%s.orig.tar.%s" % (cp['Source'], cp['Upstream-Version'], ext) + return UpstreamSource.build_tarball_name(cp['Source'], + cp['Upstream-Version'], + compression) + def is_valid_packagename(name): "Is this a valid Debian package name?" |