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.c91
1 files changed, 51 insertions, 40 deletions
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index a5ff238f..6b648675 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>
@@ -69,7 +67,7 @@ int SYMEXPORT alpm_pkg_checkmd5sum(alpm_pkg_t *pkg)
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);
@@ -461,6 +468,15 @@ alpm_pkg_t *_alpm_pkg_new(void)
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 +525,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,22 +550,6 @@ 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;
@@ -561,6 +570,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 +594,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,13 +605,10 @@ 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);
@@ -690,14 +701,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;
}
}