Common helpers for packaging policy.
Class Method | has |
Undocumented |
Class Method | is |
Is this a valid package name? |
Class Method | is |
Is this a valid upstream version number? |
Class Method | symlink |
Undocumented |
Class Method | version |
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 |
Guess the package name and version from the filename of an upstream archive. |
Static Method | has |
Check orig tarball and additional tarballs exists in dir |
Static Method | symlink |
symlink orig tarball from orig_dir to output_dir |
Class Variable | packagename |
Undocumented |
Class Variable | packagename |
Undocumented |
Class Variable | upstreamversion |
Undocumented |
Class Variable | upstreamversion |
Undocumented |
Class Variable | version |
Undocumented |
Is this a valid package name?
>>> PkgPolicy.is_valid_packagename('doesnotmatter') Traceback (most recent call last): ... NotImplementedError: Class needs to provide packagename_re
Is this a valid upstream version number?
>>> PkgPolicy.is_valid_upstreamversion('doesnotmatter') Traceback (most recent call last): ... NotImplementedError: Class needs to provide upstreamversion_re
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'
Guess the package name and version from the filename of an upstream archive.
Parameters | |
filename:string | filename (archive or directory) from which to guess |
extra | additional 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 ('', '') |
symlink orig tarball from orig_dir to output_dir
Returns | |
[] if all links were created, list of failed links otherwise |