apt_pkg — The low-level bindings for apt-pkg
The apt_pkg extensions provides a more low-level way to work with apt. It can
do everything apt can, and is written in C++. It has been in python-apt since
the beginning.
Module Initialization
-
apt_pkg.initConfig()
- Initialize the configuration of apt. This is needed for most operations.
-
apt_pkg.initSystem()
- Initialize the system.
-
apt_pkg.init()
- Deprecated function. Use initConfig() and initSystem() instead.
Object initialization
-
apt_pkg.GetCache([progress])
- Return a pkgCache object. The optional parameter progress
specifies an instance of apt.progress.OpProgress() which will
display the open progress.
-
apt_pkg.GetCdrom()
Return a Cdrom object with the following methods:
-
Cdrom.Ident(progress)
- Identify the cdrom. The parameter progress refers to an
apt.progress.CdromProgress() object.
-
Cdrom.Add(progress)
- Add the cdrom to the sources.list file. The parameter progress
refers to an apt.progress.CdromProgress() object.
-
apt_pkg.GetDepCache(cache)
- Return a pkgDepCache object. The parameter cache specifies an
instance of pkgCache (see GetCache()).
-
apt_pkg.GetPkgSourceList()
- Return a pkgSourceList object.
The Acquire interface
-
apt_pkg.GetAcquire([progress])
Return an Acquire object. This is a class which allows you
to fetch files, or archive contents. The parameter progress refers to
an apt.progress.FetchProgress() object.
Acquire items have multiple methods:
-
Acquire.Run()
- Fetch all the items which have been added by GetPkgAcqFile().
-
Acquire.Shutdown()
- Shut the fetcher down.
-
Acquire.TotalNeeded
- The total amount of bytes needed (including those of files which are
already present)
-
Acquire.FetchNeeded
- The total amount of bytes which need to be fetched.
-
Acquire.PartialPresent
- Whether some files have been acquired already. (???)
-
apt_pkg.GetPkgAcqFile(aquire, uri[, md5, size, descr, shortDescr, destDir, destFile])
The parameter acquire refers to an Acquire() object as returned
by GetAcquire(). The file will be added to the Acquire queue
automatically.
The parameter uri refers to the location of the file, any protocol
of apt is supported.
The parameter md5 refers to the md5sum of the file. This can be used
for checking the file.
The parameter size can be used to specify the size of the package,
which can then be used to calculate the progress and validate the download.
The parameter descr is a descripition of the download. It may be
used to describe the item in the progress class. shortDescr is the
short form of it.
You can use destDir to manipulate the directory where the file will
be saved in. Together with destFile you can specify the complete target
path.
Hash functions
The apt_pkg module also provides several hash functions. If you develop
applications with python-apt it is often easier to use these functions instead
of the ones provides in Python’s hashlib module.
-
apt_pkg.md5sum(object)
- Return the md5sum of the object. object may either be a string, in
which case the md5sum of the string is returned, or a file()
object, in which case the md5sum of its contents is returned.
-
apt_pkg.sha1sum(object)
- Return the sha1sum of the object. object may either be a string, in
which case the sha1sum of the string is returned, or a file()
object, in which case the sha1sum of its contents is returned.
-
apt_pkg.sha256sum(object)
- Return the sha256sum of the object. object may either be a string, in
which case the sha256sum of the string is returned, or a file()
object, in which case the sha256sum of its contents is returned.
Other functions
Note
This documentation is created automatically and should be rewritten.
Data
-
apt_pkg.Config
- An Configuration() object with the default configuration. Actually,
this is a bit different object, but it is compatible.
-
apt_pkg.RewritePackageOrder
-
apt_pkg.RewriteSourceOrder
Package States
-
apt_pkg.CurStateConfigFiles
-
apt_pkg.CurStateHalfConfigured
-
apt_pkg.CurStateHalfInstalled
-
apt_pkg.CurStateInstalled
-
apt_pkg.CurStateNotInstalled
-
apt_pkg.CurStateUnPacked
Dependency types
-
apt_pkg.DepConflicts
-
apt_pkg.DepDepends
-
apt_pkg.DepObsoletes
-
apt_pkg.DepPreDepends
-
apt_pkg.DepRecommends
-
apt_pkg.DepReplaces
-
apt_pkg.DepSuggests
Installed states
-
apt_pkg.InstStateHold
-
apt_pkg.InstStateHoldReInstReq
-
apt_pkg.InstStateOk
-
apt_pkg.InstStateReInstReq
Priorities
-
apt_pkg.PriImportant
-
apt_pkg.PriOptional
-
apt_pkg.PriRequired
-
apt_pkg.PriStandard
Select states
-
apt_pkg.SelStateDeInstall
-
apt_pkg.SelStateHold
-
apt_pkg.SelStateInstall
-
apt_pkg.SelStatePurge
-
apt_pkg.SelStateUnknown