Back to index

apport  2.3
Public Member Functions
apport.packaging.PackageInfo Class Reference
Inheritance diagram for apport.packaging.PackageInfo:
Inheritance graph
[legend]

List of all members.

Public Member Functions

def get_version
def get_available_version
def get_dependencies
def get_source
def get_package_origin
def is_distro_package
def get_architecture
def get_files
def get_modified_files
def get_modified_conffiles
def get_file_package
def get_system_architecture
def get_library_paths
def set_mirror
def get_source_tree
def compare_versions
def enabled
def get_kernel_package
def install_packages
def package_name_glob
def get_uninstalled_package

Detailed Description

Definition at line 13 of file packaging.py.


Member Function Documentation

def apport.packaging.PackageInfo.compare_versions (   self,
  ver1,
  ver2 
)
Compare two package versions.

Return -1 for ver < ver2, 0 for ver1 == ver2, and 1 for ver1 > ver2.

Reimplemented in packaging-apt-dpkg.__AptDpkgPackageInfo.

Definition at line 148 of file packaging.py.

00148 
00149     def compare_versions(self, ver1, ver2):
00150         '''Compare two package versions.
00151 
00152         Return -1 for ver < ver2, 0 for ver1 == ver2, and 1 for ver1 > ver2.
00153         '''
00154         raise NotImplementedError('this method must be implemented by a concrete subclass')

Return whether Apport should generate crash reports.

Signal crashes are controlled by /proc/sys/kernel/core_pattern, but
some init script needs to set that value based on a configuration file.
This also determines whether Apport generates reports for Python,
package, or kernel crashes.

Implementations should parse the configuration file which controls
Apport (such as /etc/default/apport in Debian/Ubuntu).

Reimplemented in packaging-apt-dpkg.__AptDpkgPackageInfo.

Definition at line 155 of file packaging.py.

00155 
00156     def enabled(self):
00157         '''Return whether Apport should generate crash reports.
00158 
00159         Signal crashes are controlled by /proc/sys/kernel/core_pattern, but
00160         some init script needs to set that value based on a configuration file.
00161         This also determines whether Apport generates reports for Python,
00162         package, or kernel crashes.
00163 
00164         Implementations should parse the configuration file which controls
00165         Apport (such as /etc/default/apport in Debian/Ubuntu).
00166         '''
00167         raise NotImplementedError('this method must be implemented by a concrete subclass')

def apport.packaging.PackageInfo.get_architecture (   self,
  package 
)
Return the architecture of a package.

This might differ on multiarch architectures (e. g.  an i386 Firefox
package on a x86_64 system)

Reimplemented in packaging-apt-dpkg.__AptDpkgPackageInfo.

Definition at line 60 of file packaging.py.

00060 
00061     def get_architecture(self, package):
00062         '''Return the architecture of a package.
00063 
00064         This might differ on multiarch architectures (e. g.  an i386 Firefox
00065         package on a x86_64 system)
00066         '''
00067         raise NotImplementedError('this method must be implemented by a concrete subclass')

Return the latest available version of a package.

Throw ValueError if package does not exist.

Reimplemented in packaging-apt-dpkg.__AptDpkgPackageInfo.

Definition at line 21 of file packaging.py.

00021 
00022     def get_available_version(self, package):
00023         '''Return the latest available version of a package.
00024 
00025         Throw ValueError if package does not exist.
00026         '''
00027         raise NotImplementedError('this method must be implemented by a concrete subclass')

def apport.packaging.PackageInfo.get_dependencies (   self,
  package 
)
Return a list of packages a package depends on.

Reimplemented in packaging-apt-dpkg.__AptDpkgPackageInfo.

Definition at line 28 of file packaging.py.

00028 
00029     def get_dependencies(self, package):
00030         '''Return a list of packages a package depends on.'''
00031 
00032         raise NotImplementedError('this method must be implemented by a concrete subclass')

def apport.packaging.PackageInfo.get_file_package (   self,
  file,
  uninstalled = False,
  map_cachedir = None 
)
Return the package a file belongs to.

Return None if the file is not shipped by any package.

If uninstalled is True, this will also find files of uninstalled
packages; this is very expensive, though, and needs network access and
lots of CPU and I/O resources. In this case, map_cachedir can be set to
an existing directory which will be used to permanently store the
downloaded maps. If it is not set, a temporary directory will be used.

Reimplemented in packaging-apt-dpkg.__AptDpkgPackageInfo.

Definition at line 90 of file packaging.py.

00090 
00091     def get_file_package(self, file, uninstalled=False, map_cachedir=None):
00092         '''Return the package a file belongs to.
00093 
00094         Return None if the file is not shipped by any package.
00095 
00096         If uninstalled is True, this will also find files of uninstalled
00097         packages; this is very expensive, though, and needs network access and
00098         lots of CPU and I/O resources. In this case, map_cachedir can be set to
00099         an existing directory which will be used to permanently store the
00100         downloaded maps. If it is not set, a temporary directory will be used.
00101         '''
00102         raise NotImplementedError('this method must be implemented by a concrete subclass')

def apport.packaging.PackageInfo.get_files (   self,
  package 
)
Return list of files shipped by a package.

Throw ValueError if package does not exist.

Reimplemented in packaging-apt-dpkg.__AptDpkgPackageInfo.

Definition at line 68 of file packaging.py.

00068 
00069     def get_files(self, package):
00070         '''Return list of files shipped by a package.
00071 
00072         Throw ValueError if package does not exist.
00073         '''
00074         raise NotImplementedError('this method must be implemented by a concrete subclass')

Return the actual Linux kernel package name.

This is used when the user reports a bug against the "linux" package.

Reimplemented in packaging-apt-dpkg.__AptDpkgPackageInfo.

Definition at line 168 of file packaging.py.

00168 
00169     def get_kernel_package(self):
00170         '''Return the actual Linux kernel package name.
00171 
00172         This is used when the user reports a bug against the "linux" package.
00173         '''
00174         raise NotImplementedError('this method must be implemented by a concrete subclass')

Here is the call graph for this function:

Return a list of default library search paths.

The entries should be separated with a colon ':', like for
$LD_LIBRARY_PATH. This needs to take any multiarch directories into
account.

Reimplemented in packaging-apt-dpkg.__AptDpkgPackageInfo.

Definition at line 110 of file packaging.py.

00110 
00111     def get_library_paths(self):
00112         '''Return a list of default library search paths.
00113 
00114         The entries should be separated with a colon ':', like for
00115         $LD_LIBRARY_PATH. This needs to take any multiarch directories into
00116         account.
00117         '''
00118         # dummy default implementation
00119         return '/lib:/usr/lib'

Return modified configuration files of a package.

Return a file name -> file contents map of all configuration files of
package. Please note that apport.hookutils.attach_conffiles() is the
official user-facing API for this, which will ask for confirmation and
allows filtering.

Reimplemented in packaging-apt-dpkg.__AptDpkgPackageInfo.

Definition at line 80 of file packaging.py.

00080 
00081     def get_modified_conffiles(self, package):
00082         '''Return modified configuration files of a package.
00083 
00084         Return a file name -> file contents map of all configuration files of
00085         package. Please note that apport.hookutils.attach_conffiles() is the
00086         official user-facing API for this, which will ask for confirmation and
00087         allows filtering.
00088         '''
00089         return {}

def apport.packaging.PackageInfo.get_modified_files (   self,
  package 
)
Return list of all modified files of a package.

Reimplemented in packaging-apt-dpkg.__AptDpkgPackageInfo.

Definition at line 75 of file packaging.py.

00075 
00076     def get_modified_files(self, package):
00077         '''Return list of all modified files of a package.'''
00078 
00079         raise NotImplementedError('this method must be implemented by a concrete subclass')

def apport.packaging.PackageInfo.get_package_origin (   self,
  package 
)
Return package origin.

Return the repository name from which a package was installed, or None
if it cannot be determined.

Throw ValueError if package is not installed.

Reimplemented in packaging-apt-dpkg.__AptDpkgPackageInfo.

Definition at line 40 of file packaging.py.

00040 
00041     def get_package_origin(self, package):
00042         '''Return package origin.
00043 
00044         Return the repository name from which a package was installed, or None
00045         if it cannot be determined.
00046 
00047         Throw ValueError if package is not installed.
00048         '''
00049         raise NotImplementedError('this method must be implemented by a concrete subclass')

def apport.packaging.PackageInfo.get_source (   self,
  package 
)
Return the source package name for a package.

Throw ValueError if package does not exist.

Reimplemented in packaging-apt-dpkg.__AptDpkgPackageInfo.

Definition at line 33 of file packaging.py.

00033 
00034     def get_source(self, package):
00035         '''Return the source package name for a package.
00036 
00037         Throw ValueError if package does not exist.
00038         '''
00039         raise NotImplementedError('this method must be implemented by a concrete subclass')

def apport.packaging.PackageInfo.get_source_tree (   self,
  srcpackage,
  dir,
  version = None 
)
Download a source package and unpack it into dir..

dir should exist and be empty.

This also has to care about applying patches etc., so that dir will
eventually contain the actually compiled source.

If version is given, this particular version will be retrieved.
Otherwise this will fetch the latest available version.

Return the directory that contains the actual source root directory
(which might be a subdirectory of dir). Return None if the source is
not available.

Definition at line 131 of file packaging.py.

00131 
00132     def get_source_tree(self, srcpackage, dir, version=None):
00133         '''Download a source package and unpack it into dir..
00134 
00135         dir should exist and be empty.
00136 
00137         This also has to care about applying patches etc., so that dir will
00138         eventually contain the actually compiled source.
00139 
00140         If version is given, this particular version will be retrieved.
00141         Otherwise this will fetch the latest available version.
00142 
00143         Return the directory that contains the actual source root directory
00144         (which might be a subdirectory of dir). Return None if the source is
00145         not available.
00146         '''
00147         raise NotImplementedError('this method must be implemented by a concrete subclass')

Return the architecture of the system.

This should use the notation of the particular distribution.

Reimplemented in packaging-apt-dpkg.__AptDpkgPackageInfo.

Definition at line 103 of file packaging.py.

00103 
00104     def get_system_architecture(self):
00105         '''Return the architecture of the system.
00106 
00107         This should use the notation of the particular distribution.
00108         '''
00109         raise NotImplementedError('this method must be implemented by a concrete subclass')

Here is the caller graph for this function:

Return a valid package name which is not installed.

This is only used in the test suite. The default implementation should
work, but might be slow for your backend, so you might want to
reimplement this.

Definition at line 215 of file packaging.py.

00215 
00216     def get_uninstalled_package(self):
00217         '''Return a valid package name which is not installed.
00218 
00219         This is only used in the test suite. The default implementation should
00220         work, but might be slow for your backend, so you might want to
00221         reimplement this.
00222         '''
00223         for p in self.package_name_glob('*'):
00224             if not self.is_distro_package(p):
00225                 continue
00226             try:
00227                 self.get_version(p)
00228                 continue
00229             except ValueError:
00230                 return p

Here is the call graph for this function:

def apport.packaging.PackageInfo.get_version (   self,
  package 
)
Return the installed version of a package.

Throw ValueError if package does not exist.

Reimplemented in packaging-apt-dpkg.__AptDpkgPackageInfo.

Definition at line 14 of file packaging.py.

00014 
00015     def get_version(self, package):
00016         '''Return the installed version of a package.
00017 
00018         Throw ValueError if package does not exist.
00019         '''
00020         raise NotImplementedError('this method must be implemented by a concrete subclass')

Here is the caller graph for this function:

def apport.packaging.PackageInfo.install_packages (   self,
  rootdir,
  configdir,
  release,
  packages,
  verbose = False,
  cache_dir = None,
  permanent_rootdir = False 
)
Install packages into a sandbox (for apport-retrace).

In order to work without any special permissions and without touching
the running system, this should only download and unpack packages into
the given root directory, not install them into the system.

configdir points to a directory with by-release configuration files for
the packaging system; this is completely dependent on the backend
implementation, the only assumption is that this looks into
configdir/release/, so that you can use retracing for multiple
DistroReleases. As a special case, if configdir is None, it uses the
current system configuration, and "release" is ignored.

release is the value of the report's 'DistroRelease' field.

packages is a list of ('packagename', 'version') tuples. If the version
is None, it should install the most current available version.

If cache_dir is given, then the downloaded packages will be stored
there, to speed up subsequent retraces.

If permanent_rootdir is True, then the sandbox created from the
downloaded packages will be reused, to speed up subsequent retraces.

Return a string with outdated packages, or None if all packages were
installed.

If something is wrong with the environment (invalid configuration,
package servers down, etc.), this should raise a SystemError with a
meaningful error message.

Reimplemented in packaging-apt-dpkg.__AptDpkgPackageInfo.

Definition at line 176 of file packaging.py.

00176 
00177                          verbose=False, cache_dir=None, permanent_rootdir=False):
00178         '''Install packages into a sandbox (for apport-retrace).
00179 
00180         In order to work without any special permissions and without touching
00181         the running system, this should only download and unpack packages into
00182         the given root directory, not install them into the system.
00183 
00184         configdir points to a directory with by-release configuration files for
00185         the packaging system; this is completely dependent on the backend
00186         implementation, the only assumption is that this looks into
00187         configdir/release/, so that you can use retracing for multiple
00188         DistroReleases. As a special case, if configdir is None, it uses the
00189         current system configuration, and "release" is ignored.
00190 
00191         release is the value of the report's 'DistroRelease' field.
00192 
00193         packages is a list of ('packagename', 'version') tuples. If the version
00194         is None, it should install the most current available version.
00195 
00196         If cache_dir is given, then the downloaded packages will be stored
00197         there, to speed up subsequent retraces.
00198 
00199         If permanent_rootdir is True, then the sandbox created from the
00200         downloaded packages will be reused, to speed up subsequent retraces.
00201 
00202         Return a string with outdated packages, or None if all packages were
00203         installed.
00204 
00205         If something is wrong with the environment (invalid configuration,
00206         package servers down, etc.), this should raise a SystemError with a
00207         meaningful error message.
00208         '''
00209         raise NotImplementedError('this method must be implemented by a concrete subclass')

Here is the caller graph for this function:

def apport.packaging.PackageInfo.is_distro_package (   self,
  package 
)
Check package origin.

Return True if the package is a genuine distro package, or False if it
comes from a third-party source.

Throw ValueError if package does not exist.

Reimplemented in packaging-apt-dpkg.__AptDpkgPackageInfo.

Definition at line 50 of file packaging.py.

00050 
00051     def is_distro_package(self, package):
00052         '''Check package origin.
00053 
00054         Return True if the package is a genuine distro package, or False if it
00055         comes from a third-party source.
00056 
00057         Throw ValueError if package does not exist.
00058         '''
00059         raise NotImplementedError('this method must be implemented by a concrete subclass')

Here is the caller graph for this function:

Return known package names which match given glob.

Reimplemented in packaging-apt-dpkg.__AptDpkgPackageInfo.

Definition at line 210 of file packaging.py.

00210 
00211     def package_name_glob(self, glob):
00212         '''Return known package names which match given glob.'''
00213 
00214         raise NotImplementedError('this method must be implemented by a concrete subclass')

Here is the caller graph for this function:

def apport.packaging.PackageInfo.set_mirror (   self,
  url 
)
Explicitly set a distribution mirror URL.

This might be called for operations that need to fetch distribution
files/packages from the network.

By default, the mirror will be read from the system configuration
files.

Reimplemented in packaging-apt-dpkg.__AptDpkgPackageInfo.

Definition at line 120 of file packaging.py.

00120 
00121     def set_mirror(self, url):
00122         '''Explicitly set a distribution mirror URL.
00123 
00124         This might be called for operations that need to fetch distribution
00125         files/packages from the network.
00126 
00127         By default, the mirror will be read from the system configuration
00128         files.
00129         '''
00130         raise NotImplementedError('this method must be implemented by a concrete subclass')


The documentation for this class was generated from the following file: