pristinetar.py 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. from gbp.pkg import compressor_opts
  19. from gbp.pkg.pristinetar import PristineTar
  20. from gbp.deb import DebianPkgPolicy
  21. class DebianPristineTar(PristineTar):
  22. """The pristine-tar branch in a Debian git repository"""
  23. def has_commit(self, package, version, comp_type=None):
  24. """
  25. Do we have a pristine-tar commit for package I{package} at version
  26. {version} with compression type I{comp_type}?
  27. @param package: the package to look for
  28. @type package: C{str}
  29. @param version: the upstream version to look for
  30. @type version: C{str}
  31. @param comp_type: the compression type
  32. @type comp_type: C{str}
  33. """
  34. if not comp_type:
  35. ext = '\w\+'
  36. else:
  37. ext = compressor_opts[comp_type][1]
  38. name_regexp = '%s_%s\.orig\.tar\.%s' % (package, version, ext)
  39. return super(DebianPristineTar, self).has_commit(name_regexp)
  40. def checkout(self, package, version, comp_type, output_dir):
  41. """
  42. Checkout the orig tarball for package I{package} of I{version} and
  43. compression type I{comp_type} to I{output_dir}
  44. @param package: the package to generate the orig tarball for
  45. @type package: C{str}
  46. @param version: the version to check generate the orig tarball for
  47. @type version: C{str}
  48. @param comp_type: the compression type of the tarball
  49. @type comp_type: C{str}
  50. @param output_dir: the directory to put the tarball into
  51. @type output_dir: C{str}
  52. """
  53. name = DebianPkgPolicy.build_tarball_name(package,
  54. version,
  55. comp_type,
  56. output_dir)
  57. super(DebianPristineTar, self).checkout(name)