Functionality related to packages.
Representation of a package in a cache.
This class provides methods and properties for working with a package. It lets you mark the package for installation, check if it is installed, and much more.
Note
Several methods have been deprecated in version 0.7.9 of python-apt, please see the Version class for the new alternatives.
Deprecated: | Return the Architecture of the package |
---|
Return the candidate version of the package.
This property is writeable to allow you to set the candidate version of the package. Just assign a Version() object, and it will be set as the candidate version.
Deprecated: | Return a list of candidate dependencies. |
---|
Deprecated: | Return True if the candidate is downloadable. |
---|
Deprecated: | Return the size of the candidate installed package. |
---|
Deprecated: | Return a list of Origin() objects for the candidate version. |
---|
Deprecated: | Return the Record of the candidate version of the package. |
---|
Deprecated: | Return the candidate version as string. |
---|
Commit the changes.
The parameter fprogress refers to a FetchProgress() object, as found in apt.progress.
The parameter iprogress refers to an InstallProgress() object, as found in apt.progress.
Deprecated: | Return the formatted long description. |
---|
Return the formated long description according to the Debian policy (Chapter 5.6.13). See http://www.debian.org/doc/debian-policy/ch-controlfields.html for more information.
Download the changelog of the package and return it as unicode string.
The parameter uri refers to the uri of the changelog file. It may contain multiple named variables which will be substitued. These variables are (src_section, prefix, src_pkg, src_ver). An example is the Ubuntu changelog:
- “http://changelogs.ubuntu.com/changelogs/pool”
- “/%(src_section)s/%(prefix)s/%(src_pkg)s” “/%(src_pkg)s_%(src_ver)s/changelog”
The parameter cancel_lock refers to an instance of threading.Lock, which if set, prevents the download.
Deprecated: | Return the homepage field as string. |
---|
Return a uniq ID for the package.
This can be used eg. to store additional information about the pkg.
Return the currently installed version of the package.
Since: | 0.7.9 |
---|
Deprecated: | Return a list of installed dependencies. |
---|
Deprecated: | Return True if the installed version is downloadable. |
---|
Return a list of files installed by the package.
Return a list of unicode names of the files which have been installed by this package
Deprecated: | Return the size of the installed deb package. |
---|
Deprecated: | Return the priority (of the installed version). |
---|
Deprecated: | Return the Record of the candidate version of the package. |
---|
Deprecated: | Return the size of the currently installed package. |
---|
Deprecated: | Return the installed version as string. |
---|
Deprecated, please use installed.version instead.
Return True if the package is no longer required.
If the package has been installed automatically as a dependency of another package, and if no packages depend on it anymore, the package is no longer required.
Mark a package for install.
If autoFix is True, the resolver will be run, trying to fix broken packages. This is the default.
If purge is True, remove the configuration files of the package as well. The default is to keep the configuration.
Mark a package for install.
If autoFix is True, the resolver will be run, trying to fix broken packages. This is the default.
If autoInst is True, the dependencies of the packages will be installed automatically. This is the default.
If fromUser is True, this package will not be marked as automatically installed. This is the default. Set it to False if you want to be able to remove the package at a later stage if no other package depends on it.
Deprecated: | Return the size of the candidate deb package. |
---|
Deprecated: | Return the priority (of the candidate version). |
---|
Deprecated: | return the long description (raw). |
---|
Deprecated: | Return the source package name as string. |
---|
Deprecated: | Return the short description (one line summary). |
---|
Return a VersionList() object for all available versions.
Since: | 0.7.9 |
---|
Representation of a package version.
Since: | 0.7.9 |
---|
Return the formatted long description.
Return the formated long description according to the Debian policy (Chapter 5.6.13). See http://www.debian.org/doc/debian-policy/ch-controlfields.html for more information.
Fetch the binary version of the package.
The parameter ‘destdir’ specifies the directory where the package will be fetched to.
The parameter ‘progress’ may refer to an apt.progress.FetchProgress() object. If not specified or None, apt.progress.TextFetchProgress() is used.
Get the source code of a package.
The parameter ‘destdir’ specifies the directory where the source will be fetched to.
The parameter ‘progress’ may refer to an apt.progress.FetchProgress() object. If not specified or None, apt.progress.TextFetchProgress() is used.
The parameter ‘unpack’ describes whether the source should be unpacked (True) or not (False). By default, it is unpacked.
If ‘unpack’ is True, the path to the extracted directory is returned. Otherwise, the path to the .dsc file is returned.
The BaseDependency class defines various attributes for accessing the parts of a dependency. The attributes are as follows:
The dependency class represents a Or-Group of dependencies. It provides an attribute to access the BaseDependency object for the available choices.
The Origin class provides access to the origin of the package. It allows you to check the component, archive, the hostname, and even if this package can be trusted.
import apt
cache = apt.Cache()
pkg = cache['python-apt'] # Access the Package object for python-apt
print 'python-apt is trusted:', pkg.candidate.origins[0].trusted
# Mark python-apt for install
pkg.markInstall()
print 'python-apt is marked for install:', pkg.markedInstall
print 'python-apt is (summary):', pkg.candidate.summary
# Now, really install it
cache.commit()