Package gbp :: Package pkg :: Class PkgPolicy

[hide private]
[frames] | no frames]

# Class PkgPolicy

    object --+
             |
            PkgPolicy

Known Subclasses:
  - deb.policy.DebianPkgPolicy
  - , rpm.policy.RpmPkgPolicy

Common helpers for packaging policy.

Instance Methods | [hide private]

Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__init__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__sizeof__`, `__str__`, `__subclasshook__`

Class Methods | [hide private]

is_valid_packagename(cls, name) Is this a valid package name? |

is_valid_upstreamversion(cls, version) Is this a valid upstream version number? |

Static Methods | [hide private]

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')

guess_upstream_src_version(filename, extra_regex=`'````'`) Guess the package name and version from the filename of an upstream archive. |

has_orig(orig_file, dir) Check if orig tarball exists in dir |

symlink_orig(orig_file, orig_dir, output_dir, force=False) symlink orig tarball from orig_dir to output_dir |

Class Variables | [hide private]

| packagename_msg = `None` hash(x)
| packagename_re = `None` hash(x)
| upstreamversion_msg = `None` hash(x)
| upstreamversion_re = `None` hash(x)

Properties | [hide private]

Inherited from `object`: `__class__`

Method Details | [hide private]

### guess_upstream_src_version(filename, extra_regex=`'````'`)
Static Method

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_regex` - 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 ('', '')

### is_valid_packagename(cls, name)
Class Method

Is this a valid package name?

    >>> PkgPolicy.is_valid_packagename('doesnotmatter')
    Traceback (most recent call last):
    ...
    NotImplementedError: Class needs to provide packagename_re

### is_valid_upstreamversion(cls, version)
Class Method

Is this a valid upstream version number?

    >>> PkgPolicy.is_valid_upstreamversion('doesnotmatter')
    Traceback (most recent call last):
    ...
    NotImplementedError: Class needs to provide upstreamversion_re

### symlink_orig(orig_file, orig_dir, output_dir, force=False)
Static Method

symlink orig tarball from orig_dir to output_dir

Returns:
  True if link was created or src == dst False in case of error or src doesn't exist