summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/alpm.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libalpm/alpm.h')
-rw-r--r--lib/libalpm/alpm.h253
1 files changed, 175 insertions, 78 deletions
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index cb643d29..ee55d0b9 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -45,9 +45,36 @@ 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;
+
+/**
+ * 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;
@@ -59,18 +86,12 @@ 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);
-
-/*
* Logging facilities
*/
-/* Levels */
+/**
+ * Logging Levels
+ */
typedef enum _pmloglevel_t {
PM_LOG_ERROR = 1,
PM_LOG_WARNING = (1 << 1),
@@ -85,9 +106,16 @@ int alpm_logaction(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
@@ -109,100 +137,119 @@ char *alpm_fetch_pkgurl(const char *url);
* @{
*/
-/** @name The logging callback. */
-/* @{ */
+/** Returns the callback used for logging. */
alpm_cb_log alpm_option_get_logcb(void);
-void alpm_option_set_logcb(alpm_cb_log cb);
-/* @} */
+/** Sets the callback used for logging. */
+int alpm_option_set_logcb(alpm_cb_log cb);
-/** Get/set the download progress callback. */
+/** Returns the callback used to report download progress. */
alpm_cb_download alpm_option_get_dlcb(void);
-void alpm_option_set_dlcb(alpm_cb_download cb);
+/** Sets the callback used to report download progress. */
+int alpm_option_set_dlcb(alpm_cb_download cb);
-/** Get/set the downloader callback. */
+/** Returns the downloading callback. */
alpm_cb_fetch alpm_option_get_fetchcb(void);
-void alpm_option_set_fetchcb(alpm_cb_fetch cb);
+/** Sets the downloading callback. */
+int alpm_option_set_fetchcb(alpm_cb_fetch cb);
-/** Get/set the callback used when download size is known. */
+/** Returns the callback used to report total download size. */
alpm_cb_totaldl alpm_option_get_totaldlcb(void);
-void alpm_option_set_totaldlcb(alpm_cb_totaldl cb);
+/** Sets the callback used to report total download size. */
+int alpm_option_set_totaldlcb(alpm_cb_totaldl cb);
-/** Get/set the root of the destination filesystem. */
+/** Returns the root of the destination filesystem. Read-only. */
const char *alpm_option_get_root(void);
-int alpm_option_set_root(const char *root);
-/** Get/set the path to the database directory. */
+/** Returns the path to the database directory. Read-only. */
const char *alpm_option_get_dbpath(void);
-int alpm_option_set_dbpath(const char *dbpath);
-/** 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(void);
-/** Add a single directory to the package cache paths. */
+/** @name Accessors to the list of package cache directories.
+ * @{
+ */
+alpm_list_t *alpm_option_get_cachedirs(void);
+int alpm_option_set_cachedirs(alpm_list_t *cachedirs);
int alpm_option_add_cachedir(const char *cachedir);
-
-/** Remove a single directory from the package cache paths. */
int alpm_option_remove_cachedir(const char *cachedir);
+/** @} */
-/** Get/set the logfile name. */
+/** Returns the logfile name. */
const char *alpm_option_get_logfile(void);
+/** Sets the logfile name. */
int alpm_option_set_logfile(const char *logfile);
-/** 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 the signature directory path. */
+const char *alpm_option_get_signaturedir(void);
+/** Sets the signature directory path. */
+int alpm_option_set_signaturedir(const char *signaturedir);
-/** Get/set whether to use syslog (0 is FALSE, TRUE otherwise). */
+/** Returns whether to use syslog (0 is FALSE, TRUE otherwise). */
int alpm_option_get_usesyslog(void);
-void alpm_option_set_usesyslog(int usesyslog);
+/** Sets whether to use syslog (0 is FALSE, TRUE otherwise). */
+int 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(void);
-void alpm_option_add_noupgrade(const char *pkg);
-void alpm_option_set_noupgrades(alpm_list_t *noupgrade);
+int alpm_option_add_noupgrade(const char *pkg);
+int 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(void);
-void alpm_option_add_noextract(const char *pkg);
-void alpm_option_set_noextracts(alpm_list_t *noextract);
+int alpm_option_add_noextract(const char *pkg);
+int 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(void);
-void alpm_option_add_ignorepkg(const char *pkg);
-void alpm_option_set_ignorepkgs(alpm_list_t *ignorepkgs);
+int alpm_option_add_ignorepkg(const char *pkg);
+int 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(void);
-void alpm_option_add_ignoregrp(const char *grp);
-void alpm_option_set_ignoregrps(alpm_list_t *ignoregrps);
+int alpm_option_add_ignoregrp(const char *grp);
+int alpm_option_set_ignoregrps(alpm_list_t *ignoregrps);
int alpm_option_remove_ignoregrp(const char *grp);
+/** @} */
-/** Get/set the targeted architecture. */
+/** Returns the targeted architecture. */
const char *alpm_option_get_arch(void);
-void alpm_option_set_arch(const char *arch);
+/** Sets the targeted architecture. */
+int alpm_option_set_arch(const char *arch);
int alpm_option_get_usedelta(void);
-void alpm_option_set_usedelta(int usedelta);
+int alpm_option_set_usedelta(int usedelta);
int alpm_option_get_checkspace(void);
-void alpm_option_set_checkspace(int checkspace);
+int alpm_option_set_checkspace(int checkspace);
-/** @} */
+pgp_verify_t alpm_option_get_default_sigverify(void);
+int alpm_option_set_default_sigverify(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.
@@ -237,9 +284,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
@@ -253,12 +301,14 @@ const char *alpm_db_get_name(const pmdb_t *db);
*/
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 +338,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 +363,18 @@ 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 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(const char *filename, int full, pgp_verify_t check_sig,
+ pmpkg_t **pkg);
/** Free a package.
* @param pkg package pointer to free
@@ -498,9 +552,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 +588,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,6 +607,15 @@ alpm_list_t *alpm_pkg_unused_deltas(pmpkg_t *pkg);
/** @} */
/*
+ * Signatures
+ */
+
+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);
+
+/*
* Deltas
*/
@@ -726,6 +792,9 @@ 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);
+/** Returns the bitfield of flags for the current transaction.
+ * @sa _pmtransflag_t
+ */
int alpm_trans_get_flags(void);
/** Returns a list of packages added by the transaction.
@@ -776,9 +845,27 @@ int alpm_trans_release(void);
/** @name Common Transactions */
/** @{ */
+
+/** Search for packages to upgrade and add them to the transaction.
+ * @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(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 pkg the package to add
+ * @return 0 on success, -1 on error (pm_errno is set accordingly)
+ */
int alpm_add_pkg(pmpkg_t *pkg);
+
+/** Add a package removal action to the transaction.
+ * @param pkg the package to uninstall
+ * @return 0 on success, -1 on error (pm_errno is set accordingly)
+ */
int alpm_remove_pkg(pmpkg_t *pkg);
+
/** @} */
/** @addtogroup alpm_api_depends Dependency Functions
@@ -916,6 +1003,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,
@@ -929,8 +1020,9 @@ enum _pmerrno_t {
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. */
@@ -945,6 +1037,11 @@ const char *alpm_strerrorlast(void);
/* 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 */
/** @} */