class documentation

class PkgPolicy(object):

Known subclasses: gbp.deb.policy.DebianPkgPolicy

View In Hierarchy

Common helpers for packaging policy.

Class Method has_orig Undocumented
Class Method is_valid_packagename Is this a valid package name?
Class Method is_valid_upstreamversion Is this a valid upstream version number?
Class Method symlink_orig Undocumented
Class Method version_subst Generate a string from a given format and a version. The extracted version can be passed through the sanitizer function argument before being formatted into a string.
Static Method guess_upstream_src_version Guess the package name and version from the filename of an upstream archive.
Static Method has_origs Check orig tarball and additional tarballs exists in dir
Static Method symlink_origs symlink orig tarball from orig_dir to output_dir
Class Variable packagename_msg Undocumented
Class Variable packagename_re Undocumented
Class Variable upstreamversion_msg Undocumented
Class Variable upstreamversion_re Undocumented
Class Variable version_mangle_re Undocumented
@classmethod
def has_orig(cls, orig_file, dir):

Undocumented

@classmethod
def is_valid_packagename(cls, name):

Is this a valid package name?

>>> PkgPolicy.is_valid_packagename('doesnotmatter')
Traceback (most recent call last):
...
NotImplementedError: Class needs to provide packagename_re
@classmethod
def is_valid_upstreamversion(cls, version):

Is this a valid upstream version number?

>>> PkgPolicy.is_valid_upstreamversion('doesnotmatter')
Traceback (most recent call last):
...
NotImplementedError: Class needs to provide upstreamversion_re
@classmethod
def symlink_orig(cls, orig_file, orig_dir, output_dir, force=False):

Undocumented

@classmethod
def version_subst(cls, format, version, sanitizer=(lambda arg: arg)):

Generate a string from a given format and a version. The extracted version can be passed through the sanitizer function argument before being formatted into a string.

%(version)s provides a clean version.

%(hversion)s provides the same thing, but with '.' replaced with '-'. hversion is useful for upstreams with tagging policies that prohibit . characters.

%(version%A%B)s provides %(version)s with string 'A' replaced by 'B'. This way, simple version mangling is possible via substitution. Inside the substition string, '%' needs to be escaped. See the examples below.

>>> PkgPolicy.version_subst("debian/%(version)s", "0:0~0")
'debian/0:0~0'
>>> PkgPolicy.version_subst("libfoo-%(hversion)s", "1.8.1")
'libfoo-1-8-1'
>>> PkgPolicy.version_subst("v%(version%.%_)s", "1.2.3")
'v1_2_3'
>>> PkgPolicy.version_subst(r'%(version%-%\%)s', "0-1.2.3")
'0%1.2.3'
@staticmethod
def guess_upstream_src_version(filename, extra_regex=''):

Guess the package name and version from the filename of an upstream archive.

Parameters
filename:stringfilename (archive or directory) from which to guess
extra_regexadditional regex to apply, needs a 'package' and a 'version' group
Returns

tuple

>>> PkgPolicy.guess_upstream_src_version('foo-bar_0.2.orig.tar.gz')
('foo-bar', '0.2')
>>> PkgPolicy.guess_upstream_src_version('foo-Bar_0.2.orig.tar.gz')
('', '')
>>> PkgPolicy.guess_upstream_src_version('git-bar-0.2.tar.gz')
('git-bar', '0.2')
>>> PkgPolicy.guess_upstream_src_version('git-bar-0.2-rc1.tar.gz')
('git-bar', '0.2-rc1')
>>> PkgPolicy.guess_upstream_src_version('git-bar-0.2:~-rc1.tar.gz')
('git-bar', '0.2:~-rc1')
>>> PkgPolicy.guess_upstream_src_version('git-Bar-0A2d:rc1.tar.bz2')
('git-Bar', '0A2d:rc1')
>>> PkgPolicy.guess_upstream_src_version('git-1.tar.bz2')
('git', '1')
>>> PkgPolicy.guess_upstream_src_version('kvm_87+dfsg.orig.tar.gz')
('kvm', '87+dfsg')
>>> PkgPolicy.guess_upstream_src_version('foo-Bar-a.b.tar.gz')
('', '')
>>> PkgPolicy.guess_upstream_src_version('foo-bar_0.2.orig.tar.xz')
('foo-bar', '0.2')
>>> PkgPolicy.guess_upstream_src_version('foo-bar_0.2.orig.tar.lzma')
('foo-bar', '0.2')
>>> PkgPolicy.guess_upstream_src_version('foo-bar-0.2.zip')
('foo-bar', '0.2')
>>> PkgPolicy.guess_upstream_src_version('foo-bar-0.2.tlz')
('foo-bar', '0.2')
>>> PkgPolicy.guess_upstream_src_version('foo-bar_0.2.tar.gz')
('foo-bar', '0.2')
(package name, version) or ('', '')
@staticmethod
def has_origs(orig_files, dir):

Check orig tarball and additional tarballs exists in dir

@staticmethod
def symlink_origs(orig_files, orig_dir, output_dir, force=False):

symlink orig tarball from orig_dir to output_dir

Returns
[] if all links were created, list of failed links otherwise
packagename_msg: typing.Optional[str] =

Undocumented

packagename_re: typing.Optional[typing.Pattern[str]] =

Undocumented

upstreamversion_msg: typing.Optional[str] =

Undocumented

upstreamversion_re: typing.Optional[typing.Pattern[str]] =

Undocumented

version_mangle_re: str =

Undocumented