summaryrefslogtreecommitdiff
path: root/lib/libalpm/alpm.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libalpm/alpm.h')
-rw-r--r--lib/libalpm/alpm.h527
1 files changed, 322 insertions, 205 deletions
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index cb643d29..579b45f2 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -45,32 +45,134 @@ extern "C" {
*/
/*
+ * Enumerations
+ * These ones are used in multiple contexts, so are forward-declared.
+ */
+
+/**
+ * Install reasons.
+ * Why the package was installed.
+ */
+typedef enum _pmpkgreason_t {
+ /** Explicitly requested by the user. */
+ PM_PKG_REASON_EXPLICIT = 0,
+ /** Installed as a dependency for another package. */
+ PM_PKG_REASON_DEPEND = 1
+} pmpkgreason_t;
+
+/** Types of version constraints in dependency specs. */
+typedef enum _pmdepmod_t {
+ /** No version constraint */
+ PM_DEP_MOD_ANY = 1,
+ /** Test version equality (package=x.y.z) */
+ PM_DEP_MOD_EQ,
+ /** Test for at least a version (package>=x.y.z) */
+ PM_DEP_MOD_GE,
+ /** Test for at most a version (package<=x.y.z) */
+ PM_DEP_MOD_LE,
+ /** Test for greater than some version (package>x.y.z) */
+ PM_DEP_MOD_GT,
+ /** Test for less than some version (package<x.y.z) */
+ PM_DEP_MOD_LT
+} pmdepmod_t;
+
+/**
+ * File conflict type.
+ * Whether the conflict results from a file existing on the filesystem, or with
+ * another target in the transaction.
+ */
+typedef enum _pmfileconflicttype_t {
+ PM_FILECONFLICT_TARGET = 1,
+ PM_FILECONFLICT_FILESYSTEM
+} pmfileconflicttype_t;
+
+/**
+ * GPG signature verification options
+ */
+typedef enum _pgp_verify_t {
+ PM_PGP_VERIFY_UNKNOWN,
+ PM_PGP_VERIFY_NEVER,
+ PM_PGP_VERIFY_OPTIONAL,
+ PM_PGP_VERIFY_ALWAYS
+} pgp_verify_t;
+
+/*
* Structures
*/
+typedef struct __pmhandle_t pmhandle_t;
typedef struct __pmdb_t pmdb_t;
typedef struct __pmpkg_t pmpkg_t;
-typedef struct __pmdelta_t pmdelta_t;
-typedef struct __pmgrp_t pmgrp_t;
typedef struct __pmtrans_t pmtrans_t;
-typedef struct __pmdepend_t pmdepend_t;
-typedef struct __pmdepmissing_t pmdepmissing_t;
-typedef struct __pmconflict_t pmconflict_t;
-typedef struct __pmfileconflict_t pmfileconflict_t;
-/*
- * Library
- */
-
-int alpm_initialize(void);
-int alpm_release(void);
-const char *alpm_version(void);
+/** Dependency */
+typedef struct _pmdepend_t {
+ char *name;
+ char *version;
+ unsigned long name_hash;
+ pmdepmod_t mod;
+} pmdepend_t;
+
+/** Missing dependency */
+typedef struct _pmdepmissing_t {
+ char *target;
+ pmdepend_t *depend;
+ /* this is used in case of remove dependency error only */
+ char *causingpkg;
+} pmdepmissing_t;
+
+/** Conflict */
+typedef struct _pmconflict_t {
+ char *package1;
+ char *package2;
+ char *reason;
+} pmconflict_t;
+
+/** File conflict */
+typedef struct _pmfileconflict_t {
+ char *target;
+ pmfileconflicttype_t type;
+ char *file;
+ char *ctarget;
+} pmfileconflict_t;
+
+/** Package group */
+typedef struct _pmgrp_t {
+ /** group name */
+ char *name;
+ /** list of pmpkg_t packages */
+ alpm_list_t *packages;
+} pmgrp_t;
+
+/** Package upgrade delta */
+typedef struct _pmdelta_t {
+ /** filename of the delta patch */
+ char *delta;
+ /** md5sum of the delta file */
+ char *delta_md5;
+ /** filename of the 'before' file */
+ char *from;
+ /** filename of the 'after' file */
+ char *to;
+ /** filesize of the delta file */
+ off_t delta_size;
+ /** download filesize of the delta file */
+ off_t download_size;
+} pmdelta_t;
+
+/** Local package or package file backup entry */
+typedef struct _pmbackup_t {
+ char *name;
+ char *hash;
+} pmbackup_t;
/*
* Logging facilities
*/
-/* Levels */
+/**
+ * Logging Levels
+ */
typedef enum _pmloglevel_t {
PM_LOG_ERROR = 1,
PM_LOG_WARNING = (1 << 1),
@@ -79,15 +181,22 @@ typedef enum _pmloglevel_t {
} pmloglevel_t;
typedef void (*alpm_cb_log)(pmloglevel_t, const char *, va_list);
-int alpm_logaction(const char *fmt, ...);
+int alpm_logaction(pmhandle_t *handle, const char *fmt, ...);
/*
* Downloading
*/
+/** Type of download progress callbacks.
+ * @param filename the name of the file being downloaded
+ * @param xfered the number of transferred bytes
+ * @param total the total number of bytes to transfer
+ */
typedef void (*alpm_cb_download)(const char *filename,
off_t xfered, off_t total);
+
typedef void (*alpm_cb_totaldl)(off_t total);
+
/** A callback for downloading files
* @param url the URL of the file to be downloaded
* @param localpath the directory to which the file should be downloaded
@@ -99,111 +208,131 @@ typedef int (*alpm_cb_fetch)(const char *url, const char *localpath,
int force);
/** Fetch a remote pkg.
+ * @param handle the context handle
* @param url URL of the package to download
* @return the downloaded filepath on success, NULL on error
*/
-char *alpm_fetch_pkgurl(const char *url);
+char *alpm_fetch_pkgurl(pmhandle_t *handle, const char *url);
/** @addtogroup alpm_api_options Options
* Libalpm option getters and setters
* @{
*/
-/** @name The logging callback. */
-/* @{ */
-alpm_cb_log alpm_option_get_logcb(void);
-void alpm_option_set_logcb(alpm_cb_log cb);
-/* @} */
+/** Returns the callback used for logging. */
+alpm_cb_log alpm_option_get_logcb(pmhandle_t *handle);
+/** Sets the callback used for logging. */
+int alpm_option_set_logcb(pmhandle_t *handle, alpm_cb_log cb);
-/** Get/set the download progress callback. */
-alpm_cb_download alpm_option_get_dlcb(void);
-void alpm_option_set_dlcb(alpm_cb_download cb);
+/** Returns the callback used to report download progress. */
+alpm_cb_download alpm_option_get_dlcb(pmhandle_t *handle);
+/** Sets the callback used to report download progress. */
+int alpm_option_set_dlcb(pmhandle_t *handle, alpm_cb_download cb);
-/** Get/set the downloader callback. */
-alpm_cb_fetch alpm_option_get_fetchcb(void);
-void alpm_option_set_fetchcb(alpm_cb_fetch cb);
+/** Returns the downloading callback. */
+alpm_cb_fetch alpm_option_get_fetchcb(pmhandle_t *handle);
+/** Sets the downloading callback. */
+int alpm_option_set_fetchcb(pmhandle_t *handle, alpm_cb_fetch cb);
-/** Get/set the callback used when download size is known. */
-alpm_cb_totaldl alpm_option_get_totaldlcb(void);
-void alpm_option_set_totaldlcb(alpm_cb_totaldl cb);
+/** Returns the callback used to report total download size. */
+alpm_cb_totaldl alpm_option_get_totaldlcb(pmhandle_t *handle);
+/** Sets the callback used to report total download size. */
+int alpm_option_set_totaldlcb(pmhandle_t *handle, alpm_cb_totaldl cb);
-/** Get/set the root of the destination filesystem. */
-const char *alpm_option_get_root(void);
-int alpm_option_set_root(const char *root);
+/** Returns the root of the destination filesystem. Read-only. */
+const char *alpm_option_get_root(pmhandle_t *handle);
-/** Get/set the path to the database directory. */
-const char *alpm_option_get_dbpath(void);
-int alpm_option_set_dbpath(const char *dbpath);
+/** Returns the path to the database directory. Read-only. */
+const char *alpm_option_get_dbpath(pmhandle_t *handle);
-/** Get/set the list of package cache directories. */
-alpm_list_t *alpm_option_get_cachedirs(void);
-void alpm_option_set_cachedirs(alpm_list_t *cachedirs);
+/** Get the name of the database lock file. Read-only. */
+const char *alpm_option_get_lockfile(pmhandle_t *handle);
-/** Add a single directory to the package cache paths. */
-int alpm_option_add_cachedir(const char *cachedir);
+/** @name Accessors to the list of package cache directories.
+ * @{
+ */
+alpm_list_t *alpm_option_get_cachedirs(pmhandle_t *handle);
+int alpm_option_set_cachedirs(pmhandle_t *handle, alpm_list_t *cachedirs);
+int alpm_option_add_cachedir(pmhandle_t *handle, const char *cachedir);
+int alpm_option_remove_cachedir(pmhandle_t *handle, const char *cachedir);
+/** @} */
-/** Remove a single directory from the package cache paths. */
-int alpm_option_remove_cachedir(const char *cachedir);
+/** Returns the logfile name. */
+const char *alpm_option_get_logfile(pmhandle_t *handle);
+/** Sets the logfile name. */
+int alpm_option_set_logfile(pmhandle_t *handle, const char *logfile);
-/** Get/set the logfile name. */
-const char *alpm_option_get_logfile(void);
-int alpm_option_set_logfile(const char *logfile);
+/** Returns the path to libalpm's GnuPG home directory. */
+const char *alpm_option_get_gpgdir(pmhandle_t *handle);
+/** Sets the path to libalpm's GnuPG home directory. */
+int alpm_option_set_gpgdir(pmhandle_t *handle, const char *gpgdir);
-/** Get the name of the database lock file.
- *
- * This properly is read-only, and determined from
- * the database path.
- *
- * @sa alpm_option_set_dbpath(const char*)
- */
-const char *alpm_option_get_lockfile(void);
+/** Returns whether to use syslog (0 is FALSE, TRUE otherwise). */
+int alpm_option_get_usesyslog(pmhandle_t *handle);
+/** Sets whether to use syslog (0 is FALSE, TRUE otherwise). */
+int alpm_option_set_usesyslog(pmhandle_t *handle, int usesyslog);
-/** Get/set whether to use syslog (0 is FALSE, TRUE otherwise). */
-int alpm_option_get_usesyslog(void);
-void alpm_option_set_usesyslog(int usesyslog);
+/** @name Accessors to the list of no-upgrade files.
+ * These functions modify the list of files which should
+ * not be updated by package installation.
+ * @{
+ */
+alpm_list_t *alpm_option_get_noupgrades(pmhandle_t *handle);
+int alpm_option_add_noupgrade(pmhandle_t *handle, const char *pkg);
+int alpm_option_set_noupgrades(pmhandle_t *handle, alpm_list_t *noupgrade);
+int alpm_option_remove_noupgrade(pmhandle_t *handle, const char *pkg);
+/** @} */
-alpm_list_t *alpm_option_get_noupgrades(void);
-void alpm_option_add_noupgrade(const char *pkg);
-void alpm_option_set_noupgrades(alpm_list_t *noupgrade);
-int alpm_option_remove_noupgrade(const char *pkg);
+/** @name Accessors to the list of no-extract files.
+ * These functions modify the list of filenames which should
+ * be skipped packages which should
+ * not be upgraded by a sysupgrade operation.
+ * @{
+ */
+alpm_list_t *alpm_option_get_noextracts(pmhandle_t *handle);
+int alpm_option_add_noextract(pmhandle_t *handle, const char *pkg);
+int alpm_option_set_noextracts(pmhandle_t *handle, alpm_list_t *noextract);
+int alpm_option_remove_noextract(pmhandle_t *handle, const char *pkg);
+/** @} */
-alpm_list_t *alpm_option_get_noextracts(void);
-void alpm_option_add_noextract(const char *pkg);
-void alpm_option_set_noextracts(alpm_list_t *noextract);
-int alpm_option_remove_noextract(const char *pkg);
+/** @name Accessors to the list of ignored packages.
+ * These functions modify the list of packages that
+ * should be ignored by a sysupgrade.
+ * @{
+ */
+alpm_list_t *alpm_option_get_ignorepkgs(pmhandle_t *handle);
+int alpm_option_add_ignorepkg(pmhandle_t *handle, const char *pkg);
+int alpm_option_set_ignorepkgs(pmhandle_t *handle, alpm_list_t *ignorepkgs);
+int alpm_option_remove_ignorepkg(pmhandle_t *handle, const char *pkg);
+/** @} */
-alpm_list_t *alpm_option_get_ignorepkgs(void);
-void alpm_option_add_ignorepkg(const char *pkg);
-void alpm_option_set_ignorepkgs(alpm_list_t *ignorepkgs);
-int alpm_option_remove_ignorepkg(const char *pkg);
+/** @name Accessors to the list of ignored groups.
+ * These functions modify the list of groups whose packages
+ * should be ignored by a sysupgrade.
+ * @{
+ */
+alpm_list_t *alpm_option_get_ignoregrps(pmhandle_t *handle);
+int alpm_option_add_ignoregrp(pmhandle_t *handle, const char *grp);
+int alpm_option_set_ignoregrps(pmhandle_t *handle, alpm_list_t *ignoregrps);
+int alpm_option_remove_ignoregrp(pmhandle_t *handle, const char *grp);
+/** @} */
-alpm_list_t *alpm_option_get_ignoregrps(void);
-void alpm_option_add_ignoregrp(const char *grp);
-void alpm_option_set_ignoregrps(alpm_list_t *ignoregrps);
-int alpm_option_remove_ignoregrp(const char *grp);
+/** Returns the targeted architecture. */
+const char *alpm_option_get_arch(pmhandle_t *handle);
+/** Sets the targeted architecture. */
+int alpm_option_set_arch(pmhandle_t *handle, const char *arch);
-/** Get/set the targeted architecture. */
-const char *alpm_option_get_arch(void);
-void alpm_option_set_arch(const char *arch);
+int alpm_option_get_usedelta(pmhandle_t *handle);
+int alpm_option_set_usedelta(pmhandle_t *handle, int usedelta);
-int alpm_option_get_usedelta(void);
-void alpm_option_set_usedelta(int usedelta);
+int alpm_option_get_checkspace(pmhandle_t *handle);
+int alpm_option_set_checkspace(pmhandle_t *handle, int checkspace);
-int alpm_option_get_checkspace(void);
-void alpm_option_set_checkspace(int checkspace);
+pgp_verify_t alpm_option_get_default_sigverify(pmhandle_t *handle);
+int alpm_option_set_default_sigverify(pmhandle_t *handle, pgp_verify_t level);
/** @} */
-/** Install reasons
- * Why the package was installed.
- */
-typedef enum _pmpkgreason_t {
- /** Explicitly requested by the user. */
- PM_PKG_REASON_EXPLICIT = 0,
- /** Installed as a dependency for another package. */
- PM_PKG_REASON_DEPEND = 1
-} pmpkgreason_t;
-
/** @addtogroup alpm_api_databases Database Functions
* Functions to query and manipulate the database of libalpm.
* @{
@@ -215,20 +344,25 @@ typedef enum _pmpkgreason_t {
* libalpm functions.
* @return a reference to the local database
*/
-pmdb_t *alpm_option_get_localdb(void);
+pmdb_t *alpm_option_get_localdb(pmhandle_t *handle);
/** Get the list of sync databases.
* Returns a list of pmdb_t structures, one for each registered
* sync database.
+ * @param handle the context handle
* @return a reference to an internal list of pmdb_t structures
*/
-alpm_list_t *alpm_option_get_syncdbs(void);
+alpm_list_t *alpm_option_get_syncdbs(pmhandle_t *handle);
/** Register a sync database of packages.
+ * @param handle the context handle
* @param treename the name of the sync repository
+ * @param check_sig what level of signature checking to perform on the
+ * database; note that this must be a '.sig' file type verification
* @return a pmdb_t* on success (the value), NULL on error
*/
-pmdb_t *alpm_db_register_sync(const char *treename);
+pmdb_t *alpm_db_register_sync(pmhandle_t *handle, const char *treename,
+ pgp_verify_t check_sig);
/** Unregister a package database.
* @param db pointer to the package database to unregister
@@ -237,9 +371,10 @@ pmdb_t *alpm_db_register_sync(const char *treename);
int alpm_db_unregister(pmdb_t *db);
/** Unregister all package databases.
+ * @param handle the context handle
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
-int alpm_db_unregister_all(void);
+int alpm_db_unregister_all(pmhandle_t *handle);
/** Get the name of a package database.
* @param db pointer to the package database
@@ -247,18 +382,14 @@ int alpm_db_unregister_all(void);
*/
const char *alpm_db_get_name(const pmdb_t *db);
-/** Get a download URL for the package database.
- * @param db pointer to the package database
- * @return a fully-specified download URL, NULL on error
- */
-const char *alpm_db_get_url(const pmdb_t *db);
-
-/** Set the serverlist of a database.
- * @param db database pointer
- * @param url url of the server
- * @return 0 on success, -1 on error (pm_errno is set accordingly)
+/** @name Accessors to the list of servers for a database.
+ * @{
*/
-int alpm_db_setserver(pmdb_t *db, const char *url);
+alpm_list_t *alpm_db_get_servers(const pmdb_t *db);
+int alpm_db_set_servers(pmdb_t *db, alpm_list_t *servers);
+int alpm_db_add_server(pmdb_t *db, const char *url);
+int alpm_db_remove_server(pmdb_t *db, const char *url);
+/** @} */
int alpm_db_update(int level, pmdb_t *db);
@@ -288,10 +419,10 @@ pmgrp_t *alpm_db_readgrp(pmdb_t *db, const char *name);
*/
alpm_list_t *alpm_db_get_grpcache(pmdb_t *db);
-/** Searches a database.
+/** Searches a database with regular expressions.
* @param db pointer to the package database to search in
- * @param needles the list of strings to search for
- * @return the list of packages on success, NULL on error
+ * @param needles a list of regular expressions to search for
+ * @return the list of packages matching all regular expressions on success, NULL on error
*/
alpm_list_t *alpm_db_search(pmdb_t *db, const alpm_list_t* needles);
@@ -313,14 +444,19 @@ int alpm_db_set_pkgreason(pmdb_t *db, const char *name, pmpkgreason_t reason);
/** Create a package from a file.
* If full is false, the archive is read only until all necessary
* metadata is found. If it is true, the entire archive is read, which
- * serves as a verfication of integrity and the filelist can be created.
+ * serves as a verification of integrity and the filelist can be created.
+ * The allocated structure should be freed using alpm_pkg_free().
+ * @param handle the context handle
* @param filename location of the package tarball
* @param full whether to stop the load after metadata is read or continue
- * through the full archive
+ * through the full archive
+ * @param check_sig what level of package signature checking to perform on the
+ * package; note that this must be a '.sig' file type verification
* @param pkg address of the package pointer
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
-int alpm_pkg_load(const char *filename, int full, pmpkg_t **pkg);
+int alpm_pkg_load(pmhandle_t *handle, const char *filename, int full,
+ pgp_verify_t check_sig, pmpkg_t **pkg);
/** Free a package.
* @param pkg package pointer to free
@@ -498,9 +634,9 @@ alpm_list_t *alpm_pkg_get_files(pmpkg_t *pkg);
*/
alpm_list_t *alpm_pkg_get_backup(pmpkg_t *pkg);
-/** Returns the database containing pkg
+/** Returns the database containing pkg.
* Returns a pointer to the pmdb_t structure the package is
- * originating from, or NULL is the package was loaded from a file.
+ * originating from, or NULL if the package was loaded from a file.
* @param pkg a pointer to package
* @return a pointer to the DB containing pkg, or NULL.
*/
@@ -534,6 +670,9 @@ size_t alpm_pkg_changelog_read(void *ptr, size_t size,
int alpm_pkg_changelog_close(const pmpkg_t *pkg, void *fp);
+/** Returns whether the package has an install scriptlet.
+ * @return 0 if FALSE, TRUE otherwise
+ */
int alpm_pkg_has_scriptlet(pmpkg_t *pkg);
/** Returns the size of download.
@@ -550,20 +689,18 @@ alpm_list_t *alpm_pkg_unused_deltas(pmpkg_t *pkg);
/** @} */
/*
- * Deltas
+ * Signatures
*/
-const char *alpm_delta_get_from(pmdelta_t *delta);
-const char *alpm_delta_get_to(pmdelta_t *delta);
-const char *alpm_delta_get_filename(pmdelta_t *delta);
-const char *alpm_delta_get_md5sum(pmdelta_t *delta);
-off_t alpm_delta_get_size(pmdelta_t *delta);
+int alpm_pkg_check_pgp_signature(pmpkg_t *pkg);
+
+int alpm_db_check_pgp_signature(pmdb_t *db);
+int alpm_db_set_pgp_verify(pmdb_t *db, pgp_verify_t verify);
/*
* Groups
*/
-const char *alpm_grp_get_name(const pmgrp_t *grp);
-alpm_list_t *alpm_grp_get_pkgs(const pmgrp_t *grp);
+
alpm_list_t *alpm_find_grp_pkgs(alpm_list_t *dbs, const char *name);
/*
@@ -726,59 +863,91 @@ typedef void (*alpm_trans_cb_conv)(pmtransconv_t, void *, void *,
/** Transaction Progress callback */
typedef void (*alpm_trans_cb_progress)(pmtransprog_t, const char *, int, size_t, size_t);
-int alpm_trans_get_flags(void);
+/** Returns the bitfield of flags for the current transaction.
+ * @param handle the context handle
+ * @return the bitfield of transaction flags
+ */
+pmtransflag_t alpm_trans_get_flags(pmhandle_t *handle);
/** Returns a list of packages added by the transaction.
+ * @param handle the context handle
* @return a list of pmpkg_t structures
*/
-alpm_list_t * alpm_trans_get_add(void);
+alpm_list_t * alpm_trans_get_add(pmhandle_t *handle);
/** Returns the list of packages removed by the transaction.
+ * @param handle the context handle
* @return a list of pmpkg_t structures
*/
-alpm_list_t * alpm_trans_get_remove(void);
+alpm_list_t * alpm_trans_get_remove(pmhandle_t *handle);
/** Initialize the transaction.
+ * @param handle the context handle
* @param flags flags of the transaction (like nodeps, etc)
* @param event event callback function pointer
* @param conv question callback function pointer
* @param progress progress callback function pointer
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
-int alpm_trans_init(pmtransflag_t flags,
+int alpm_trans_init(pmhandle_t *handle, pmtransflag_t flags,
alpm_trans_cb_event cb_event, alpm_trans_cb_conv conv,
alpm_trans_cb_progress cb_progress);
/** Prepare a transaction.
+ * @param handle the context handle
* @param data the address of an alpm_list where a list
* of pmdepmissing_t objects is dumped (conflicting packages)
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
-int alpm_trans_prepare(alpm_list_t **data);
+int alpm_trans_prepare(pmhandle_t *handle, alpm_list_t **data);
/** Commit a transaction.
+ * @param handle the context handle
* @param data the address of an alpm_list where detailed description
* of an error can be dumped (ie. list of conflicting files)
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
-int alpm_trans_commit(alpm_list_t **data);
+int alpm_trans_commit(pmhandle_t *handle, alpm_list_t **data);
/** Interrupt a transaction.
+ * @param handle the context handle
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
-int alpm_trans_interrupt(void);
+int alpm_trans_interrupt(pmhandle_t *handle);
/** Release a transaction.
+ * @param handle the context handle
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
-int alpm_trans_release(void);
+int alpm_trans_release(pmhandle_t *handle);
/** @} */
/** @name Common Transactions */
/** @{ */
-int alpm_sync_sysupgrade(int enable_downgrade);
-int alpm_add_pkg(pmpkg_t *pkg);
-int alpm_remove_pkg(pmpkg_t *pkg);
+
+/** Search for packages to upgrade and add them to the transaction.
+ * @param handle the context handle
+ * @param enable_downgrade allow downgrading of packages if the remote version is lower
+ * @return 0 on success, -1 on error (pm_errno is set accordingly)
+ */
+int alpm_sync_sysupgrade(pmhandle_t *handle, int enable_downgrade);
+
+/** Add a package to the transaction.
+ * If the package was loaded by alpm_pkg_load(), it will be freed upon
+ * alpm_trans_release() invocation.
+ * @param handle the context handle
+ * @param pkg the package to add
+ * @return 0 on success, -1 on error (pm_errno is set accordingly)
+ */
+int alpm_add_pkg(pmhandle_t *handle, pmpkg_t *pkg);
+
+/** Add a package removal action to the transaction.
+ * @param handle the context handle
+ * @param pkg the package to uninstall
+ * @return 0 on success, -1 on error (pm_errno is set accordingly)
+ */
+int alpm_remove_pkg(pmhandle_t *handle, pmpkg_t *pkg);
+
/** @} */
/** @addtogroup alpm_api_depends Dependency Functions
@@ -787,57 +956,13 @@ int alpm_remove_pkg(pmpkg_t *pkg);
* @{
*/
-/** Types of version constraints in dependency specs. */
-typedef enum _pmdepmod_t {
- /** No version constraint */
- PM_DEP_MOD_ANY = 1,
- /** Test version equality (package=x.y.z) */
- PM_DEP_MOD_EQ,
- /** Test for at least a version (package>=x.y.z) */
- PM_DEP_MOD_GE,
- /** Test for at most a version (package<=x.y.z) */
- PM_DEP_MOD_LE,
- /** Test for greater than some version (package>x.y.z) */
- PM_DEP_MOD_GT,
- /** Test for less than some version (package<x.y.z) */
- PM_DEP_MOD_LT
-} pmdepmod_t;
-
-alpm_list_t *alpm_checkdeps(alpm_list_t *pkglist, int reversedeps,
- alpm_list_t *remove, alpm_list_t *upgrade);
+alpm_list_t *alpm_checkdeps(pmhandle_t *handle, alpm_list_t *pkglist,
+ alpm_list_t *remove, alpm_list_t *upgrade, int reversedeps);
pmpkg_t *alpm_find_satisfier(alpm_list_t *pkgs, const char *depstring);
-pmpkg_t *alpm_find_dbs_satisfier(alpm_list_t *dbs, const char *depstring);
-
-const char *alpm_miss_get_target(const pmdepmissing_t *miss);
-pmdepend_t *alpm_miss_get_dep(pmdepmissing_t *miss);
-const char *alpm_miss_get_causingpkg(const pmdepmissing_t *miss);
-
-alpm_list_t *alpm_checkconflicts(alpm_list_t *pkglist);
-
-const char *alpm_conflict_get_package1(pmconflict_t *conflict);
-const char *alpm_conflict_get_package2(pmconflict_t *conflict);
-const char *alpm_conflict_get_reason(pmconflict_t *conflict);
+pmpkg_t *alpm_find_dbs_satisfier(pmhandle_t *handle,
+ alpm_list_t *dbs, const char *depstring);
-/** Returns the type of version constraint.
- * @param dep a dependency info structure
- * @return the type of version constraint (PM_DEP_MOD_ANY if no version
- * is specified).
- */
-pmdepmod_t alpm_dep_get_mod(const pmdepend_t *dep);
-
-/** Returns the package name of a dependency constraint.
- * @param dep a dependency info structure
- * @return a pointer to an internal string.
- */
-const char *alpm_dep_get_name(const pmdepend_t *dep);
-
-/** Returns the version specified by a dependency constraint.
- * The version information is returned as a string in the same format
- * as given by alpm_pkg_get_version().
- * @param dep a dependency info structure
- * @return a pointer to an internal string.
- */
-const char *alpm_dep_get_version(const pmdepend_t *dep);
+alpm_list_t *alpm_checkconflicts(pmhandle_t *handle, alpm_list_t *pkglist);
/** Returns a newly allocated string representing the dependency information.
* @param dep a dependency info structure
@@ -847,21 +972,6 @@ char *alpm_dep_compute_string(const pmdepend_t *dep);
/** @} */
-/** @addtogroup alpm_api_fileconflicts File Conflicts Functions
- * Functions to manipulate file conflict information.
- * @{
- */
-
-typedef enum _pmfileconflicttype_t {
- PM_FILECONFLICT_TARGET = 1,
- PM_FILECONFLICT_FILESYSTEM
-} pmfileconflicttype_t;
-
-const char *alpm_fileconflict_get_target(pmfileconflict_t *conflict);
-pmfileconflicttype_t alpm_fileconflict_get_type(pmfileconflict_t *conflict);
-const char *alpm_fileconflict_get_file(pmfileconflict_t *conflict);
-const char *alpm_fileconflict_get_ctarget(pmfileconflict_t *conflict);
-
/** @} */
/*
@@ -892,6 +1002,7 @@ enum _pmerrno_t {
PM_ERR_DB_NULL,
PM_ERR_DB_NOT_NULL,
PM_ERR_DB_NOT_FOUND,
+ PM_ERR_DB_INVALID,
PM_ERR_DB_VERSION,
PM_ERR_DB_WRITE,
PM_ERR_DB_REMOVE,
@@ -916,6 +1027,10 @@ enum _pmerrno_t {
PM_ERR_PKG_INVALID_NAME,
PM_ERR_PKG_INVALID_ARCH,
PM_ERR_PKG_REPO_NOT_FOUND,
+ /* Signatures */
+ PM_ERR_SIG_MISSINGDIR,
+ PM_ERR_SIG_INVALID,
+ PM_ERR_SIG_UNKNOWN,
/* Deltas */
PM_ERR_DLT_INVALID,
PM_ERR_DLT_PATCHFAILED,
@@ -925,26 +1040,28 @@ enum _pmerrno_t {
PM_ERR_FILE_CONFLICTS,
/* Misc */
PM_ERR_RETRIEVE,
- PM_ERR_WRITE,
PM_ERR_INVALID_REGEX,
/* External library errors */
PM_ERR_LIBARCHIVE,
- PM_ERR_LIBFETCH,
- PM_ERR_EXTERNAL_DOWNLOAD
+ PM_ERR_LIBCURL,
+ PM_ERR_EXTERNAL_DOWNLOAD,
+ PM_ERR_GPGME
};
-/** The number of the last error that occurred. */
-extern enum _pmerrno_t pm_errno;
+/** Returns the current error code from the handle. */
+enum _pmerrno_t alpm_errno(pmhandle_t *handle);
/** Returns the string corresponding to an error number. */
-const char *alpm_strerror(int err);
-
-/** Returns the string corresponding to pm_errno. */
-const char *alpm_strerrorlast(void);
+const char *alpm_strerror(enum _pmerrno_t err);
/* End of alpm_api_errors */
/** @} */
+pmhandle_t *alpm_initialize(const char *root, const char *dbpath,
+ enum _pmerrno_t *err);
+int alpm_release(pmhandle_t *handle);
+const char *alpm_version(void);
+
/* End of alpm_api */
/** @} */