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.c120
1 files changed, 61 insertions, 59 deletions
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index a5ff238f..a4c3309e 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -1,7 +1,7 @@
/*
* package.c
*
- * Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2006-2012 Pacman Development Team <pacman-dev@archlinux.org>
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
* Copyright (c) 2005, 2006 by Christian Hamar <krics@linuxforum.hu>
@@ -21,8 +21,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "config.h"
-
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
@@ -48,7 +46,7 @@ int SYMEXPORT alpm_pkg_free(alpm_pkg_t *pkg)
ASSERT(pkg != NULL, return -1);
/* Only free packages loaded in user space */
- if(pkg->origin == PKG_FROM_FILE) {
+ if(pkg->origin == ALPM_PKG_FROM_FILE) {
_alpm_pkg_free(pkg);
}
@@ -64,12 +62,12 @@ int SYMEXPORT alpm_pkg_checkmd5sum(alpm_pkg_t *pkg)
ASSERT(pkg != NULL, return -1);
pkg->handle->pm_errno = 0;
/* We only inspect packages from sync repositories */
- ASSERT(pkg->origin == PKG_FROM_SYNCDB,
+ ASSERT(pkg->origin == ALPM_PKG_FROM_SYNCDB,
RET_ERR(pkg->handle, ALPM_ERR_WRONG_ARGS, -1));
fpath = _alpm_filecache_find(pkg->handle, pkg->filename);
- retval = _alpm_test_checksum(fpath, pkg->md5sum, ALPM_CSUM_MD5);
+ retval = _alpm_test_checksum(fpath, pkg->md5sum, ALPM_PKG_VALIDATION_MD5SUM);
if(retval == 0) {
return 0;
@@ -87,12 +85,13 @@ int SYMEXPORT alpm_pkg_checkmd5sum(alpm_pkg_t *pkg)
* populated package structures. */
static const char *_pkg_get_desc(alpm_pkg_t *pkg) { return pkg->desc; }
static const char *_pkg_get_url(alpm_pkg_t *pkg) { return pkg->url; }
-static time_t _pkg_get_builddate(alpm_pkg_t *pkg) { return pkg->builddate; }
-static time_t _pkg_get_installdate(alpm_pkg_t *pkg) { return pkg->installdate; }
+static alpm_time_t _pkg_get_builddate(alpm_pkg_t *pkg) { return pkg->builddate; }
+static alpm_time_t _pkg_get_installdate(alpm_pkg_t *pkg) { return pkg->installdate; }
static const char *_pkg_get_packager(alpm_pkg_t *pkg) { return pkg->packager; }
static const char *_pkg_get_arch(alpm_pkg_t *pkg) { return pkg->arch; }
static off_t _pkg_get_isize(alpm_pkg_t *pkg) { return pkg->isize; }
-static alpm_pkgreason_t _pkg_get_reason(alpm_pkg_t *pkg) { return pkg->reason; }
+static alpm_pkgreason_t _pkg_get_reason(alpm_pkg_t *pkg) { return pkg->reason; }
+static alpm_pkgvalidation_t _pkg_get_validation(alpm_pkg_t *pkg) { return pkg->validation; }
static int _pkg_has_scriptlet(alpm_pkg_t *pkg) { return pkg->scriptlet; }
static alpm_list_t *_pkg_get_licenses(alpm_pkg_t *pkg) { return pkg->licenses; }
@@ -136,6 +135,7 @@ struct pkg_operations default_pkg_ops = {
.get_arch = _pkg_get_arch,
.get_isize = _pkg_get_isize,
.get_reason = _pkg_get_reason,
+ .get_validation = _pkg_get_validation,
.has_scriptlet = _pkg_has_scriptlet,
.get_licenses = _pkg_get_licenses,
@@ -200,14 +200,14 @@ const char SYMEXPORT *alpm_pkg_get_url(alpm_pkg_t *pkg)
return pkg->ops->get_url(pkg);
}
-time_t SYMEXPORT alpm_pkg_get_builddate(alpm_pkg_t *pkg)
+alpm_time_t SYMEXPORT alpm_pkg_get_builddate(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return -1);
pkg->handle->pm_errno = 0;
return pkg->ops->get_builddate(pkg);
}
-time_t SYMEXPORT alpm_pkg_get_installdate(alpm_pkg_t *pkg)
+alpm_time_t SYMEXPORT alpm_pkg_get_installdate(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return -1);
pkg->handle->pm_errno = 0;
@@ -270,6 +270,13 @@ alpm_pkgreason_t SYMEXPORT alpm_pkg_get_reason(alpm_pkg_t *pkg)
return pkg->ops->get_reason(pkg);
}
+alpm_pkgvalidation_t SYMEXPORT alpm_pkg_get_validation(alpm_pkg_t *pkg)
+{
+ ASSERT(pkg != NULL, return -1);
+ pkg->handle->pm_errno = 0;
+ return pkg->ops->get_validation(pkg);
+}
+
alpm_list_t SYMEXPORT *alpm_pkg_get_licenses(alpm_pkg_t *pkg)
{
ASSERT(pkg != NULL, return NULL);
@@ -344,7 +351,7 @@ alpm_db_t SYMEXPORT *alpm_pkg_get_db(alpm_pkg_t *pkg)
{
/* Sanity checks */
ASSERT(pkg != NULL, return NULL);
- ASSERT(pkg->origin != PKG_FROM_FILE, return NULL);
+ ASSERT(pkg->origin != ALPM_PKG_FROM_FILE, return NULL);
pkg->handle->pm_errno = 0;
return pkg->origin_data.db;
@@ -411,7 +418,7 @@ alpm_list_t SYMEXPORT *alpm_pkg_compute_requiredby(alpm_pkg_t *pkg)
ASSERT(pkg != NULL, return NULL);
pkg->handle->pm_errno = 0;
- if(pkg->origin == PKG_FROM_FILE) {
+ if(pkg->origin == ALPM_PKG_FROM_FILE) {
/* The sane option; search locally for things that require this. */
find_requiredby(pkg, pkg->handle->db_local, &reqs);
} else {
@@ -443,24 +450,24 @@ alpm_file_t *_alpm_file_copy(alpm_file_t *dest,
return dest;
}
-/* Helper function for comparing files list entries
- */
-int _alpm_files_cmp(const void *f1, const void *f2)
-{
- const alpm_file_t *file1 = f1;
- const alpm_file_t *file2 = f2;
- return strcmp(file1->name, file2->name);
-}
-
alpm_pkg_t *_alpm_pkg_new(void)
{
- alpm_pkg_t* pkg;
+ alpm_pkg_t *pkg;
CALLOC(pkg, 1, sizeof(alpm_pkg_t), return NULL);
return pkg;
}
+static alpm_list_t *list_depdup(alpm_list_t *old)
+{
+ alpm_list_t *i, *new = NULL;
+ for(i = old; i; i = i->next) {
+ new = alpm_list_add(new, _alpm_dep_dup(i->data));
+ }
+ return new;
+}
+
/**
* Duplicate a package data struct.
* @param pkg the package to duplicate
@@ -509,10 +516,19 @@ int _alpm_pkg_dup(alpm_pkg_t *pkg, alpm_pkg_t **new_ptr)
newpkg->reason = pkg->reason;
newpkg->licenses = alpm_list_strdup(pkg->licenses);
- for(i = pkg->replaces; i; i = i->next) {
- newpkg->replaces = alpm_list_add(newpkg->replaces, _alpm_dep_dup(i->data));
- }
+ newpkg->replaces = list_depdup(pkg->replaces);
newpkg->groups = alpm_list_strdup(pkg->groups);
+ for(i = pkg->backup; i; i = i->next) {
+ newpkg->backup = alpm_list_add(newpkg->backup, _alpm_backup_dup(i->data));
+ }
+ newpkg->depends = list_depdup(pkg->depends);
+ newpkg->optdepends = list_depdup(pkg->optdepends);
+ newpkg->conflicts = list_depdup(pkg->conflicts);
+ newpkg->provides = list_depdup(pkg->provides);
+ for(i = pkg->deltas; i; i = i->next) {
+ newpkg->deltas = alpm_list_add(newpkg->deltas, _alpm_delta_dup(i->data));
+ }
+
if(pkg->files.count) {
size_t filenum;
size_t len = sizeof(alpm_file_t) * pkg->files.count;
@@ -525,27 +541,11 @@ int _alpm_pkg_dup(alpm_pkg_t *pkg, alpm_pkg_t **new_ptr)
}
newpkg->files.count = pkg->files.count;
}
- for(i = pkg->backup; i; i = i->next) {
- newpkg->backup = alpm_list_add(newpkg->backup, _alpm_backup_dup(i->data));
- }
- for(i = pkg->depends; i; i = i->next) {
- newpkg->depends = alpm_list_add(newpkg->depends, _alpm_dep_dup(i->data));
- }
- newpkg->optdepends = alpm_list_strdup(pkg->optdepends);
- for(i = pkg->conflicts; i; i = i->next) {
- newpkg->conflicts = alpm_list_add(newpkg->conflicts, _alpm_dep_dup(i->data));
- }
- for(i = pkg->provides; i; i = i->next) {
- newpkg->provides = alpm_list_add(newpkg->provides, _alpm_dep_dup(i->data));
- }
- for(i = pkg->deltas; i; i = i->next) {
- newpkg->deltas = alpm_list_add(newpkg->deltas, _alpm_delta_dup(i->data));
- }
/* internal */
newpkg->infolevel = pkg->infolevel;
newpkg->origin = pkg->origin;
- if(newpkg->origin == PKG_FROM_FILE) {
+ if(newpkg->origin == ALPM_PKG_FROM_FILE) {
newpkg->origin_data.file = strdup(pkg->origin_data.file);
} else {
newpkg->origin_data.db = pkg->origin_data.db;
@@ -561,6 +561,12 @@ cleanup:
RET_ERR(pkg->handle, ALPM_ERR_MEMORY, -1);
}
+static void free_deplist(alpm_list_t *deps)
+{
+ alpm_list_free_inner(deps, (alpm_list_fn_free)_alpm_dep_free);
+ alpm_list_free(deps);
+}
+
void _alpm_pkg_free(alpm_pkg_t *pkg)
{
if(pkg == NULL) {
@@ -579,8 +585,7 @@ void _alpm_pkg_free(alpm_pkg_t *pkg)
FREE(pkg->arch);
FREELIST(pkg->licenses);
- alpm_list_free_inner(pkg->replaces, (alpm_list_fn_free)_alpm_dep_free);
- alpm_list_free(pkg->replaces);
+ free_deplist(pkg->replaces);
FREELIST(pkg->groups);
if(pkg->files.count) {
size_t i;
@@ -591,27 +596,24 @@ void _alpm_pkg_free(alpm_pkg_t *pkg)
}
alpm_list_free_inner(pkg->backup, (alpm_list_fn_free)_alpm_backup_free);
alpm_list_free(pkg->backup);
- alpm_list_free_inner(pkg->depends, (alpm_list_fn_free)_alpm_dep_free);
- alpm_list_free(pkg->depends);
- FREELIST(pkg->optdepends);
- alpm_list_free_inner(pkg->conflicts, (alpm_list_fn_free)_alpm_dep_free);
- alpm_list_free(pkg->conflicts);
- alpm_list_free_inner(pkg->provides, (alpm_list_fn_free)_alpm_dep_free);
- alpm_list_free(pkg->provides);
+ free_deplist(pkg->depends);
+ free_deplist(pkg->optdepends);
+ free_deplist(pkg->conflicts);
+ free_deplist(pkg->provides);
alpm_list_free_inner(pkg->deltas, (alpm_list_fn_free)_alpm_delta_free);
alpm_list_free(pkg->deltas);
alpm_list_free(pkg->delta_path);
alpm_list_free(pkg->removes);
- if(pkg->origin == PKG_FROM_FILE) {
+ if(pkg->origin == ALPM_PKG_FROM_FILE) {
FREE(pkg->origin_data.file);
}
FREE(pkg);
}
/* This function should be used when removing a target from upgrade/sync target list
- * Case 1: If pkg is a loaded package file (PKG_FROM_FILE), it will be freed.
- * Case 2: If pkg is a pkgcache entry (PKG_FROM_CACHE), it won't be freed,
+ * Case 1: If pkg is a loaded package file (ALPM_PKG_FROM_FILE), it will be freed.
+ * Case 2: If pkg is a pkgcache entry (ALPM_PKG_FROM_CACHE), it won't be freed,
* only the transaction specific fields of pkg will be freed.
*/
void _alpm_pkg_free_trans(alpm_pkg_t *pkg)
@@ -620,7 +622,7 @@ void _alpm_pkg_free_trans(alpm_pkg_t *pkg)
return;
}
- if(pkg->origin == PKG_FROM_FILE) {
+ if(pkg->origin == ALPM_PKG_FROM_FILE) {
_alpm_pkg_free(pkg);
return;
}
@@ -690,14 +692,14 @@ int _alpm_pkg_should_ignore(alpm_handle_t *handle, alpm_pkg_t *pkg)
alpm_list_t *groups = NULL;
/* first see if the package is ignored */
- if(alpm_list_find_str(handle->ignorepkg, pkg->name)) {
+ if(alpm_list_find(handle->ignorepkg, pkg->name, _alpm_fnmatch)) {
return 1;
}
/* next see if the package is in a group that is ignored */
- for(groups = handle->ignoregroup; groups; groups = groups->next) {
+ for(groups = alpm_pkg_get_groups(pkg); groups; groups = groups->next) {
char *grp = groups->data;
- if(alpm_list_find_str(alpm_pkg_get_groups(pkg), grp)) {
+ if(alpm_list_find(handle->ignoregroup, grp, _alpm_fnmatch)) {
return 1;
}
}