Aptdaemon provides two D-Bus interfaces on the system bus.
This is the main interface which allows you to perform package managing tasks. It is proivded by the aptdaemon object at /org/debian/apt.
There are two kind of tasks: ones which are performed immediately and ones which are queued up in transaction and performed in a sequence.
Get the list of the installed vendor keys which are used to authenticate packages.
Requires the org.debian.apt.get-trusted-vendor-keys PolicyKit privilege.
Returns: | Fingerprints of all installed keys. |
---|
Request a shutdown of the daemon.
Instead of performing the task immediately, a new transaction will be created and the method will return the D-Bus path of it. Afterwards you can simulate the transaction or put it on the queue.
Life cycle of a transaction based action and Chaining Transactions are described in the Python client documentation with code examples.
Download the latest information about available packages from the repositories and rebuild the package cache.
Requires the org.debian.apt.update-cache PolicyKit privilege.
Returns: | The D-Bus path of the new transaction object which performs this action. |
---|
Update the cache from the repositories defined in the given sources.list only.
Requires the org.debian.apt.update-cache PolicyKit privilege.
Parameters: | sources_list (s) – The absolute path to a sources.list, e.g. /etc/apt/sources.list.d/ppa-aptdaemon.list or the name of the snippet in /etc/apt/sources.list.d/, e.g. ppa-aptdaemon.list. |
---|---|
Returns: | The D-Bus path of the new transaction object which performs this action. |
Add given repository to the sources list.
Requires the org.debian.apt.change-repositories PolicyKit privilege.
Parameters: |
|
---|---|
Returns: | The D-Bus path of the new transaction object which performs this action. |
Enable the component in the distribution repositories. This will not affect third-party repositories.
The repositories of a distribution are often separated into different components because of policy reasons. E.g. Debian uses main for DFSG-free software and non-free for re-distributable but not free in the sense of the Debian Free Software Guidelines.
Requires the org.debian.apt.change-repositories PolicyKit privilege.
Parameters: | component (s) – The component, e,g, main or non-free. |
---|---|
Returns: | The D-Bus path of the new transaction object which performs this action. |
Install the given local package file.
Requires the org.debian.apt.install-file PolicyKit privilege.
Parameters: |
|
---|---|
Returns: | The D-Bus path of the new transaction object which performs this action. |
Fetch and install the given packages from the repositories.
The version number and target release of the packages can be specified using the traditional apt-get syntax, e.g. “xterm=281.1” to force installing the version 281.1 of xterm or “xterm/experimental” to force installing xterm from the experimental release.
Requires the org.debian.apt.install-or-remove-packages PolicyKit privilege.
Parameters: | package_names (as) – Packages to be upgraded |
---|---|
Returns: | The D-Bus path of the new transaction object which performs this action. |
Remove the given packages from the system. The configuration files will be kept by default. Use CommitPackages() to also purge the configuration files.
Requires the org.debian.apt.install-or-packages PolicyKit privilege.
Parameters: | package_names (as) – packages to be removed |
---|---|
Returns: | The D-Bus path of the new transaction object which performs this action. |
Upgrade the given packages to their latest version.
The version number and target release of the packages can be specified using the traditional apt-get syntax, e.g. “xterm=281.1” to force installing the version 281.1 of xterm or “xterm/experimental” to force installing xterm from the experimental release.
Requires the org.debian.apt.upgrade-packages PolicyKit privilege.
Parameters: | package_names (as) – Packages to be upgraded |
---|---|
Returns: | The D-Bus path of the new transaction object which performs this action. |
Perform several package changes at the same time.
The version number and target release of the packages can be specified using the traditional apt-get syntax, e.g. “xterm=281.1” to force installing the version 281.1 of xterm or “xterm/experimental” to force installing xterm from the experimental release.
Requires the org.debian.apt.install-or-remove-packages PolicyKit privilege.
Parameters: |
|
---|---|
Returns: | The D-Bus path of the new transaction object which performs this action. |
Apply all available upgrades and try to resolve conflicts.
Requires the org.debian.apt.upgrade-packages PolicyKit privilege.
Parameters: | safe_mode – If True only already installed packages will be updated. Updates which require to remove installed packages or to install additional packages will be skipped. |
---|---|
Returns: | The D-Bus path of the new transaction object which performs this action. |
Try to complete cancelled installations. This is equivalent to a call of dpkg --configure -a.
Requires the org.debian.apt.install-or-remove-packages PolicyKit privilege.
Returns: | The D-Bus path of the new transaction object which performs this action. |
---|
Try to resolve unsatisfied dependencies of installed packages.
Requires the org.debian.apt.install-or-remove-packages PolicyKit privilege.
Returns: | The D-Bus path of the new transaction object which performs this action. |
---|
Download and install the key of a software vendor. The key is used to authenticate packages of the vendor.
Requires the org.debian.apt.change-repositories PolicyKit privilege.
Parameters: |
|
---|---|
Returns: | The D-Bus path of the new transaction object which performs this action. |
Install the key file of a software vendor. The key is used to authenticate packages of the vendor.
Requires the org.debian.apt.change-repositories PolicyKit privilege.
Parameters: | path (s) – The absolute path to the key file. |
---|---|
Returns: | The D-Bus path of the new transaction object which performs this action. |
The following singal can be emitted on the org.debian.apt interface.
The currently processed or the queued transactions changed.
Parameters: |
|
---|
The daemon interface provides a set of properties which can be accessed and modified through Set(), Get() and GetAll() methods of the org.freedesktop.DBus.Properties interface. See the D-Bus specification for more details.
The following properties are available:
The interval in days in which the cache of downloaded packages should should be cleaned. A value of 0 disables this feature.
writable
If available upgrades should be already downloaded in the background. The upgrades won’t get installed automatically.
writable
The interval in days in which the software repositories should be checked for updates. A value of 0 disables the automatic check.
writable
If statistics about installed software and how often it is used should be sent to the distribution anonymously. This helps to determine which software should be shipped on the first install CDROMs and to make software recommendations.
writable
The interval in days in which updates should be installed automatically. A value of 0 disables this feature.
writable
Set if a reboot is required in order to complete the update.
readonly
This is the main interface of a transaction object. It allows to control and monitor the transaction. Transactions are created by using the org.debian.apt interface of aptdaemon.
The path of a transaction object consists of /org/debian/apt/transaction/ and an unique identifier.
Check the authentication, simulate and queue the transaction for processing.
Queue the transaction for processing after the given transaction.
The transaction will also fail if the previous one failed. Several transactions can be chained up.
Parameters: | tid (s) – The id of the transaction which should be executed before. |
---|
Cancel the transaction.
Simulate a transaction to update its dependencies, download size and required disk space.
Call this method if you want to show changes before queuing the transaction.
Continue paused transaction with the inserted medium.
If a media change is required to install packages from CD/DVD the transaction will be paused and could be resumed with this method.
Parameters: | medium (s) – The label of the CD/DVD. |
---|
Resolve a configuration file conflict and continue the transaction.
If a config file prompt is detected the transaction will be paused and could be resumed with this method.
Parameters: |
|
---|
The signal gets emitted if the transaction has been finished.
Parameters: | exit_state (s) – The exit state of the transaction, e.g. exit-failed. |
---|
The signal gets emitted if a property of the transaction changed.
Parameters: |
|
---|
The transaction interface provides a set of properties which can be accessed and modified through Set(), Get() and GetAll() methods of the org.freedesktop.DBus.Properties interface. See the D-Bus specification for more details.
For the documentation of the available string enumerations, see aptdaemon.enums.
The following properties are available:
If it is allowed to install not authenticated packages by the transaction. Defaults to False.
writable
If the transaction can be cancelled at the moment.
read-only
If the transaction waits for the resolution of a configuration file conflict, this property contains an array of the path to the old and the path to the new configuration file. See ResolveConfigFileConflict().
read-only
The path to the socket which should be used to proxy debconf communication to the user.
writable
Array of package groups which will be modified as dependencies:
The packages are specified by their name and a version number separated by an “=”, e.g. “xterm=261-1”. The dependencies are calculated after Simulate() or Run() was called.
read-only
The required download size in Bytes.
The property is available after Simulate() or Run() has been called.
read-only
If the transaction failed this property contains an array of the error code, e.g. error-no-lock and a detailed error message.
read-only
If the transaction is completed it contains the exit status enum of the transaction, e.g. exit-failed. If the transaction has not yet been completed it is exit-unfinished.
read-only
The URL of an http proxy which should be used for downloads by the transaction, e.g. http://proxy:8080.
writable
The locale which is used to translate messages, e.g. de_DE@UTF-8.
writable
The meta data dictionary allows client applications to store additional data persistently in the transaction object. The key has to be a string and be prefixed by an underscore separated identifier of the client application, e.g. Software Center uses sc_app to store the application corresponding to the transaction.
If a dict is written to the property it will be merged with the existing one. It is not allowed to override already existing keys.
writable
The progress in percent of the transaction.
read-only
Array of package groups which have been specified by the user intially to be modified:
The packages are specified by their name and an optional version number separated by an “=”, e.g. “xterm=261-1”. Furthermore if specified the target release of the package will be separated by a “/”, e.g. “xterm/experimental”.
read-only
If the transaction is paused, e.g. it is waiting for a medium or the resolution of a configuration file conflict.
read-only
A list with detailed progress information:
read-only
The last progress information update of a currently running download. A list of ..
read-only
If in the case of a removal obsolete dependencies which have been installed automatically before should be removed, too. writable
If the transaction waits for a medium to be inserted this property contains an array of the medium name and the path to the drive in which it should be inserted. read-only
The enum representing the type of action performed by the transaction e.g. role-install-packages. read-only
The required disk space in Bytes. If disk spaces is freed the value will be negative.
The property is available after Simulate() or Run() has been called.
read-only
The status enum of the transaction, e.g. status-loading-cache.
read-only
A human readable string with additional download information.
read-only
The path to the slave end of the controlling terminal which should be used to controll the underlying dpkg call.
writable
If the controlling terminal can be used to control the underlying dpkg call.
read-only
List of packages which are going to be installed but are not from an authenticated repository.
read-only
Most actions require the user to authenticate. The PolicyKit framework is used by aptdaemon for the authentication process. This allows to run aptdaemon as root and the client application as normal user.
For non-transaction based actions the authentication will happen immediately. For transaction based actions the privilege will be checked after Run() has been called. If the privilege has not yet been granted the user will be requested to authenticate interactively. This allows the user to simulate a transaction before having to authenticate.
Aptdaemon supports so called high level privileges which allow to perform a specified set of actions in a row without having to authenticate for each one separately. This only works if the client application authenticates for the high level privilge before running the transactions and the authentication is cached.
There are two high level privileges install-packages-from-new-repo and install-purchased-software. Both allow to add a repository, install the key of vendor from a keyserver, update the cache and to install packages.
#!/usr/bin/python
import dbus
import gobject
from aptdaemon.client import AptClient
from aptdaemon.defer import inline_callbacks
from aptdaemon import policykit1
loop = gobject.MainLoop()
def on_finished(trans, exit):
loop.quit()
print exit
@inline_callbacks
def main():
repo = ["deb", "http://packages.glatzor.de/silly-packages", "sid", ["main"],
"Silly packages", "silly.list"]
aptclient = AptClient()
bus = dbus.SystemBus()
name = bus.get_unique_name()
# high level auth
try:
# Preauthentication
action = policykit1.PK_ACTION_INSTALL_PURCHASED_PACKAGES
flags = policykit1.CHECK_AUTH_ALLOW_USER_INTERACTION
yield policykit1.check_authorization_by_name(name, action, flags=flags)
# Setting up transactions
trans_add = yield aptclient.add_repository(*repo)
trans_update = yield aptclient.update_cache("silly.list")
trans_inst = yield aptclient.install_packages(["silly-base"])
yield trans_inst.set_allow_unauthenticated(True)
# Check when the last transaction was done
trans_inst.connect("finished", on_finished)
# Chaining transactions
yield trans_update.run_after(trans_add)
yield trans_inst.run_after(trans_update)
yield trans_add.run()
except Exception as error:
print error
loop.quit()
if __name__ == "__main__":
main()
loop.run()