Package gbp :: Package deb :: Class UpstreamSource
[hide private]
[frames] | no frames]

Class UpstreamSource

object --+
         |
        UpstreamSource
Known Subclasses:

Upstream source. Can be either an unpacked dir, a tarball or another type of archive

Instance Methods [hide private]
 
__init__(self, name, unpacked=None)
x.__init__(...) initializes x; see help(type(x)) for signature
bool
_check_orig(self)
Check if upstream source format can be used as orig tarball.
 
_unpack_archive(self, dir, filters)
Unpack packed upstream sources into a given directory.
 
_unpack_tar(self, dir, filters)
Unpack a tarball to dir applying a list of filters.
 
_unpack_zip(self, dir)
 
_unpacked_toplevel(self, dir)
unpacked archives can contain a leading directory or not
tuple
guess_version(self, extra_regex='')
Guess the package name and version from the filename of an upstream archive.
bool
is_dir(self)
Returns: True if if upstream sources are an unpacked directory, False otherwise
bool
is_orig(self)
Returns: True if sources are suitable as upstream source, False otherwise
UpstreamSource
pack(self, newarchive, filters=[])
Recreate a new archive from the current one
 
unpack(self, dir, filters=[])
Unpack packed upstream sources into a given directory and determine the toplevel of the source tree.

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

Static Methods [hide private]
str
build_tarball_name(name, version, compression, dir=None)
Given a source package's name, version and compression return the name of the corresponding upstream tarball.
 
known_compressions()
Class Variables [hide private]
boolean _orig
are the upstream sources already suitable as an upstream tarball
string _path
path to the upstream sources
string _unpacked
path to the unpacked source tree
Properties [hide private]
  path

Inherited from object: __class__

Method Details [hide private]

__init__(self, name, unpacked=None)
(Constructor)

 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

_check_orig(self)

 

Check if upstream source format can be used as orig tarball. This doesn't imply that the tarball is correctly named.

Returns: bool
True if upstream source format is suitable as upstream tarball, False otherwise.

_unpack_tar(self, dir, filters)

 

Unpack a tarball to dir applying a list of filters. Leave the cleanup to the caller in case of an error.

build_tarball_name(name, version, compression, dir=None)
Static Method

 

Given a source package's name, version and compression return the name of the corresponding upstream tarball.

>>> UpstreamSource.build_tarball_name('foo', '1.0', 'bzip2')
'foo_1.0.orig.tar.bz2'
>>> UpstreamSource.build_tarball_name('bar', '0.0~git1234', 'xz')
'bar_0.0~git1234.orig.tar.xz'
Parameters:
  • name (str) - the source package's name
  • version (str) - the upstream version
  • compression (str) - the desired compression
  • dir (str) - a directory to prepend
Returns: str
the tarballs name corresponding to the input parameters

guess_version(self, extra_regex='')

 

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

>>> UpstreamSource('foo-bar_0.2.orig.tar.gz').guess_version()
('foo-bar', '0.2')
>>> UpstreamSource('foo-Bar_0.2.orig.tar.gz').guess_version()
>>> UpstreamSource('git-bar-0.2.tar.gz').guess_version()
('git-bar', '0.2')
>>> UpstreamSource('git-bar-0.2-rc1.tar.gz').guess_version()
('git-bar', '0.2-rc1')
>>> UpstreamSource('git-bar-0.2:~-rc1.tar.gz').guess_version()
('git-bar', '0.2:~-rc1')
>>> UpstreamSource('git-Bar-0A2d:rc1.tar.bz2').guess_version()
('git-Bar', '0A2d:rc1')
>>> UpstreamSource('git-1.tar.bz2').guess_version()
('git', '1')
>>> UpstreamSource('kvm_87+dfsg.orig.tar.gz').guess_version()
('kvm', '87+dfsg')
>>> UpstreamSource('foo-Bar_0.2.orig.tar.gz').guess_version()
>>> UpstreamSource('foo-Bar-a.b.tar.gz').guess_version()
>>> UpstreamSource('foo-bar_0.2.orig.tar.xz').guess_version()
('foo-bar', '0.2')
>>> UpstreamSource('foo-bar_0.2.orig.tar.lzma').guess_version()
('foo-bar', '0.2')
Parameters:
  • extra_regex - additional regex to apply, needs a 'package' and a 'version' group
Returns: tuple
(package name, version) or None.

is_dir(self)

 
Returns: bool
True if if upstream sources are an unpacked directory, False otherwise

is_orig(self)

 
Returns: bool
True if sources are suitable as upstream source, False otherwise

pack(self, newarchive, filters=[])

 

Recreate a new archive from the current one

Parameters:
  • newarchive (string) - the name of the new archive
  • filters (array of strings) - tar filters to apply
Returns: UpstreamSource
the new upstream source

Property Details [hide private]

path

Get Method:
unreachable.path(self)