AptSystem

AptSystem — Dynamically loaded modules for system-specific parts.

Synopsis

#include <apt.h>

#define             APT_SYSTEM_ERROR
enum                AptSystemError;

struct              AptSystem;
AptSystem *         apt_system_new                      (const gchar *name,
                                                         AptConfiguration *configuration,
                                                         GError **error);
void                apt_system_unref                    (AptSystem *system);
AptSystem *         apt_system_ref                      (AptSystem *system);

gint                apt_system_compare_versions         (AptSystem *system,
                                                         const gchar *a,
                                                         const gchar *b);
GCompareFunc        apt_system_get_version_compare_func (AptSystem *system);

gboolean            apt_system_lock                     (AptSystem *system,
                                                         GError **error);
gboolean            apt_system_unlock                   (AptSystem *system,
                                                         GError **error);

const gchar *       apt_system_get_author               (AptSystem *system);
const gchar *       apt_system_get_description          (AptSystem *system);

Description

APT2 uses dynamically loaded modules for performing the system-specific parts like parsing index files or communicating with package managers such as dpkg or rpm. By dynamically loading those modules at run-time, distributions can provide support for APT2 with multiple different package management systems which can be useful when creating chroots or maintaining repositories for multiple distributions, or simply for testing purposes. Most users of this API should load the module defined in the configuration variable Apt::System.

Details

APT_SYSTEM_ERROR

#define APT_SYSTEM_ERROR apt_system_error_quark()

The error domain of AptSystem.


enum AptSystemError

typedef enum {
    APT_SYSTEM_ERROR_LOCKED,
    APT_SYSTEM_ERROR_FAILED
} AptSystemError;

Possible errors of AptSystem.

APT_SYSTEM_ERROR_LOCKED

Indicates that the system is locked. Please note that in apt_system_lock(), other error values may be used to indicate a locked system, this depends on how locking is implemented in the underlying package manager.

APT_SYSTEM_ERROR_FAILED

A generic error value that indicates any kind of error.

struct AptSystem

struct AptSystem {
};

This data structure has to be implemented by the system modules. There is no guarantee about the stability of this struct's API and/or ABI, please do not access any of its fields directly.


apt_system_new ()

AptSystem *         apt_system_new                      (const gchar *name,
                                                         AptConfiguration *configuration,
                                                         GError **error);

Creates a new AptSystem by opening the module name in the module directory. This function should not be considered thread-safe with regards to configuration, as the system may change options.

If the module could not be opened, or the initialization of the module failed, NULL is returned and the location pointed to by error is set to a GError describing the error.

name :

The name of the system module.

configuration :

The AptConfiguration on which the module shall get/set options.

error :

Return location to store a GError.

Returns :

A new AptSystem with a reference count of 1 or NULL if no AptSystem could be created.

apt_system_unref ()

void                apt_system_unref                    (AptSystem *system);

Decrements the reference count of system. If the reference count drops to 0, the memory allocated for system is freed and the module is closed.

system :

An AptSystem

apt_system_ref ()

AptSystem *         apt_system_ref                      (AptSystem *system);

Increments the reference count of system.

system :

An AptSystem

Returns :

system

apt_system_compare_versions ()

gint                apt_system_compare_versions         (AptSystem *system,
                                                         const gchar *a,
                                                         const gchar *b);

Compares the two version strings a and b and return -1 if a is less than b, 0 if they are equal, and 1 if a is greater than b.

system :

An AptSystem.

a :

The first version.

b :

The second version.

apt_system_get_version_compare_func ()

GCompareFunc        apt_system_get_version_compare_func (AptSystem *system);

Gets the GCompareFunc that implements apt_system_compare_versions(), as needed for apt_policy_new().

system :

An AptSystem

Returns :

A GCompareFunc for comparing two version strings.

apt_system_lock ()

gboolean            apt_system_lock                     (AptSystem *system,
                                                         GError **error);

Locks system globally; that is, no other process may install/remove packages and no other thread in the same process may lock the object. Note that this may not prevent another AptSystem in the same process to be locked.

If another process already holds a lock on the system or the system could not be locked due to other reasons such as file permission issues; FALSE is returned and the GError pointed to by error is set to something indicating the lower error. If this specific AptSystem is already locked inside the same program, FALSE is returned as well and error will be an AptSystemError with the error code APT_SYSTEM_ERROR_LOCKED.

system :

An AptSystem.

error :

Location to store an error.

Returns :

TRUE if locked, FALSE otherwise.

apt_system_unlock ()

gboolean            apt_system_unlock                   (AptSystem *system,
                                                         GError **error);

Unlocks system, allowing other threads or processes to lock it again. If an error occurs, FALSE is returned and error is set to another program

system :

An AptSystem.

error :

Location to store an error.

Returns :

TRUE if unlocked, FALSE otherwise.

apt_system_get_author ()

const gchar *       apt_system_get_author               (AptSystem *system);

Gets the author of the system module.

system :

An AptSystem

Returns :

Constant string naming the author of the module.

apt_system_get_description ()

const gchar *       apt_system_get_description          (AptSystem *system);

Gets the description of the system module.

system :

An AptSystem

Returns :

Constant string describing the module in one line.