chiark / gitweb /
Escape: Add missing r in regexp literals ('...' => r'...') [6]
[git-buildpackage.git] / gbp / deb / pristinetar.py
1 # vim: set fileencoding=utf-8 :
2 #
3 # (C) 2012 Guido Günther <agx@sigxcpu.org>
4 #    This program is free software; you can redistribute it and/or modify
5 #    it under the terms of the GNU General Public License as published by
6 #    the Free Software Foundation; either version 2 of the License, or
7 #    (at your option) any later version.
8 #
9 #    This program is distributed in the hope that it will be useful,
10 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
11 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 #    GNU General Public License for more details.
13 #
14 #    You should have received a copy of the GNU General Public License
15 #    along with this program; if not, please see
16 #    <http://www.gnu.org/licenses/>
17 """Handle checkin and checkout of archives from the pristine-tar branch"""
18
19 from gbp.pkg.compressor import Compressor
20 from gbp.pkg.pristinetar import PristineTar
21 from gbp.deb import DebianPkgPolicy
22
23
24 class DebianPristineTar(PristineTar):
25     """The pristine-tar branch in a Debian git repository"""
26     def has_commit(self, package, version, comp_type=None):
27         """
28         Do we have a pristine-tar commit for package I{package} at version
29         {version} with compression type I{comp_type}?
30
31         @param package: the package to look for
32         @type package: C{str}
33         @param version: the upstream version to look for
34         @type version: C{str}
35         @param comp_type: the compression type
36         @type comp_type: C{str}
37         """
38         if not comp_type:
39             ext = r'\w\+'
40         else:
41             ext = Compressor.Exts[comp_type]
42
43         name_regexp = r'%s_%s\.orig\.tar\.%s' % (package, version, ext)
44
45         return super(DebianPristineTar, self).has_commit(name_regexp)
46
47     def checkout(self, package, version, comp_type, output_dir, component=None,
48                  quiet=False):
49         """
50         Checkout the orig tarball for package I{package} of I{version} and
51         compression type I{comp_type} to I{output_dir}
52
53         @param package: the package to generate the orig tarball for
54         @type package: C{str}
55         @param version: the version to check generate the orig tarball for
56         @type version: C{str}
57         @param comp_type: the compression type of the tarball
58         @type comp_type: C{str}
59         @param output_dir: the directory to put the tarball into
60         @type output_dir: C{str}
61         """
62         name = DebianPkgPolicy.build_tarball_name(package,
63                                                   version,
64                                                   comp_type,
65                                                   output_dir,
66                                                   component=component)
67         super(DebianPristineTar, self).checkout(name, quiet=quiet)