APT2 Reference Manual | ||||
---|---|---|---|---|
Top | Description |
#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
);
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.
typedef enum { APT_SYSTEM_ERROR_LOCKED, APT_SYSTEM_ERROR_FAILED } AptSystemError;
Possible errors of AptSystem.
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.
|
|
A generic error value that indicates any kind of error. |
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.
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.
|
The name of the system module. |
|
The AptConfiguration on which the module shall get/set options. |
|
Return location to store a GError. |
Returns : |
A new AptSystem with a reference count of 1 or NULL if
no AptSystem could be created. |
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.
|
An AptSystem |
AptSystem * apt_system_ref (AptSystem *system
);
Increments the reference count of system
.
|
An AptSystem |
Returns : |
system |
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
.
|
An AptSystem. |
|
The first version. |
|
The second version. |
GCompareFunc apt_system_get_version_compare_func (AptSystem *system
);
Gets the GCompareFunc that implements apt_system_compare_versions()
, as
needed for apt_policy_new()
.
|
An AptSystem |
Returns : |
A GCompareFunc for comparing two version strings. |
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.
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
const gchar * apt_system_get_author (AptSystem *system
);
Gets the author of the system module.
|
An AptSystem |
Returns : |
Constant string naming the author of the module. |