Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm/package.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libalpm/package.c')
-rw-r--r--lib/libalpm/package.c1040
1 files changed, 522 insertions, 518 deletions
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index 8a3f6ea1..a841bf58 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -48,7 +48,6 @@
#include "cache.h"
#include "provide.h"
#include "handle.h"
-#include "versioncmp.h"
#include "alpm.h"
/** \addtogroup alpm_packages Package Functions
@@ -63,7 +62,7 @@
*/
int SYMEXPORT alpm_pkg_load(const char *filename, pmpkg_t **pkg)
{
- _alpm_log(PM_LOG_FUNCTION, "enter alpm_pkg_load");
+ _alpm_log(PM_LOG_FUNCTION, "enter alpm_pkg_load\n");
/* Sanity checks */
ASSERT(filename != NULL && strlen(filename) != 0, RET_ERR(PM_ERR_WRONG_ARGS, -1));
@@ -84,7 +83,7 @@ int SYMEXPORT alpm_pkg_load(const char *filename, pmpkg_t **pkg)
*/
int SYMEXPORT alpm_pkg_free(pmpkg_t *pkg)
{
- _alpm_log(PM_LOG_FUNCTION, "enter alpm_pkg_free");
+ _alpm_log(PM_LOG_FUNCTION, "enter alpm_pkg_free\n");
ASSERT(pkg != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1));
@@ -96,67 +95,14 @@ int SYMEXPORT alpm_pkg_free(pmpkg_t *pkg)
return(0);
}
-/** Check the integrity (with sha1) of a package from the sync cache.
- * @param pkg package pointer
- * @return 0 on success, -1 on error (pm_errno is set accordingly)
- */
-int alpm_pkg_checksha1sum(pmpkg_t *pkg)
-{
- char path[PATH_MAX];
- struct stat buf;
- char *sha1sum = NULL;
- alpm_list_t *i;
- int retval = 0;
-
- ALPM_LOG_FUNC;
-
- ASSERT(pkg != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1));
- /* We only inspect packages from sync repositories */
- ASSERT(pkg->origin == PKG_FROM_CACHE, RET_ERR(PM_ERR_PKG_INVALID, -1));
- ASSERT(pkg->data != handle->db_local, RET_ERR(PM_ERR_PKG_INVALID, -1));
-
- /* Loop through the cache dirs until we find a matching file */
- for(i = alpm_option_get_cachedirs(); i; i = alpm_list_next(i)) {
- snprintf(path, PATH_MAX, "%s%s-%s" PKGEXT, (char*)alpm_list_getdata(i),
- alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg));
- if(stat(path, &buf) == 0) {
- break;
- }
- }
-
- sha1sum = alpm_get_sha1sum(path);
- if(sha1sum == NULL) {
- _alpm_log(PM_LOG_ERROR, _("could not get sha1sum for package %s-%s"),
- alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg));
- pm_errno = PM_ERR_NOT_A_FILE;
- retval = -1;
- } else {
- if(strcmp(sha1sum, alpm_pkg_get_sha1sum(pkg)) == 0) {
- _alpm_log(PM_LOG_DEBUG, _("sha1sums for package %s-%s match"),
- alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg));
- } else {
- _alpm_log(PM_LOG_ERROR, _("sha1sums do not match for package %s-%s"),
- alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg));
- pm_errno = PM_ERR_PKG_INVALID;
- retval = -1;
- }
- }
-
- FREE(sha1sum);
-
- return(retval);
-}
-
/** Check the integrity (with md5) of a package from the sync cache.
* @param pkg package pointer
* @return 0 on success, -1 on error (pm_errno is set accordingly)
*/
-int alpm_pkg_checkmd5sum(pmpkg_t *pkg)
+int SYMEXPORT alpm_pkg_checkmd5sum(pmpkg_t *pkg)
{
- char path[PATH_MAX];
- struct stat buf;
+ char *fpath;
char *md5sum = NULL;
- alpm_list_t *i;
int retval = 0;
ALPM_LOG_FUNC;
@@ -164,43 +110,34 @@ int alpm_pkg_checkmd5sum(pmpkg_t *pkg)
ASSERT(pkg != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1));
/* We only inspect packages from sync repositories */
ASSERT(pkg->origin == PKG_FROM_CACHE, RET_ERR(PM_ERR_PKG_INVALID, -1));
- ASSERT(pkg->data != handle->db_local, RET_ERR(PM_ERR_PKG_INVALID, -1));
-
- /* Loop through the cache dirs until we find a matching file */
- for(i = alpm_option_get_cachedirs(); i; i = alpm_list_next(i)) {
- snprintf(path, PATH_MAX, "%s%s-%s" PKGEXT, (char*)alpm_list_getdata(i),
- alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg));
- if(stat(path, &buf) == 0) {
- break;
- }
- }
+ ASSERT(pkg->origin_data.db != handle->db_local, RET_ERR(PM_ERR_PKG_INVALID, -1));
+
+ fpath = _alpm_filecache_find(alpm_pkg_get_filename(pkg));
+ md5sum = alpm_get_md5sum(fpath);
- md5sum = alpm_get_md5sum(path);
if(md5sum == NULL) {
- _alpm_log(PM_LOG_ERROR, _("could not get md5sum for package %s-%s"),
+ _alpm_log(PM_LOG_ERROR, _("could not get md5sum for package %s-%s\n"),
alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg));
pm_errno = PM_ERR_NOT_A_FILE;
retval = -1;
} else {
if(strcmp(md5sum, alpm_pkg_get_md5sum(pkg)) == 0) {
- _alpm_log(PM_LOG_DEBUG, _("md5sums for package %s-%s match"),
+ _alpm_log(PM_LOG_DEBUG, "md5sums for package %s-%s match\n",
alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg));
} else {
- _alpm_log(PM_LOG_ERROR, _("md5sums do not match for package %s-%s"),
+ _alpm_log(PM_LOG_ERROR, _("md5sums do not match for package %s-%s\n"),
alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg));
pm_errno = PM_ERR_PKG_INVALID;
retval = -1;
}
}
+ FREE(fpath);
FREE(md5sum);
return(retval);
}
-
-
-
/** Compare versions.
* @param ver1 first version
* @param ver2 secont version
@@ -224,9 +161,7 @@ static char *_supported_archs[] = {
/**
* @brief Determine if a package name has -ARCH tacked on.
- *
* @param pkgname name of the package to parse
- *
* @return pointer to start of -ARCH text if it exists, else NULL
*/
char SYMEXPORT *alpm_pkg_name_hasarch(const char *pkgname)
@@ -261,8 +196,489 @@ char SYMEXPORT *alpm_pkg_name_hasarch(const char *pkgname)
return(NULL);
}
+const char SYMEXPORT *alpm_pkg_get_filename(pmpkg_t *pkg)
+{
+ ALPM_LOG_FUNC;
+
+ /* Sanity checks */
+ ASSERT(handle != NULL, return(NULL));
+ ASSERT(pkg != NULL, return(NULL));
+
+ if(!strlen(pkg->filename)) {
+ /* construct the file name, it's not in the desc file */
+ if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
+ _alpm_db_read(pkg->origin_data.db, pkg, INFRQ_DESC);
+ }
+ if(pkg->arch && strlen(pkg->arch) > 0) {
+ snprintf(pkg->filename, PKG_FILENAME_LEN, "%s-%s-%s" PKGEXT,
+ pkg->name, pkg->version, pkg->arch);
+ } else {
+ snprintf(pkg->filename, PKG_FILENAME_LEN, "%s-%s" PKGEXT,
+ pkg->name, pkg->version);
+ }
+ }
+
+ return pkg->filename;
+}
+
+const char SYMEXPORT *alpm_pkg_get_name(pmpkg_t *pkg)
+{
+ ALPM_LOG_FUNC;
+
+ /* Sanity checks */
+ ASSERT(handle != NULL, return(NULL));
+ ASSERT(pkg != NULL, return(NULL));
+
+ if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_BASE)) {
+ _alpm_db_read(pkg->origin_data.db, pkg, INFRQ_BASE);
+ }
+ return pkg->name;
+}
+
+const char SYMEXPORT *alpm_pkg_get_version(pmpkg_t *pkg)
+{
+ ALPM_LOG_FUNC;
+
+ /* Sanity checks */
+ ASSERT(handle != NULL, return(NULL));
+ ASSERT(pkg != NULL, return(NULL));
+
+ if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_BASE)) {
+ _alpm_db_read(pkg->origin_data.db, pkg, INFRQ_BASE);
+ }
+ return pkg->version;
+}
+
+const char SYMEXPORT *alpm_pkg_get_desc(pmpkg_t *pkg)
+{
+ ALPM_LOG_FUNC;
+
+ /* Sanity checks */
+ ASSERT(handle != NULL, return(NULL));
+ ASSERT(pkg != NULL, return(NULL));
+
+ if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
+ _alpm_db_read(pkg->origin_data.db, pkg, INFRQ_DESC);
+ }
+ return pkg->desc;
+}
+
+const char SYMEXPORT *alpm_pkg_get_url(pmpkg_t *pkg)
+{
+ ALPM_LOG_FUNC;
+
+ /* Sanity checks */
+ ASSERT(handle != NULL, return(NULL));
+ ASSERT(pkg != NULL, return(NULL));
+
+ if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
+ _alpm_db_read(pkg->origin_data.db, pkg, INFRQ_DESC);
+ }
+ return pkg->url;
+}
+
+const char SYMEXPORT *alpm_pkg_get_builddate(pmpkg_t *pkg)
+{
+ ALPM_LOG_FUNC;
+
+ /* Sanity checks */
+ ASSERT(handle != NULL, return(NULL));
+ ASSERT(pkg != NULL, return(NULL));
+
+ if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
+ _alpm_db_read(pkg->origin_data.db, pkg, INFRQ_DESC);
+ }
+ return pkg->builddate;
+}
+
+const char SYMEXPORT *alpm_pkg_get_installdate(pmpkg_t *pkg)
+{
+ ALPM_LOG_FUNC;
+
+ /* Sanity checks */
+ ASSERT(handle != NULL, return(NULL));
+ ASSERT(pkg != NULL, return(NULL));
+
+ if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
+ _alpm_db_read(pkg->origin_data.db, pkg, INFRQ_DESC);
+ }
+ return pkg->installdate;
+}
+
+const char SYMEXPORT *alpm_pkg_get_packager(pmpkg_t *pkg)
+{
+ ALPM_LOG_FUNC;
+
+ /* Sanity checks */
+ ASSERT(handle != NULL, return(NULL));
+ ASSERT(pkg != NULL, return(NULL));
+
+ if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
+ _alpm_db_read(pkg->origin_data.db, pkg, INFRQ_DESC);
+ }
+ return pkg->packager;
+}
+
+const char SYMEXPORT *alpm_pkg_get_md5sum(pmpkg_t *pkg)
+{
+ ALPM_LOG_FUNC;
+
+ /* Sanity checks */
+ ASSERT(handle != NULL, return(NULL));
+ ASSERT(pkg != NULL, return(NULL));
+
+ if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
+ _alpm_db_read(pkg->origin_data.db, pkg, INFRQ_DESC);
+ }
+ return pkg->md5sum;
+}
+
+const char SYMEXPORT *alpm_pkg_get_arch(pmpkg_t *pkg)
+{
+ ALPM_LOG_FUNC;
+
+ /* Sanity checks */
+ ASSERT(handle != NULL, return(NULL));
+ ASSERT(pkg != NULL, return(NULL));
+
+ if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
+ _alpm_db_read(pkg->origin_data.db, pkg, INFRQ_DESC);
+ }
+ return pkg->arch;
+}
+
+unsigned long SYMEXPORT alpm_pkg_get_size(pmpkg_t *pkg)
+{
+ ALPM_LOG_FUNC;
+
+ /* Sanity checks */
+ ASSERT(handle != NULL, return(-1));
+ ASSERT(pkg != NULL, return(-1));
+
+ if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
+ _alpm_db_read(pkg->origin_data.db, pkg, INFRQ_DESC);
+ }
+ return pkg->size;
+}
+
+unsigned long SYMEXPORT alpm_pkg_get_isize(pmpkg_t *pkg)
+{
+ ALPM_LOG_FUNC;
+
+ /* Sanity checks */
+ ASSERT(handle != NULL, return(-1));
+ ASSERT(pkg != NULL, return(-1));
+
+ if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
+ _alpm_db_read(pkg->origin_data.db, pkg, INFRQ_DESC);
+ }
+ return pkg->isize;
+}
+
+pmpkgreason_t SYMEXPORT alpm_pkg_get_reason(pmpkg_t *pkg)
+{
+ ALPM_LOG_FUNC;
+
+ /* Sanity checks */
+ ASSERT(handle != NULL, return(-1));
+ ASSERT(pkg != NULL, return(-1));
+
+ if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
+ _alpm_db_read(pkg->origin_data.db, pkg, INFRQ_DESC);
+ }
+ return pkg->reason;
+}
+
+alpm_list_t SYMEXPORT *alpm_pkg_get_licenses(pmpkg_t *pkg)
+{
+ ALPM_LOG_FUNC;
+
+ /* Sanity checks */
+ ASSERT(handle != NULL, return(NULL));
+ ASSERT(pkg != NULL, return(NULL));
+
+ if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
+ _alpm_db_read(pkg->origin_data.db, pkg, INFRQ_DESC);
+ }
+ return pkg->licenses;
+}
+
+alpm_list_t SYMEXPORT *alpm_pkg_get_groups(pmpkg_t *pkg)
+{
+ ALPM_LOG_FUNC;
+
+ /* Sanity checks */
+ ASSERT(handle != NULL, return(NULL));
+ ASSERT(pkg != NULL, return(NULL));
+
+ if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
+ _alpm_db_read(pkg->origin_data.db, pkg, INFRQ_DESC);
+ }
+ return pkg->groups;
+}
+
+/* depends */
+alpm_list_t SYMEXPORT *alpm_pkg_get_depends(pmpkg_t *pkg)
+{
+ ALPM_LOG_FUNC;
+
+ /* Sanity checks */
+ ASSERT(handle != NULL, return(NULL));
+ ASSERT(pkg != NULL, return(NULL));
+
+ if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DEPENDS)) {
+ _alpm_db_read(pkg->origin_data.db, pkg, INFRQ_DEPENDS);
+ }
+ return pkg->depends;
+}
+
+alpm_list_t SYMEXPORT *alpm_pkg_get_requiredby(pmpkg_t *pkg)
+{
+ ALPM_LOG_FUNC;
+
+ /* Sanity checks */
+ ASSERT(handle != NULL, return(NULL));
+ ASSERT(pkg != NULL, return(NULL));
+
+ if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DEPENDS)) {
+ _alpm_db_read(pkg->origin_data.db, pkg, INFRQ_DEPENDS);
+ }
+ return pkg->requiredby;
+}
+
+alpm_list_t SYMEXPORT *alpm_pkg_get_conflicts(pmpkg_t *pkg)
+{
+ ALPM_LOG_FUNC;
+
+ /* Sanity checks */
+ ASSERT(handle != NULL, return(NULL));
+ ASSERT(pkg != NULL, return(NULL));
+
+ if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DEPENDS)) {
+ _alpm_db_read(pkg->origin_data.db, pkg, INFRQ_DEPENDS);
+ }
+ return pkg->conflicts;
+}
+
+alpm_list_t SYMEXPORT *alpm_pkg_get_provides(pmpkg_t *pkg)
+{
+ ALPM_LOG_FUNC;
+
+ /* Sanity checks */
+ ASSERT(handle != NULL, return(NULL));
+ ASSERT(pkg != NULL, return(NULL));
+
+ if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DEPENDS)) {
+ _alpm_db_read(pkg->origin_data.db, pkg, INFRQ_DEPENDS);
+ }
+ return pkg->provides;
+}
+
+alpm_list_t SYMEXPORT *alpm_pkg_get_replaces(pmpkg_t *pkg)
+{
+ ALPM_LOG_FUNC;
+
+ /* Sanity checks */
+ ASSERT(handle != NULL, return(NULL));
+ ASSERT(pkg != NULL, return(NULL));
+
+ if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
+ _alpm_db_read(pkg->origin_data.db, pkg, INFRQ_DESC);
+ }
+ return pkg->replaces;
+}
+
+alpm_list_t SYMEXPORT *alpm_pkg_get_files(pmpkg_t *pkg)
+{
+ ALPM_LOG_FUNC;
+
+ /* Sanity checks */
+ ASSERT(handle != NULL, return(NULL));
+ ASSERT(pkg != NULL, return(NULL));
+
+ if(pkg->origin == PKG_FROM_CACHE && pkg->origin_data.db == handle->db_local
+ && !(pkg->infolevel & INFRQ_FILES)) {
+ _alpm_db_read(pkg->origin_data.db, pkg, INFRQ_FILES);
+ }
+ return pkg->files;
+}
+
+alpm_list_t SYMEXPORT *alpm_pkg_get_backup(pmpkg_t *pkg)
+{
+ ALPM_LOG_FUNC;
+
+ /* Sanity checks */
+ ASSERT(handle != NULL, return(NULL));
+ ASSERT(pkg != NULL, return(NULL));
+
+ if(pkg->origin == PKG_FROM_CACHE && pkg->origin_data.db == handle->db_local
+ && !(pkg->infolevel & INFRQ_FILES)) {
+ _alpm_db_read(pkg->origin_data.db, pkg, INFRQ_FILES);
+ }
+ return pkg->backup;
+}
+
+unsigned short SYMEXPORT alpm_pkg_has_scriptlet(pmpkg_t *pkg)
+{
+ ALPM_LOG_FUNC;
+
+ /* Sanity checks */
+ ASSERT(handle != NULL, return(-1));
+ ASSERT(pkg != NULL, return(-1));
+
+ if(pkg->origin == PKG_FROM_CACHE && pkg->origin_data.db == handle->db_local
+ && !(pkg->infolevel & INFRQ_SCRIPTLET)) {
+ _alpm_db_read(pkg->origin_data.db, pkg, INFRQ_SCRIPTLET);
+ }
+ return pkg->scriptlet;
+}
+
+/**
+ * @brief Compute the packages requiring a given package.
+ * @param pkg a package
+ * @return the list of packages requiring pkg
+ *
+ * A depends on B through n depends <=> A listed in B's requiredby n times
+ * n == 0 or 1 in almost all cases */
+alpm_list_t SYMEXPORT *alpm_pkg_compute_requiredby(pmpkg_t *pkg)
+{
+ const alpm_list_t *i, *j;
+ alpm_list_t *reqs = NULL;
+
+ pmdb_t *localdb = alpm_option_get_localdb();
+ for(i = _alpm_db_get_pkgcache(localdb); i; i = i->next) {
+ if(!i->data) {
+ continue;
+ }
+ pmpkg_t *cachepkg = i->data;
+ const char *cachepkgname = alpm_pkg_get_name(cachepkg);
+
+ for(j = alpm_pkg_get_depends(cachepkg); j; j = j->next) {
+ pmdepend_t *dep;
+ int satisfies;
+
+ if(!j->data) {
+ continue;
+ }
+ dep = alpm_splitdep(j->data);
+ if(dep == NULL) {
+ continue;
+ }
+
+ satisfies = alpm_depcmp(pkg, dep);
+ FREE(dep);
+ if(satisfies) {
+ _alpm_log(PM_LOG_DEBUG, "adding '%s' in requiredby field for '%s'\n",
+ cachepkgname, pkg->name);
+ reqs = alpm_list_add(reqs, strdup(cachepkgname));
+ break;
+ }
+ }
+ }
+ return(reqs);
+}
+
/** @} */
+/* this function was taken from rpm 4.0.4 and rewritten */
+int _alpm_versioncmp(const char *a, const char *b)
+{
+ char str1[64], str2[64];
+ char *ptr1, *ptr2;
+ char *one, *two;
+ char *rel1 = NULL, *rel2 = NULL;
+ char oldch1, oldch2;
+ int is1num, is2num;
+ int rc;
+
+ ALPM_LOG_FUNC;
+
+ if(!strcmp(a,b)) {
+ return(0);
+ }
+
+ strncpy(str1, a, 64);
+ str1[63] = 0;
+ strncpy(str2, b, 64);
+ str2[63] = 0;
+
+ /* lose the release number */
+ for(one = str1; *one && *one != '-'; one++);
+ if(one) {
+ *one = '\0';
+ rel1 = ++one;
+ }
+ for(two = str2; *two && *two != '-'; two++);
+ if(two) {
+ *two = '\0';
+ rel2 = ++two;
+ }
+
+ one = str1;
+ two = str2;
+
+ while(*one || *two) {
+ while(*one && !isalnum((int)*one)) one++;
+ while(*two && !isalnum((int)*two)) two++;
+
+ ptr1 = one;
+ ptr2 = two;
+
+ /* find the next segment for each string */
+ if(isdigit((int)*ptr1)) {
+ is1num = 1;
+ while(*ptr1 && isdigit((int)*ptr1)) ptr1++;
+ } else {
+ is1num = 0;
+ while(*ptr1 && isalpha((int)*ptr1)) ptr1++;
+ }
+ if(isdigit((int)*ptr2)) {
+ is2num = 1;
+ while(*ptr2 && isdigit((int)*ptr2)) ptr2++;
+ } else {
+ is2num = 0;
+ while(*ptr2 && isalpha((int)*ptr2)) ptr2++;
+ }
+
+ oldch1 = *ptr1;
+ *ptr1 = '\0';
+ oldch2 = *ptr2;
+ *ptr2 = '\0';
+
+ /* see if we ran out of segments on one string */
+ if(one == ptr1 && two != ptr2) {
+ return(is2num ? -1 : 1);
+ }
+ if(one != ptr1 && two == ptr2) {
+ return(is1num ? 1 : -1);
+ }
+
+ /* see if we have a type mismatch (ie, one is alpha and one is digits) */
+ if(is1num && !is2num) return(1);
+ if(!is1num && is2num) return(-1);
+
+ if(is1num) while(*one == '0') one++;
+ if(is2num) while(*two == '0') two++;
+
+ rc = strverscmp(one, two);
+ if(rc) return(rc);
+
+ *ptr1 = oldch1;
+ *ptr2 = oldch2;
+ one = ptr1;
+ two = ptr2;
+ }
+
+ if((!*one) && (!*two)) {
+ /* compare release numbers */
+ if(rel1 && rel2 && strlen(rel1) && strlen(rel2)) return(_alpm_versioncmp(rel1, rel2));
+ return(0);
+ }
+
+ return(*one ? 1 : -1);
+}
+
+
pmpkg_t *_alpm_pkg_new(const char *name, const char *version)
{
pmpkg_t* pkg;
@@ -294,13 +710,12 @@ pmpkg_t *_alpm_pkg_dup(pmpkg_t *pkg)
ALPM_LOG_FUNC;
if((newpkg = calloc(1, sizeof(pmpkg_t))) == NULL) {
- _alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"), sizeof(pmpkg_t));
+ _alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes\n"), sizeof(pmpkg_t));
RET_ERR(PM_ERR_MEMORY, NULL);
}
memcpy(newpkg, pkg, sizeof(pmpkg_t));
newpkg->licenses = alpm_list_strdup(alpm_pkg_get_licenses(pkg));
- /*newpkg->desc_localized = alpm_list_strdup(pkg->desc_localized);*/
newpkg->requiredby = alpm_list_strdup(alpm_pkg_get_requiredby(pkg));
newpkg->conflicts = alpm_list_strdup(alpm_pkg_get_conflicts(pkg));
newpkg->files = alpm_list_strdup(alpm_pkg_get_files(pkg));
@@ -310,7 +725,11 @@ pmpkg_t *_alpm_pkg_dup(pmpkg_t *pkg)
newpkg->provides = alpm_list_strdup(alpm_pkg_get_provides(pkg));
newpkg->replaces = alpm_list_strdup(alpm_pkg_get_replaces(pkg));
/* internal */
- newpkg->data = (newpkg->origin == PKG_FROM_FILE) ? strdup(pkg->data) : pkg->data;
+ if(newpkg->origin == PKG_FROM_FILE) {
+ newpkg->origin_data.file = strdup(pkg->origin_data.file);
+ } else {
+ newpkg->origin_data.db = pkg->origin_data.db;
+ }
return(newpkg);
}
@@ -324,7 +743,6 @@ void _alpm_pkg_free(pmpkg_t *pkg)
}
FREELIST(pkg->licenses);
- /*FREELIST(pkg->desc_localized);*/
FREELIST(pkg->files);
FREELIST(pkg->backup);
FREELIST(pkg->depends);
@@ -334,7 +752,7 @@ void _alpm_pkg_free(pmpkg_t *pkg)
FREELIST(pkg->provides);
FREELIST(pkg->replaces);
if(pkg->origin == PKG_FROM_FILE) {
- FREE(pkg->data);
+ FREE(pkg->origin_data.file);
}
FREE(pkg);
}
@@ -348,7 +766,7 @@ int alpm_pkg_compare_versions(pmpkg_t *local_pkg, pmpkg_t *pkg)
if(pkg->origin == PKG_FROM_CACHE) {
/* ensure we have the /desc file, which contains the 'force' option */
- _alpm_db_read(pkg->data, pkg, INFRQ_DESC);
+ _alpm_db_read(pkg->origin_data.db, pkg, INFRQ_DESC);
}
/* compare versions and see if we need to upgrade */
@@ -357,7 +775,7 @@ int alpm_pkg_compare_versions(pmpkg_t *local_pkg, pmpkg_t *pkg)
if(alpm_list_find_str(handle->ignorepkg, alpm_pkg_get_name(pkg))) {
/* package should be ignored (IgnorePkg) */
if(cmp > 0) {
- _alpm_log(PM_LOG_WARNING, _("%s-%s: ignoring package upgrade (%s)"),
+ _alpm_log(PM_LOG_WARNING, _("%s-%s: ignoring package upgrade (%s)\n"),
alpm_pkg_get_name(local_pkg), alpm_pkg_get_version(local_pkg),
alpm_pkg_get_version(pkg));
}
@@ -366,12 +784,12 @@ int alpm_pkg_compare_versions(pmpkg_t *local_pkg, pmpkg_t *pkg)
if(cmp != 0 && pkg->force) {
cmp = 1;
- _alpm_log(PM_LOG_WARNING, _("%s: forcing upgrade to version %s"),
+ _alpm_log(PM_LOG_WARNING, _("%s: forcing upgrade to version %s\n"),
alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg));
} else if(cmp < 0) {
/* local version is newer */
- pmdb_t *db = pkg->data;
- _alpm_log(PM_LOG_WARNING, _("%s: local (%s) is newer than %s (%s)"),
+ pmdb_t *db = pkg->origin_data.db;
+ _alpm_log(PM_LOG_WARNING, _("%s: local (%s) is newer than %s (%s)\n"),
alpm_pkg_get_name(local_pkg), alpm_pkg_get_version(local_pkg),
alpm_db_get_name(db), alpm_pkg_get_version(pkg));
cmp = 0;
@@ -379,7 +797,7 @@ int alpm_pkg_compare_versions(pmpkg_t *local_pkg, pmpkg_t *pkg)
/* we have an upgrade, make sure we should actually do it */
if(_alpm_pkg_istoonew(pkg)) {
/* package too new (UpgradeDelay) */
- _alpm_log(PM_LOG_WARNING, _("%s-%s: delaying upgrade of package (%s)"),
+ _alpm_log(PM_LOG_WARNING, _("%s-%s: delaying upgrade of package (%s)\n"),
alpm_pkg_get_name(local_pkg), alpm_pkg_get_version(local_pkg),
alpm_pkg_get_version(pkg));
cmp = 0;
@@ -416,7 +834,7 @@ static int parse_descfile(const char *descfile, pmpkg_t *info)
ALPM_LOG_FUNC;
if((fp = fopen(descfile, "r")) == NULL) {
- _alpm_log(PM_LOG_ERROR, _("could not open file %s: %s"), descfile, strerror(errno));
+ _alpm_log(PM_LOG_ERROR, _("could not open file %s: %s\n"), descfile, strerror(errno));
return(-1);
}
@@ -430,7 +848,7 @@ static int parse_descfile(const char *descfile, pmpkg_t *info)
ptr = line;
key = strsep(&ptr, "=");
if(key == NULL || ptr == NULL) {
- _alpm_log(PM_LOG_DEBUG, _("%s: syntax error in description file line %d"),
+ _alpm_log(PM_LOG_DEBUG, "%s: syntax error in description file line %d\n",
info->name[0] != '\0' ? info->name : "error", linenum);
} else {
_alpm_strtrim(key);
@@ -441,22 +859,7 @@ static int parse_descfile(const char *descfile, pmpkg_t *info)
} else if(!strcmp(key, "PKGVER")) {
strncpy(info->version, ptr, sizeof(info->version));
} else if(!strcmp(key, "PKGDESC")) {
- /*
- char *lang_tmp;
- info->desc_localized = alpm_list_add(info->desc_localized, strdup(ptr));
- if((lang_tmp = malloc(strlen(setlocale(LC_ALL, "")))) == NULL) {
- RET_ERR(PM_ERR_MEMORY, -1);
- }
- strncpy(lang_tmp, setlocale(LC_ALL, ""), strlen(setlocale(LC_ALL, "")));
- if(info->desc_localized && !info->desc_localized->next) {
- */
strncpy(info->desc, ptr, sizeof(info->desc));
- /*
- } else if (ptr && !strncmp(ptr, lang_tmp, strlen(lang_tmp))) {
- strncpy(info->desc, ptr+strlen(lang_tmp)+1, sizeof(info->desc));
- }
- FREE(lang_tmp);
- */
} else if(!strcmp(key, "GROUP")) {
info->groups = alpm_list_add(info->groups, strdup(ptr));
} else if(!strcmp(key, "URL")) {
@@ -465,8 +868,6 @@ static int parse_descfile(const char *descfile, pmpkg_t *info)
info->licenses = alpm_list_add(info->licenses, strdup(ptr));
} else if(!strcmp(key, "BUILDDATE")) {
strncpy(info->builddate, ptr, sizeof(info->builddate));
- } else if(!strcmp(key, "BUILDTYPE")) {
- strncpy(info->buildtype, ptr, sizeof(info->buildtype));
} else if(!strcmp(key, "INSTALLDATE")) {
strncpy(info->installdate, ptr, sizeof(info->installdate));
} else if(!strcmp(key, "PACKAGER")) {
@@ -487,7 +888,7 @@ static int parse_descfile(const char *descfile, pmpkg_t *info)
} else if(!strcmp(key, "BACKUP")) {
info->backup = alpm_list_add(info->backup, strdup(ptr));
} else {
- _alpm_log(PM_LOG_DEBUG, _("%s: syntax error in description file line %d"),
+ _alpm_log(PM_LOG_DEBUG, "%s: syntax error in description file line %d\n",
info->name[0] != '\0' ? info->name : "error", linenum);
}
}
@@ -527,7 +928,8 @@ pmpkg_t *_alpm_pkg_load(const char *pkgfile)
archive_read_support_compression_all(archive);
archive_read_support_format_all(archive);
- if (archive_read_open_file(archive, pkgfile, ARCHIVE_DEFAULT_BYTES_PER_BLOCK) != ARCHIVE_OK) {
+ if (archive_read_open_filename(archive, pkgfile,
+ ARCHIVE_DEFAULT_BYTES_PER_BLOCK) != ARCHIVE_OK) {
RET_ERR(PM_ERR_PKG_OPEN, NULL);
}
@@ -561,15 +963,15 @@ pmpkg_t *_alpm_pkg_load(const char *pkgfile)
archive_read_data_into_fd (archive, fd);
/* parse the info file */
if(parse_descfile(descfile, info) == -1) {
- _alpm_log(PM_LOG_ERROR, _("could not parse the package description file"));
+ _alpm_log(PM_LOG_ERROR, _("could not parse the package description file\n"));
goto pkg_invalid;
}
if(!strlen(info->name)) {
- _alpm_log(PM_LOG_ERROR, _("missing package name in %s"), pkgfile);
+ _alpm_log(PM_LOG_ERROR, _("missing package name in %s\n"), pkgfile);
goto pkg_invalid;
}
if(!strlen(info->version)) {
- _alpm_log(PM_LOG_ERROR, _("missing package version in %s"), pkgfile);
+ _alpm_log(PM_LOG_ERROR, _("missing package version in %s\n"), pkgfile);
goto pkg_invalid;
}
config = 1;
@@ -604,7 +1006,7 @@ pmpkg_t *_alpm_pkg_load(const char *pkgfile)
FREE(str);
fclose(fp);
if(unlink(fn)) {
- _alpm_log(PM_LOG_WARNING, _("could not remove tempfile %s"), fn);
+ _alpm_log(PM_LOG_WARNING, _("could not remove tempfile %s\n"), fn);
}
FREE(fn);
close(fd);
@@ -620,27 +1022,27 @@ pmpkg_t *_alpm_pkg_load(const char *pkgfile)
}
if(archive_read_data_skip(archive)) {
- _alpm_log(PM_LOG_ERROR, _("error while reading package: %s"), archive_error_string(archive));
+ _alpm_log(PM_LOG_ERROR, _("error while reading package: %s\n"), archive_error_string(archive));
pm_errno = PM_ERR_LIBARCHIVE_ERROR;
goto error;
}
expath = NULL;
}
if(ret != ARCHIVE_EOF) { /* An error occured */
- _alpm_log(PM_LOG_ERROR, _("error while reading package: %s"), archive_error_string(archive));
+ _alpm_log(PM_LOG_ERROR, _("error while reading package: %s\n"), archive_error_string(archive));
pm_errno = PM_ERR_LIBARCHIVE_ERROR;
goto error;
}
if(!config) {
- _alpm_log(PM_LOG_ERROR, _("missing package metadata"), pkgfile);
+ _alpm_log(PM_LOG_ERROR, _("missing package metadata\n"), pkgfile);
goto error;
}
archive_read_finish(archive);
if(!filelist) {
- _alpm_log(PM_LOG_ERROR, _("missing package filelist in %s, generating one"), pkgfile);
+ _alpm_log(PM_LOG_ERROR, _("missing package filelist in %s, generating one\n"), pkgfile);
info->files = all_files;
} else {
alpm_list_free_inner(all_files, free);
@@ -653,7 +1055,7 @@ pmpkg_t *_alpm_pkg_load(const char *pkgfile)
/* internal */
info->origin = PKG_FROM_FILE;
- info->data = strdup(pkgfile);
+ info->origin_data.file = strdup(pkgfile);
info->infolevel = 0xFF;
return(info);
@@ -750,409 +1152,11 @@ int _alpm_pkg_splitname(const char *target, char *name, char *version, int witha
return(0);
}
-/* scan the local db to fill in requiredby field of package,
+/* fill in requiredby field of package,
* used when we want to install or add a package */
void _alpm_pkg_update_requiredby(pmpkg_t *pkg)
{
- const alpm_list_t *i, *j;
-
- pmdb_t *localdb = alpm_option_get_localdb();
- for(i = _alpm_db_get_pkgcache(localdb); i; i = i->next) {
- if(!i->data) {
- continue;
- }
- pmpkg_t *cachepkg = i->data;
- const char *cachepkgname = alpm_pkg_get_name(cachepkg);
-
- for(j = alpm_pkg_get_depends(cachepkg); j; j = j->next) {
- pmdepend_t *dep;
- int satisfies;
-
- if(!j->data) {
- continue;
- }
- dep = alpm_splitdep(j->data);
- if(dep == NULL) {
- continue;
- }
-
- satisfies = alpm_depcmp(pkg, dep);
- free(dep);
- if(satisfies) {
- alpm_list_t *reqs = alpm_pkg_get_requiredby(pkg);
- _alpm_log(PM_LOG_DEBUG, _("adding '%s' in requiredby field for '%s'"),
- cachepkgname, pkg->name);
- reqs = alpm_list_add(reqs, strdup(cachepkgname));
- pkg->requiredby = reqs;
- break;
- }
- }
- }
-}
-
-const char SYMEXPORT *alpm_pkg_get_filename(pmpkg_t *pkg)
-{
- ALPM_LOG_FUNC;
-
- /* Sanity checks */
- ASSERT(handle != NULL, return(NULL));
- ASSERT(pkg != NULL, return(NULL));
-
- if(!strlen(pkg->filename)) {
- /* construct the file name, it's not in the desc file */
- if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
- _alpm_db_read(pkg->data, pkg, INFRQ_DESC);
- }
- if(pkg->arch && strlen(pkg->arch) > 0) {
- snprintf(pkg->filename, PKG_FILENAME_LEN, "%s-%s-%s" PKGEXT,
- pkg->name, pkg->version, pkg->arch);
- } else {
- snprintf(pkg->filename, PKG_FILENAME_LEN, "%s-%s" PKGEXT,
- pkg->name, pkg->version);
- }
- }
-
- return pkg->filename;
-}
-
-const char SYMEXPORT *alpm_pkg_get_name(pmpkg_t *pkg)
-{
- ALPM_LOG_FUNC;
-
- /* Sanity checks */
- ASSERT(handle != NULL, return(NULL));
- ASSERT(pkg != NULL, return(NULL));
-
- if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_BASE)) {
- _alpm_db_read(pkg->data, pkg, INFRQ_BASE);
- }
- return pkg->name;
-}
-
-const char SYMEXPORT *alpm_pkg_get_version(pmpkg_t *pkg)
-{
- ALPM_LOG_FUNC;
-
- /* Sanity checks */
- ASSERT(handle != NULL, return(NULL));
- ASSERT(pkg != NULL, return(NULL));
-
- if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_BASE)) {
- _alpm_db_read(pkg->data, pkg, INFRQ_BASE);
- }
- return pkg->version;
-}
-
-const char SYMEXPORT *alpm_pkg_get_desc(pmpkg_t *pkg)
-{
- ALPM_LOG_FUNC;
-
- /* Sanity checks */
- ASSERT(handle != NULL, return(NULL));
- ASSERT(pkg != NULL, return(NULL));
-
- if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
- _alpm_db_read(pkg->data, pkg, INFRQ_DESC);
- }
- return pkg->desc;
-}
-
-const char SYMEXPORT *alpm_pkg_get_url(pmpkg_t *pkg)
-{
- ALPM_LOG_FUNC;
-
- /* Sanity checks */
- ASSERT(handle != NULL, return(NULL));
- ASSERT(pkg != NULL, return(NULL));
-
- if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
- _alpm_db_read(pkg->data, pkg, INFRQ_DESC);
- }
- return pkg->url;
-}
-
-const char SYMEXPORT *alpm_pkg_get_builddate(pmpkg_t *pkg)
-{
- ALPM_LOG_FUNC;
-
- /* Sanity checks */
- ASSERT(handle != NULL, return(NULL));
- ASSERT(pkg != NULL, return(NULL));
-
- if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
- _alpm_db_read(pkg->data, pkg, INFRQ_DESC);
- }
- return pkg->builddate;
-}
-
-const char SYMEXPORT *alpm_pkg_get_buildtype(pmpkg_t *pkg)
-{
- ALPM_LOG_FUNC;
-
- /* Sanity checks */
- ASSERT(handle != NULL, return(NULL));
- ASSERT(pkg != NULL, return(NULL));
-
- if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
- _alpm_db_read(pkg->data, pkg, INFRQ_DESC);
- }
- return pkg->buildtype;
-}
-
-const char SYMEXPORT *alpm_pkg_get_installdate(pmpkg_t *pkg)
-{
- ALPM_LOG_FUNC;
-
- /* Sanity checks */
- ASSERT(handle != NULL, return(NULL));
- ASSERT(pkg != NULL, return(NULL));
-
- if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
- _alpm_db_read(pkg->data, pkg, INFRQ_DESC);
- }
- return pkg->installdate;
-}
-
-const char SYMEXPORT *alpm_pkg_get_packager(pmpkg_t *pkg)
-{
- ALPM_LOG_FUNC;
-
- /* Sanity checks */
- ASSERT(handle != NULL, return(NULL));
- ASSERT(pkg != NULL, return(NULL));
-
- if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
- _alpm_db_read(pkg->data, pkg, INFRQ_DESC);
- }
- return pkg->packager;
-}
-
-const char SYMEXPORT *alpm_pkg_get_md5sum(pmpkg_t *pkg)
-{
- ALPM_LOG_FUNC;
-
- /* Sanity checks */
- ASSERT(handle != NULL, return(NULL));
- ASSERT(pkg != NULL, return(NULL));
-
- if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
- _alpm_db_read(pkg->data, pkg, INFRQ_DESC);
- }
- return pkg->md5sum;
-}
-
-const char SYMEXPORT *alpm_pkg_get_sha1sum(pmpkg_t *pkg)
-{
- ALPM_LOG_FUNC;
-
- /* Sanity checks */
- ASSERT(handle != NULL, return(NULL));
- ASSERT(pkg != NULL, return(NULL));
-
- if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
- _alpm_db_read(pkg->data, pkg, INFRQ_DESC);
- }
- return pkg->sha1sum;
-}
-
-const char SYMEXPORT *alpm_pkg_get_arch(pmpkg_t *pkg)
-{
- ALPM_LOG_FUNC;
-
- /* Sanity checks */
- ASSERT(handle != NULL, return(NULL));
- ASSERT(pkg != NULL, return(NULL));
-
- if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
- _alpm_db_read(pkg->data, pkg, INFRQ_DESC);
- }
- return pkg->arch;
-}
-
-unsigned long SYMEXPORT alpm_pkg_get_size(pmpkg_t *pkg)
-{
- ALPM_LOG_FUNC;
-
- /* Sanity checks */
- ASSERT(handle != NULL, return(-1));
- ASSERT(pkg != NULL, return(-1));
-
- if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
- _alpm_db_read(pkg->data, pkg, INFRQ_DESC);
- }
- return pkg->size;
-}
-
-unsigned long SYMEXPORT alpm_pkg_get_isize(pmpkg_t *pkg)
-{
- ALPM_LOG_FUNC;
-
- /* Sanity checks */
- ASSERT(handle != NULL, return(-1));
- ASSERT(pkg != NULL, return(-1));
-
- if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
- _alpm_db_read(pkg->data, pkg, INFRQ_DESC);
- }
- return pkg->isize;
-}
-
-pmpkgreason_t SYMEXPORT alpm_pkg_get_reason(pmpkg_t *pkg)
-{
- ALPM_LOG_FUNC;
-
- /* Sanity checks */
- ASSERT(handle != NULL, return(-1));
- ASSERT(pkg != NULL, return(-1));
-
- if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
- _alpm_db_read(pkg->data, pkg, INFRQ_DESC);
- }
- return pkg->reason;
-}
-
-alpm_list_t SYMEXPORT *alpm_pkg_get_licenses(pmpkg_t *pkg)
-{
- ALPM_LOG_FUNC;
-
- /* Sanity checks */
- ASSERT(handle != NULL, return(NULL));
- ASSERT(pkg != NULL, return(NULL));
-
- if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
- _alpm_db_read(pkg->data, pkg, INFRQ_DESC);
- }
- return pkg->licenses;
-}
-
-alpm_list_t SYMEXPORT *alpm_pkg_get_groups(pmpkg_t *pkg)
-{
- ALPM_LOG_FUNC;
-
- /* Sanity checks */
- ASSERT(handle != NULL, return(NULL));
- ASSERT(pkg != NULL, return(NULL));
-
- if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
- _alpm_db_read(pkg->data, pkg, INFRQ_DESC);
- }
- return pkg->groups;
-}
-
-/* depends */
-alpm_list_t SYMEXPORT *alpm_pkg_get_depends(pmpkg_t *pkg)
-{
- ALPM_LOG_FUNC;
-
- /* Sanity checks */
- ASSERT(handle != NULL, return(NULL));
- ASSERT(pkg != NULL, return(NULL));
-
- if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DEPENDS)) {
- _alpm_db_read(pkg->data, pkg, INFRQ_DEPENDS);
- }
- return pkg->depends;
-}
-
-alpm_list_t SYMEXPORT *alpm_pkg_get_requiredby(pmpkg_t *pkg)
-{
- ALPM_LOG_FUNC;
-
- /* Sanity checks */
- ASSERT(handle != NULL, return(NULL));
- ASSERT(pkg != NULL, return(NULL));
-
- if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DEPENDS)) {
- _alpm_db_read(pkg->data, pkg, INFRQ_DEPENDS);
- }
- return pkg->requiredby;
-}
-
-alpm_list_t SYMEXPORT *alpm_pkg_get_conflicts(pmpkg_t *pkg)
-{
- ALPM_LOG_FUNC;
-
- /* Sanity checks */
- ASSERT(handle != NULL, return(NULL));
- ASSERT(pkg != NULL, return(NULL));
-
- if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DEPENDS)) {
- _alpm_db_read(pkg->data, pkg, INFRQ_DEPENDS);
- }
- return pkg->conflicts;
-}
-
-alpm_list_t SYMEXPORT *alpm_pkg_get_provides(pmpkg_t *pkg)
-{
- ALPM_LOG_FUNC;
-
- /* Sanity checks */
- ASSERT(handle != NULL, return(NULL));
- ASSERT(pkg != NULL, return(NULL));
-
- if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DEPENDS)) {
- _alpm_db_read(pkg->data, pkg, INFRQ_DEPENDS);
- }
- return pkg->provides;
-}
-
-alpm_list_t SYMEXPORT *alpm_pkg_get_replaces(pmpkg_t *pkg)
-{
- ALPM_LOG_FUNC;
-
- /* Sanity checks */
- ASSERT(handle != NULL, return(NULL));
- ASSERT(pkg != NULL, return(NULL));
-
- if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
- _alpm_db_read(pkg->data, pkg, INFRQ_DESC);
- }
- return pkg->replaces;
-}
-
-alpm_list_t SYMEXPORT *alpm_pkg_get_files(pmpkg_t *pkg)
-{
- ALPM_LOG_FUNC;
-
- /* Sanity checks */
- ASSERT(handle != NULL, return(NULL));
- ASSERT(pkg != NULL, return(NULL));
-
- if(pkg->origin == PKG_FROM_CACHE && pkg->data == handle->db_local
- && !(pkg->infolevel & INFRQ_FILES)) {
- _alpm_db_read(pkg->data, pkg, INFRQ_FILES);
- }
- return pkg->files;
-}
-
-alpm_list_t SYMEXPORT *alpm_pkg_get_backup(pmpkg_t *pkg)
-{
- ALPM_LOG_FUNC;
-
- /* Sanity checks */
- ASSERT(handle != NULL, return(NULL));
- ASSERT(pkg != NULL, return(NULL));
-
- if(pkg->origin == PKG_FROM_CACHE && pkg->data == handle->db_local
- && !(pkg->infolevel & INFRQ_FILES)) {
- _alpm_db_read(pkg->data, pkg, INFRQ_FILES);
- }
- return pkg->backup;
-}
-
-unsigned short SYMEXPORT alpm_pkg_has_scriptlet(pmpkg_t *pkg)
-{
- ALPM_LOG_FUNC;
-
- /* Sanity checks */
- ASSERT(handle != NULL, return(-1));
- ASSERT(pkg != NULL, return(-1));
-
- if(pkg->origin == PKG_FROM_CACHE && pkg->data == handle->db_local
- && !(pkg->infolevel & INFRQ_SCRIPTLET)) {
- _alpm_db_read(pkg->data, pkg, INFRQ_SCRIPTLET);
- }
- return pkg->scriptlet;
+ pkg->requiredby = alpm_pkg_compute_requiredby(pkg);
}
/* TODO this should either be public, or done somewhere else */