2005-03-14 20:51:43 -05:00
|
|
|
/*
|
|
|
|
* package.c
|
2006-10-15 15:31:03 -04:00
|
|
|
*
|
2006-01-02 14:55:35 -05:00
|
|
|
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
|
2006-10-15 15:31:03 -04:00
|
|
|
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
|
|
|
|
* Copyright (c) 2005, 2006 by Christian Hamar <krics@linuxforum.hu>
|
|
|
|
* Copyright (c) 2005, 2006 by Miklos Vajna <vmiklos@frugalware.org>
|
2005-03-14 20:51:43 -05:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
|
|
|
* USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <string.h>
|
2006-05-14 22:19:57 -04:00
|
|
|
#include <libintl.h>
|
2006-10-15 15:31:03 -04:00
|
|
|
#include <locale.h>
|
2007-01-24 03:51:50 -05:00
|
|
|
#include <errno.h>
|
2007-02-10 18:44:39 -05:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <unistd.h>
|
2005-03-14 20:51:43 -05:00
|
|
|
/* pacman */
|
2007-02-09 16:54:57 -05:00
|
|
|
#include "package.h"
|
2005-03-14 20:51:43 -05:00
|
|
|
#include "log.h"
|
|
|
|
#include "util.h"
|
|
|
|
#include "error.h"
|
2007-01-19 04:28:44 -05:00
|
|
|
#include "alpm_list.h"
|
2006-11-20 04:10:23 -05:00
|
|
|
#include "db.h"
|
2007-02-17 03:55:05 -05:00
|
|
|
#include "cache.h"
|
|
|
|
#include "provide.h"
|
2006-11-20 04:10:23 -05:00
|
|
|
#include "handle.h"
|
2007-02-09 16:54:57 -05:00
|
|
|
#include "versioncmp.h"
|
2005-03-28 03:21:17 -05:00
|
|
|
#include "alpm.h"
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2006-02-17 17:35:26 -05:00
|
|
|
pmpkg_t *_alpm_pkg_new(const char *name, const char *version)
|
2005-03-14 20:51:43 -05:00
|
|
|
{
|
2007-01-19 13:01:02 -05:00
|
|
|
pmpkg_t* pkg;
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2007-01-30 03:14:10 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2007-01-19 13:01:02 -05:00
|
|
|
if((pkg = calloc(1,sizeof(pmpkg_t))) == NULL) {
|
|
|
|
RET_ERR(PM_ERR_MEMORY, NULL);
|
2006-02-20 15:41:40 -05:00
|
|
|
}
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2006-01-09 15:16:00 -05:00
|
|
|
if(name && name[0] != 0) {
|
|
|
|
STRNCPY(pkg->name, name, PKG_NAME_LEN);
|
|
|
|
} else {
|
|
|
|
pkg->name[0] = '\0';
|
|
|
|
}
|
|
|
|
if(version && version[0] != 0) {
|
|
|
|
STRNCPY(pkg->version, version, PKG_VERSION_LEN);
|
|
|
|
} else {
|
|
|
|
pkg->version[0] = '\0';
|
|
|
|
}
|
2005-03-14 20:51:43 -05:00
|
|
|
|
|
|
|
return(pkg);
|
|
|
|
}
|
|
|
|
|
2006-02-17 17:35:26 -05:00
|
|
|
pmpkg_t *_alpm_pkg_dup(pmpkg_t *pkg)
|
2005-04-23 13:18:31 -04:00
|
|
|
{
|
2007-01-19 13:01:02 -05:00
|
|
|
pmpkg_t* newpkg;
|
2005-04-23 13:18:31 -04:00
|
|
|
|
2007-01-30 03:14:10 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2007-01-19 13:06:37 -05:00
|
|
|
if((newpkg = calloc(1, sizeof(pmpkg_t))) == NULL) {
|
2006-05-14 22:19:57 -04:00
|
|
|
_alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"), sizeof(pmpkg_t));
|
2006-03-07 15:52:45 -05:00
|
|
|
RET_ERR(PM_ERR_MEMORY, NULL);
|
2005-04-23 13:18:31 -04:00
|
|
|
}
|
|
|
|
|
2007-01-19 13:01:02 -05:00
|
|
|
memcpy(newpkg, pkg, sizeof(pmpkg_t));
|
2007-03-03 03:13:59 -05:00
|
|
|
newpkg->licenses = alpm_list_strdup(alpm_pkg_get_licenses(pkg));
|
2007-02-12 20:46:33 -05:00
|
|
|
/*newpkg->desc_localized = alpm_list_strdup(pkg->desc_localized);*/
|
2007-03-03 03:13:59 -05:00
|
|
|
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));
|
|
|
|
newpkg->backup = alpm_list_strdup(alpm_pkg_get_backup(pkg));
|
|
|
|
newpkg->depends = alpm_list_strdup(alpm_pkg_get_depends(pkg));
|
|
|
|
newpkg->removes = alpm_list_strdup(alpm_pkg_get_removes(pkg));
|
|
|
|
newpkg->groups = alpm_list_strdup(alpm_pkg_get_groups(pkg));
|
|
|
|
newpkg->provides = alpm_list_strdup(alpm_pkg_get_provides(pkg));
|
|
|
|
newpkg->replaces = alpm_list_strdup(alpm_pkg_get_replaces(pkg));
|
2005-04-23 13:18:31 -04:00
|
|
|
/* internal */
|
|
|
|
newpkg->data = (newpkg->origin == PKG_FROM_FILE) ? strdup(pkg->data) : pkg->data;
|
|
|
|
|
|
|
|
return(newpkg);
|
|
|
|
}
|
|
|
|
|
2006-02-22 15:49:33 -05:00
|
|
|
void _alpm_pkg_free(void *data)
|
2005-03-14 20:51:43 -05:00
|
|
|
{
|
2006-02-22 15:49:33 -05:00
|
|
|
pmpkg_t *pkg = data;
|
|
|
|
|
2007-01-30 03:14:10 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2005-03-14 20:51:43 -05:00
|
|
|
if(pkg == NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-03-03 03:13:59 -05:00
|
|
|
FREELIST(pkg->licenses);
|
2007-02-12 20:46:33 -05:00
|
|
|
/*FREELIST(pkg->desc_localized);*/
|
2005-03-14 20:51:43 -05:00
|
|
|
FREELIST(pkg->files);
|
|
|
|
FREELIST(pkg->backup);
|
|
|
|
FREELIST(pkg->depends);
|
2006-10-15 15:31:03 -04:00
|
|
|
FREELIST(pkg->removes);
|
2005-03-14 20:51:43 -05:00
|
|
|
FREELIST(pkg->conflicts);
|
|
|
|
FREELIST(pkg->requiredby);
|
|
|
|
FREELIST(pkg->groups);
|
|
|
|
FREELIST(pkg->provides);
|
|
|
|
FREELIST(pkg->replaces);
|
|
|
|
if(pkg->origin == PKG_FROM_FILE) {
|
|
|
|
FREE(pkg->data);
|
|
|
|
}
|
2006-10-31 01:39:59 -05:00
|
|
|
FREE(pkg);
|
2005-03-14 20:51:43 -05:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-02-06 12:39:32 -05:00
|
|
|
/* Is pkgB an upgrade for pkgA ? */
|
2007-02-07 00:57:28 -05:00
|
|
|
int alpm_pkg_compare_versions(pmpkg_t *local_pkg, pmpkg_t *pkg)
|
2007-02-06 12:39:32 -05:00
|
|
|
{
|
2007-02-07 00:57:28 -05:00
|
|
|
int cmp = 0;
|
|
|
|
|
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
|
|
|
if(pkg->origin == PKG_FROM_CACHE) {
|
2007-02-06 15:57:17 -05:00
|
|
|
/* ensure we have the /desc file, which contains the 'force' option */
|
2007-02-21 03:34:36 -05:00
|
|
|
_alpm_db_read(pkg->data, pkg, INFRQ_DESC);
|
2007-02-06 15:57:17 -05:00
|
|
|
}
|
|
|
|
|
2007-02-06 12:39:32 -05:00
|
|
|
/* compare versions and see if we need to upgrade */
|
2007-03-03 03:13:59 -05:00
|
|
|
cmp = _alpm_versioncmp(alpm_pkg_get_version(pkg), alpm_pkg_get_version(local_pkg));
|
2007-02-06 12:39:32 -05:00
|
|
|
|
2007-02-07 01:12:53 -05:00
|
|
|
if(cmp != 0 && pkg->force) {
|
|
|
|
cmp = 1;
|
2007-03-03 03:13:59 -05:00
|
|
|
_alpm_log(PM_LOG_WARNING, _("%s: forcing upgrade to version %s"),
|
|
|
|
alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg));
|
2007-02-22 21:10:56 -05:00
|
|
|
} else if(cmp < 0) {
|
2007-02-06 12:39:32 -05:00
|
|
|
/* local version is newer */
|
2007-02-07 00:57:28 -05:00
|
|
|
pmdb_t *db = pkg->data;
|
2007-02-06 12:39:32 -05:00
|
|
|
_alpm_log(PM_LOG_WARNING, _("%s: local (%s) is newer than %s (%s)"),
|
2007-03-03 03:13:59 -05:00
|
|
|
alpm_pkg_get_name(local_pkg), alpm_pkg_get_version(local_pkg),
|
|
|
|
alpm_db_get_name(db), alpm_pkg_get_version(pkg));
|
2007-02-06 12:39:32 -05:00
|
|
|
cmp = 0;
|
2007-02-22 21:10:56 -05:00
|
|
|
} else if(cmp > 0) {
|
2007-02-14 11:15:09 -05:00
|
|
|
/* we have an upgrade, make sure we should actually do it */
|
2007-03-03 03:13:59 -05:00
|
|
|
if(alpm_list_find_str(handle->ignorepkg, alpm_pkg_get_name(pkg))) {
|
2007-02-14 11:15:09 -05:00
|
|
|
/* package should be ignored (IgnorePkg) */
|
|
|
|
_alpm_log(PM_LOG_WARNING, _("%s-%s: ignoring package upgrade (%s)"),
|
2007-03-03 03:13:59 -05:00
|
|
|
alpm_pkg_get_name(local_pkg), alpm_pkg_get_version(local_pkg),
|
|
|
|
alpm_pkg_get_version(pkg));
|
2007-02-22 21:10:56 -05:00
|
|
|
cmp = 0;
|
2007-02-14 11:15:09 -05:00
|
|
|
} else if(_alpm_pkg_istoonew(pkg)) {
|
|
|
|
/* package too new (UpgradeDelay) */
|
|
|
|
_alpm_log(PM_LOG_WARNING, _("%s-%s: delaying upgrade of package (%s)"),
|
2007-03-03 03:13:59 -05:00
|
|
|
alpm_pkg_get_name(local_pkg), alpm_pkg_get_version(local_pkg),
|
|
|
|
alpm_pkg_get_version(pkg));
|
2007-02-22 21:10:56 -05:00
|
|
|
cmp = 0;
|
2007-02-14 11:15:09 -05:00
|
|
|
}
|
2007-02-06 12:39:32 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return(cmp);
|
|
|
|
}
|
|
|
|
|
2006-03-08 13:07:58 -05:00
|
|
|
/* Helper function for comparing packages
|
|
|
|
*/
|
|
|
|
int _alpm_pkg_cmp(const void *p1, const void *p2)
|
|
|
|
{
|
2007-03-03 03:13:59 -05:00
|
|
|
pmpkg_t *pk1 = (pmpkg_t *)p1;
|
|
|
|
pmpkg_t *pk2 = (pmpkg_t *)p2;
|
|
|
|
|
|
|
|
return(strcmp(alpm_pkg_get_name(pk1), alpm_pkg_get_name(pk2)));
|
2006-03-08 13:07:58 -05:00
|
|
|
}
|
|
|
|
|
2005-03-14 20:51:43 -05:00
|
|
|
/* Parses the package description file for the current package
|
2007-02-28 11:37:24 -05:00
|
|
|
* TODO: this should ALL be in a backend interface (be_files), we should
|
|
|
|
* be dealing with the abstracted concepts only in this file
|
2005-03-14 20:51:43 -05:00
|
|
|
* Returns: 0 on success, 1 on error
|
|
|
|
*
|
|
|
|
*/
|
2007-02-26 03:38:48 -05:00
|
|
|
static int parse_descfile(const char *descfile, pmpkg_t *info)
|
2005-03-14 20:51:43 -05:00
|
|
|
{
|
|
|
|
FILE* fp = NULL;
|
2006-02-16 16:02:39 -05:00
|
|
|
char line[PATH_MAX];
|
2007-02-26 03:38:48 -05:00
|
|
|
char *ptr = NULL;
|
|
|
|
char *key = NULL;
|
2005-03-14 20:51:43 -05:00
|
|
|
int linenum = 0;
|
|
|
|
|
2007-01-30 03:14:10 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2005-03-14 20:51:43 -05:00
|
|
|
if((fp = fopen(descfile, "r")) == NULL) {
|
2007-01-24 03:51:50 -05:00
|
|
|
_alpm_log(PM_LOG_ERROR, _("could not open file %s: %s"), descfile, strerror(errno));
|
2005-03-14 20:51:43 -05:00
|
|
|
return(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
while(!feof(fp)) {
|
|
|
|
fgets(line, PATH_MAX, fp);
|
|
|
|
linenum++;
|
|
|
|
_alpm_strtrim(line);
|
|
|
|
if(strlen(line) == 0 || line[0] == '#') {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
ptr = line;
|
|
|
|
key = strsep(&ptr, "=");
|
|
|
|
if(key == NULL || ptr == NULL) {
|
2006-10-15 15:31:03 -04:00
|
|
|
_alpm_log(PM_LOG_DEBUG, _("%s: syntax error in description file line %d"),
|
2007-02-10 18:44:39 -05:00
|
|
|
info->name[0] != '\0' ? info->name : "error", linenum);
|
2005-03-14 20:51:43 -05:00
|
|
|
} else {
|
|
|
|
_alpm_strtrim(key);
|
|
|
|
key = _alpm_strtoupper(key);
|
|
|
|
_alpm_strtrim(ptr);
|
|
|
|
if(!strcmp(key, "PKGNAME")) {
|
2005-03-29 12:18:59 -05:00
|
|
|
STRNCPY(info->name, ptr, sizeof(info->name));
|
2005-03-14 20:51:43 -05:00
|
|
|
} else if(!strcmp(key, "PKGVER")) {
|
2005-03-29 12:18:59 -05:00
|
|
|
STRNCPY(info->version, ptr, sizeof(info->version));
|
2005-03-14 20:51:43 -05:00
|
|
|
} else if(!strcmp(key, "PKGDESC")) {
|
2007-02-12 20:46:33 -05:00
|
|
|
/*
|
2006-10-15 15:31:03 -04:00
|
|
|
char *lang_tmp;
|
2007-01-19 04:28:44 -05:00
|
|
|
info->desc_localized = alpm_list_add(info->desc_localized, strdup(ptr));
|
2006-10-15 15:31:03 -04:00
|
|
|
if((lang_tmp = (char *)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) {
|
2007-02-12 20:46:33 -05:00
|
|
|
*/
|
|
|
|
STRNCPY(info->desc, ptr, sizeof(info->desc));
|
|
|
|
/*
|
2006-10-15 15:31:03 -04:00
|
|
|
} else if (ptr && !strncmp(ptr, lang_tmp, strlen(lang_tmp))) {
|
|
|
|
STRNCPY(info->desc, ptr+strlen(lang_tmp)+1, sizeof(info->desc));
|
|
|
|
}
|
|
|
|
FREE(lang_tmp);
|
2007-02-12 20:46:33 -05:00
|
|
|
*/
|
2005-03-14 20:51:43 -05:00
|
|
|
} else if(!strcmp(key, "GROUP")) {
|
2007-01-19 04:28:44 -05:00
|
|
|
info->groups = alpm_list_add(info->groups, strdup(ptr));
|
2005-03-14 20:51:43 -05:00
|
|
|
} else if(!strcmp(key, "URL")) {
|
2005-03-29 12:18:59 -05:00
|
|
|
STRNCPY(info->url, ptr, sizeof(info->url));
|
2005-03-14 20:51:43 -05:00
|
|
|
} else if(!strcmp(key, "LICENSE")) {
|
2007-03-03 03:13:59 -05:00
|
|
|
info->licenses = alpm_list_add(info->licenses, strdup(ptr));
|
2005-03-14 20:51:43 -05:00
|
|
|
} else if(!strcmp(key, "BUILDDATE")) {
|
2005-03-29 12:18:59 -05:00
|
|
|
STRNCPY(info->builddate, ptr, sizeof(info->builddate));
|
2006-10-15 15:31:03 -04:00
|
|
|
} else if(!strcmp(key, "BUILDTYPE")) {
|
|
|
|
STRNCPY(info->buildtype, ptr, sizeof(info->buildtype));
|
2005-03-14 20:51:43 -05:00
|
|
|
} else if(!strcmp(key, "INSTALLDATE")) {
|
2005-03-29 12:18:59 -05:00
|
|
|
STRNCPY(info->installdate, ptr, sizeof(info->installdate));
|
2005-03-14 20:51:43 -05:00
|
|
|
} else if(!strcmp(key, "PACKAGER")) {
|
2005-03-29 12:18:59 -05:00
|
|
|
STRNCPY(info->packager, ptr, sizeof(info->packager));
|
2005-03-14 20:51:43 -05:00
|
|
|
} else if(!strcmp(key, "ARCH")) {
|
2005-03-29 12:18:59 -05:00
|
|
|
STRNCPY(info->arch, ptr, sizeof(info->arch));
|
2005-03-14 20:51:43 -05:00
|
|
|
} else if(!strcmp(key, "SIZE")) {
|
2007-02-10 18:44:39 -05:00
|
|
|
/* size in the raw package is uncompressed (installed) size */
|
2006-11-22 04:03:41 -05:00
|
|
|
info->isize = atol(ptr);
|
2005-03-14 20:51:43 -05:00
|
|
|
} else if(!strcmp(key, "DEPEND")) {
|
2007-01-19 04:28:44 -05:00
|
|
|
info->depends = alpm_list_add(info->depends, strdup(ptr));
|
2006-10-15 15:31:03 -04:00
|
|
|
} else if(!strcmp(key, "REMOVE")) {
|
2007-01-19 04:28:44 -05:00
|
|
|
info->removes = alpm_list_add(info->removes, strdup(ptr));
|
2005-03-14 20:51:43 -05:00
|
|
|
} else if(!strcmp(key, "CONFLICT")) {
|
2007-01-19 04:28:44 -05:00
|
|
|
info->conflicts = alpm_list_add(info->conflicts, strdup(ptr));
|
2005-03-14 20:51:43 -05:00
|
|
|
} else if(!strcmp(key, "REPLACES")) {
|
2007-01-19 04:28:44 -05:00
|
|
|
info->replaces = alpm_list_add(info->replaces, strdup(ptr));
|
2005-03-14 20:51:43 -05:00
|
|
|
} else if(!strcmp(key, "PROVIDES")) {
|
2007-01-19 04:28:44 -05:00
|
|
|
info->provides = alpm_list_add(info->provides, strdup(ptr));
|
2005-03-14 20:51:43 -05:00
|
|
|
} else if(!strcmp(key, "BACKUP")) {
|
2007-01-19 04:28:44 -05:00
|
|
|
info->backup = alpm_list_add(info->backup, strdup(ptr));
|
2005-03-14 20:51:43 -05:00
|
|
|
} else {
|
2006-10-15 15:31:03 -04:00
|
|
|
_alpm_log(PM_LOG_DEBUG, _("%s: syntax error in description file line %d"),
|
2007-02-10 18:44:39 -05:00
|
|
|
info->name[0] != '\0' ? info->name : "error", linenum);
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
line[0] = '\0';
|
|
|
|
}
|
|
|
|
fclose(fp);
|
|
|
|
unlink(descfile);
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
2007-02-26 03:38:48 -05:00
|
|
|
pmpkg_t *_alpm_pkg_load(const char *pkgfile)
|
2005-03-14 20:51:43 -05:00
|
|
|
{
|
|
|
|
char *expath;
|
2007-02-03 22:24:32 -05:00
|
|
|
int ret = ARCHIVE_OK;
|
2005-03-14 20:51:43 -05:00
|
|
|
int config = 0;
|
|
|
|
int filelist = 0;
|
|
|
|
int scriptcheck = 0;
|
2007-01-31 22:00:34 -05:00
|
|
|
struct archive *archive;
|
2006-09-28 16:51:33 -04:00
|
|
|
struct archive_entry *entry;
|
2005-03-14 20:51:43 -05:00
|
|
|
pmpkg_t *info = NULL;
|
2007-01-19 18:44:50 -05:00
|
|
|
char *descfile = NULL;
|
|
|
|
int fd = -1;
|
2007-01-31 22:00:34 -05:00
|
|
|
alpm_list_t *all_files = NULL;
|
2007-02-10 18:44:39 -05:00
|
|
|
struct stat st;
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2007-01-30 03:14:10 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2005-04-17 06:00:49 -04:00
|
|
|
if(pkgfile == NULL || strlen(pkgfile) == 0) {
|
2005-03-16 17:10:05 -05:00
|
|
|
RET_ERR(PM_ERR_WRONG_ARGS, NULL);
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
|
|
|
|
2007-02-03 22:24:32 -05:00
|
|
|
if((archive = archive_read_new()) == NULL) {
|
2006-10-15 15:31:03 -04:00
|
|
|
RET_ERR(PM_ERR_LIBARCHIVE_ERROR, NULL);
|
2007-02-03 22:24:32 -05:00
|
|
|
}
|
2006-10-15 15:31:03 -04:00
|
|
|
|
2007-02-03 22:24:32 -05:00
|
|
|
archive_read_support_compression_all(archive);
|
|
|
|
archive_read_support_format_all(archive);
|
2006-10-15 15:31:03 -04:00
|
|
|
|
2007-02-03 22:24:32 -05:00
|
|
|
if (archive_read_open_file(archive, pkgfile, ARCHIVE_DEFAULT_BYTES_PER_BLOCK) != ARCHIVE_OK) {
|
2006-10-15 15:31:03 -04:00
|
|
|
RET_ERR(PM_ERR_PKG_OPEN, NULL);
|
2007-02-03 22:24:32 -05:00
|
|
|
}
|
2006-10-15 15:31:03 -04:00
|
|
|
|
2006-02-17 17:35:26 -05:00
|
|
|
info = _alpm_pkg_new(NULL, NULL);
|
2005-03-14 20:51:43 -05:00
|
|
|
if(info == NULL) {
|
2007-02-03 22:24:32 -05:00
|
|
|
archive_read_finish(archive);
|
2006-10-15 15:31:03 -04:00
|
|
|
RET_ERR(PM_ERR_MEMORY, NULL);
|
2006-09-28 16:51:33 -04:00
|
|
|
}
|
|
|
|
|
2007-02-10 18:44:39 -05:00
|
|
|
if(stat(pkgfile, &st) == 0) {
|
|
|
|
info->size = st.st_size;
|
|
|
|
}
|
|
|
|
|
2007-01-31 20:51:12 -05:00
|
|
|
/* TODO there is no reason to make temp files to read
|
|
|
|
* from a libarchive archive, it can be done by reading
|
2007-02-03 22:24:32 -05:00
|
|
|
* directly from the archive
|
|
|
|
* See: archive_read_data_into_buffer
|
|
|
|
* requires changes 'parse_descfile' as well
|
|
|
|
* */
|
|
|
|
|
|
|
|
/* Read through the entire archive for metadata. We will continue reading
|
|
|
|
* even if all metadata is found, to verify the integrity of the archive in
|
|
|
|
* full */
|
|
|
|
while((ret = archive_read_next_header (archive, &entry)) == ARCHIVE_OK) {
|
2007-01-31 22:00:34 -05:00
|
|
|
const char *entry_name = archive_entry_pathname(entry);
|
|
|
|
|
|
|
|
if(strcmp(entry_name, ".PKGINFO") == 0) {
|
2005-03-14 20:51:43 -05:00
|
|
|
/* extract this file into /tmp. it has info for us */
|
2005-03-27 02:42:21 -05:00
|
|
|
descfile = strdup("/tmp/alpm_XXXXXX");
|
2005-11-09 16:50:47 -05:00
|
|
|
fd = mkstemp(descfile);
|
2006-10-15 15:31:03 -04:00
|
|
|
archive_read_data_into_fd (archive, fd);
|
2005-03-14 20:51:43 -05:00
|
|
|
/* parse the info file */
|
2007-02-10 18:44:39 -05:00
|
|
|
if(parse_descfile(descfile, info) == -1) {
|
2006-05-14 22:19:57 -04:00
|
|
|
_alpm_log(PM_LOG_ERROR, _("could not parse the package description file"));
|
2007-01-19 13:05:19 -05:00
|
|
|
goto pkg_invalid;
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
2006-10-15 15:31:03 -04:00
|
|
|
if(!strlen(info->name)) {
|
|
|
|
_alpm_log(PM_LOG_ERROR, _("missing package name in %s"), pkgfile);
|
2007-01-19 13:05:19 -05:00
|
|
|
goto pkg_invalid;
|
2006-10-15 15:31:03 -04:00
|
|
|
}
|
|
|
|
if(!strlen(info->version)) {
|
|
|
|
_alpm_log(PM_LOG_ERROR, _("missing package version in %s"), pkgfile);
|
2007-01-19 13:05:19 -05:00
|
|
|
goto pkg_invalid;
|
2006-10-15 15:31:03 -04:00
|
|
|
}
|
2005-03-14 20:51:43 -05:00
|
|
|
config = 1;
|
2005-11-09 16:50:47 -05:00
|
|
|
unlink(descfile);
|
2005-03-14 20:51:43 -05:00
|
|
|
FREE(descfile);
|
2005-11-09 16:50:47 -05:00
|
|
|
close(fd);
|
2005-03-14 20:51:43 -05:00
|
|
|
continue;
|
2007-01-31 22:00:34 -05:00
|
|
|
} else if(strcmp(entry_name, ".INSTALL") == 0) {
|
2005-03-14 20:51:43 -05:00
|
|
|
info->scriptlet = 1;
|
|
|
|
scriptcheck = 1;
|
2007-01-31 22:00:34 -05:00
|
|
|
} else if(strcmp(entry_name, ".FILELIST") == 0) {
|
2005-03-14 20:51:43 -05:00
|
|
|
/* Build info->files from the filelist */
|
|
|
|
FILE *fp;
|
|
|
|
char *fn;
|
|
|
|
char *str;
|
2005-11-09 16:50:47 -05:00
|
|
|
int fd;
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2006-10-15 15:31:03 -04:00
|
|
|
if((str = (char *)malloc(PATH_MAX)) == NULL) {
|
|
|
|
RET_ERR(PM_ERR_MEMORY, (pmpkg_t *)-1);
|
2006-02-20 15:41:40 -05:00
|
|
|
}
|
2005-03-27 02:42:21 -05:00
|
|
|
fn = strdup("/tmp/alpm_XXXXXX");
|
2005-11-09 16:50:47 -05:00
|
|
|
fd = mkstemp(fn);
|
2007-01-31 22:00:34 -05:00
|
|
|
archive_read_data_into_fd(archive,fd);
|
2005-03-14 20:51:43 -05:00
|
|
|
fp = fopen(fn, "r");
|
|
|
|
while(!feof(fp)) {
|
|
|
|
if(fgets(str, PATH_MAX, fp) == NULL) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
_alpm_strtrim(str);
|
2007-01-19 04:28:44 -05:00
|
|
|
info->files = alpm_list_add(info->files, strdup(str));
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
|
|
|
FREE(str);
|
|
|
|
fclose(fp);
|
|
|
|
if(unlink(fn)) {
|
2006-05-14 22:19:57 -04:00
|
|
|
_alpm_log(PM_LOG_WARNING, _("could not remove tempfile %s"), fn);
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
|
|
|
FREE(fn);
|
2005-11-09 16:50:47 -05:00
|
|
|
close(fd);
|
2005-03-14 20:51:43 -05:00
|
|
|
filelist = 1;
|
|
|
|
continue;
|
|
|
|
} else {
|
|
|
|
scriptcheck = 1;
|
2007-01-31 22:00:34 -05:00
|
|
|
/* Keep track of all files so we can generate a filelist later if missing */
|
|
|
|
all_files = alpm_list_add(all_files, strdup(entry_name));
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
|
|
|
|
2007-01-31 22:00:34 -05:00
|
|
|
if(archive_read_data_skip(archive)) {
|
2007-02-03 22:24:32 -05:00
|
|
|
_alpm_log(PM_LOG_ERROR, _("error while reading package: %s"), archive_error_string(archive));
|
|
|
|
pm_errno = PM_ERR_LIBARCHIVE_ERROR;
|
2005-03-14 20:51:43 -05:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
expath = NULL;
|
|
|
|
}
|
2007-02-03 22:24:32 -05:00
|
|
|
if(ret != ARCHIVE_EOF) { /* An error occured */
|
|
|
|
_alpm_log(PM_LOG_ERROR, _("error while reading package: %s"), archive_error_string(archive));
|
|
|
|
pm_errno = PM_ERR_LIBARCHIVE_ERROR;
|
|
|
|
goto error;
|
|
|
|
}
|
2005-03-14 20:51:43 -05:00
|
|
|
|
|
|
|
if(!config) {
|
2007-02-03 22:24:32 -05:00
|
|
|
_alpm_log(PM_LOG_ERROR, _("missing package metadata"), pkgfile);
|
2005-03-14 20:51:43 -05:00
|
|
|
goto error;
|
2007-01-31 22:00:34 -05:00
|
|
|
}
|
|
|
|
|
2007-02-03 22:24:32 -05:00
|
|
|
archive_read_finish(archive);
|
|
|
|
|
2007-01-31 22:00:34 -05:00
|
|
|
if(!filelist) {
|
|
|
|
_alpm_log(PM_LOG_ERROR, _("missing package filelist in %s, generating one"), pkgfile);
|
|
|
|
info->files = all_files;
|
|
|
|
} else {
|
|
|
|
alpm_list_free_inner(all_files, free);
|
|
|
|
alpm_list_free(all_files);
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
|
|
|
|
2007-02-13 03:15:38 -05:00
|
|
|
/* this is IMPORTANT - "checking for conflicts" requires a sorted list, so we
|
|
|
|
* ensure that here */
|
|
|
|
info->files = alpm_list_msort(info->files, alpm_list_count(info->files), _alpm_str_cmp);
|
|
|
|
|
2005-03-14 20:51:43 -05:00
|
|
|
/* internal */
|
|
|
|
info->origin = PKG_FROM_FILE;
|
|
|
|
info->data = strdup(pkgfile);
|
|
|
|
info->infolevel = 0xFF;
|
|
|
|
|
|
|
|
return(info);
|
|
|
|
|
2007-01-19 13:05:19 -05:00
|
|
|
pkg_invalid:
|
|
|
|
pm_errno = PM_ERR_PKG_INVALID;
|
2007-01-19 18:44:50 -05:00
|
|
|
if(descfile) {
|
|
|
|
unlink(descfile);
|
|
|
|
FREE(descfile);
|
|
|
|
}
|
|
|
|
if(fd != -1) {
|
|
|
|
close(fd);
|
|
|
|
}
|
2005-03-14 20:51:43 -05:00
|
|
|
error:
|
|
|
|
FREEPKG(info);
|
2007-01-31 22:00:34 -05:00
|
|
|
archive_read_finish(archive);
|
2006-10-15 15:31:03 -04:00
|
|
|
|
2005-03-14 20:51:43 -05:00
|
|
|
return(NULL);
|
|
|
|
}
|
|
|
|
|
2007-01-19 04:28:44 -05:00
|
|
|
/* Test for existence of a package in a alpm_list_t*
|
2005-03-14 20:51:43 -05:00
|
|
|
* of pmpkg_t*
|
|
|
|
*/
|
2007-02-26 03:38:48 -05:00
|
|
|
pmpkg_t *_alpm_pkg_find(const char *needle, alpm_list_t *haystack)
|
2005-03-14 20:51:43 -05:00
|
|
|
{
|
2007-01-19 04:28:44 -05:00
|
|
|
alpm_list_t *lp;
|
2005-03-14 20:51:43 -05:00
|
|
|
|
2007-01-30 03:14:10 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2005-03-14 20:51:43 -05:00
|
|
|
if(needle == NULL || haystack == NULL) {
|
2006-01-18 17:37:16 -05:00
|
|
|
return(NULL);
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
for(lp = haystack; lp; lp = lp->next) {
|
|
|
|
pmpkg_t *info = lp->data;
|
|
|
|
|
2007-03-03 03:13:59 -05:00
|
|
|
if(info && strcmp(alpm_pkg_get_name(info), needle) == 0) {
|
2007-02-21 23:42:59 -05:00
|
|
|
return(info);
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
|
|
|
}
|
2006-01-18 17:37:16 -05:00
|
|
|
return(NULL);
|
2005-03-14 20:51:43 -05:00
|
|
|
}
|
|
|
|
|
2007-02-26 03:38:48 -05:00
|
|
|
int _alpm_pkg_splitname(const char *target, char *name, char *version, int witharch)
|
2005-04-08 16:43:13 -04:00
|
|
|
{
|
2005-10-05 16:49:32 -04:00
|
|
|
char tmp[PKG_FULLNAME_LEN+7];
|
2007-02-26 03:38:48 -05:00
|
|
|
const char *t;
|
2005-04-08 16:43:13 -04:00
|
|
|
char *p, *q;
|
|
|
|
|
2007-01-30 03:14:10 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2005-04-08 16:43:13 -04:00
|
|
|
if(target == NULL) {
|
|
|
|
return(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* trim path name (if any) */
|
2007-02-26 03:38:48 -05:00
|
|
|
if((t = strrchr(target, '/')) == NULL) {
|
|
|
|
t = target;
|
2005-04-08 16:43:13 -04:00
|
|
|
} else {
|
2007-02-26 03:38:48 -05:00
|
|
|
t++;
|
2005-04-08 16:43:13 -04:00
|
|
|
}
|
2007-02-26 03:38:48 -05:00
|
|
|
STRNCPY(tmp, t, PKG_FULLNAME_LEN+7);
|
2005-04-08 16:43:13 -04:00
|
|
|
/* trim file extension (if any) */
|
|
|
|
if((p = strstr(tmp, PM_EXT_PKG))) {
|
2006-11-14 02:58:42 -05:00
|
|
|
*p = '\0';
|
|
|
|
}
|
|
|
|
|
2006-11-14 12:26:19 -05:00
|
|
|
if(witharch) {
|
|
|
|
/* trim architecture */
|
2006-11-15 02:50:37 -05:00
|
|
|
if((p = alpm_pkg_name_hasarch(tmp))) {
|
2006-11-14 12:26:19 -05:00
|
|
|
*p = 0;
|
|
|
|
}
|
|
|
|
}
|
2005-04-08 16:43:13 -04:00
|
|
|
|
|
|
|
p = tmp + strlen(tmp);
|
|
|
|
|
|
|
|
for(q = --p; *q && *q != '-'; q--);
|
|
|
|
if(*q != '-' || q == tmp) {
|
|
|
|
return(-1);
|
|
|
|
}
|
|
|
|
for(p = --q; *p && *p != '-'; p--);
|
|
|
|
if(*p != '-' || p == tmp) {
|
|
|
|
return(-1);
|
|
|
|
}
|
|
|
|
if(version) {
|
|
|
|
STRNCPY(version, p+1, PKG_VERSION_LEN);
|
|
|
|
}
|
2006-11-14 02:58:42 -05:00
|
|
|
*p = '\0';
|
2005-04-08 16:43:13 -04:00
|
|
|
|
|
|
|
if(name) {
|
|
|
|
STRNCPY(name, tmp, PKG_NAME_LEN);
|
|
|
|
}
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
2007-02-17 03:55:05 -05:00
|
|
|
|
|
|
|
void _alpm_pkg_update_requiredby(pmpkg_t *pkg)
|
|
|
|
{
|
2007-03-01 00:42:53 -05:00
|
|
|
alpm_list_t *i, *j, *k;
|
2007-02-17 03:55:05 -05:00
|
|
|
|
|
|
|
pmdb_t *localdb = alpm_option_get_localdb();
|
2007-03-03 03:13:59 -05:00
|
|
|
for(i = _alpm_db_get_pkgcache(localdb); i; i = i->next) {
|
2007-02-17 03:55:05 -05:00
|
|
|
if(!i->data) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
pmpkg_t *cachepkg = i->data;
|
2007-03-03 03:13:59 -05:00
|
|
|
for(j = alpm_pkg_get_depends(cachepkg); j; j = j->next) {
|
2007-03-03 04:43:16 -05:00
|
|
|
pmdepend_t *dep;
|
2007-02-17 03:55:05 -05:00
|
|
|
if(!j->data) {
|
|
|
|
continue;
|
|
|
|
}
|
2007-03-03 04:43:16 -05:00
|
|
|
dep = _alpm_splitdep(j->data);
|
|
|
|
if(dep == NULL) {
|
|
|
|
continue;
|
2007-03-01 00:42:53 -05:00
|
|
|
}
|
2007-03-03 04:43:16 -05:00
|
|
|
|
2007-03-01 00:42:53 -05:00
|
|
|
/* check the actual package itself */
|
2007-03-03 04:43:16 -05:00
|
|
|
if(strcmp(dep->name, alpm_pkg_get_name(pkg)) == 0) {
|
2007-03-01 00:42:53 -05:00
|
|
|
_alpm_log(PM_LOG_DEBUG, _("adding '%s' in requiredby field for '%s'"),
|
|
|
|
cachepkg->name, pkg->name);
|
2007-03-03 03:13:59 -05:00
|
|
|
alpm_list_t *reqs = alpm_pkg_get_requiredby(pkg);
|
|
|
|
reqs = alpm_list_add(reqs, strdup(alpm_pkg_get_name(cachepkg)));
|
|
|
|
pkg->requiredby = reqs;
|
2007-02-17 03:55:05 -05:00
|
|
|
}
|
2007-03-01 00:42:53 -05:00
|
|
|
|
|
|
|
/* check for provisions as well */
|
2007-03-03 03:13:59 -05:00
|
|
|
for(k = alpm_pkg_get_provides(pkg); k; k = k->next) {
|
2007-03-01 00:42:53 -05:00
|
|
|
const char *provname = k->data;
|
2007-03-03 04:43:16 -05:00
|
|
|
if(strcmp(dep->name, provname) == 0) {
|
2007-03-01 00:42:53 -05:00
|
|
|
_alpm_log(PM_LOG_DEBUG, _("adding '%s' in requiredby field for '%s' (provides: %s)"),
|
2007-03-03 03:13:59 -05:00
|
|
|
alpm_pkg_get_name(cachepkg), alpm_pkg_get_name(pkg), provname);
|
|
|
|
alpm_list_t *reqs = alpm_pkg_get_requiredby(pkg);
|
|
|
|
reqs = alpm_list_add(reqs, strdup(alpm_pkg_get_name(cachepkg)));
|
|
|
|
pkg->requiredby = reqs;
|
2007-03-01 00:42:53 -05:00
|
|
|
}
|
|
|
|
}
|
2007-03-03 04:43:16 -05:00
|
|
|
free(dep);
|
2007-02-17 03:55:05 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-01 14:07:38 -05:00
|
|
|
const char SYMEXPORT *alpm_pkg_get_filename(pmpkg_t *pkg)
|
2006-11-22 04:03:41 -05:00
|
|
|
{
|
2007-01-30 03:14:10 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2006-11-22 04:03:41 -05:00
|
|
|
/* 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 */
|
2007-03-01 14:07:38 -05:00
|
|
|
if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
|
|
|
|
_alpm_db_read(pkg->data, pkg, INFRQ_DESC);
|
|
|
|
}
|
2006-11-22 04:03:41 -05:00
|
|
|
if(pkg->arch && strlen(pkg->arch) > 0) {
|
2007-03-01 14:07:38 -05:00
|
|
|
snprintf(pkg->filename, PKG_FILENAME_LEN, "%s-%s-%s" PM_EXT_PKG,
|
|
|
|
pkg->name, pkg->version, pkg->arch);
|
2006-11-22 04:03:41 -05:00
|
|
|
} else {
|
2007-03-01 14:07:38 -05:00
|
|
|
snprintf(pkg->filename, PKG_FILENAME_LEN, "%s-%s" PM_EXT_PKG,
|
|
|
|
pkg->name, pkg->version);
|
2006-11-22 04:03:41 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return pkg->filename;
|
|
|
|
}
|
|
|
|
|
2007-01-30 02:47:19 -05:00
|
|
|
const char SYMEXPORT *alpm_pkg_get_name(pmpkg_t *pkg)
|
2006-11-20 04:10:23 -05:00
|
|
|
{
|
2007-03-01 14:07:38 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2006-11-20 04:10:23 -05:00
|
|
|
/* Sanity checks */
|
|
|
|
ASSERT(handle != NULL, return(NULL));
|
|
|
|
ASSERT(pkg != NULL, return(NULL));
|
|
|
|
|
2007-03-01 14:07:38 -05:00
|
|
|
if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_BASE)) {
|
|
|
|
_alpm_db_read(pkg->data, pkg, INFRQ_BASE);
|
|
|
|
}
|
2006-11-20 04:10:23 -05:00
|
|
|
return pkg->name;
|
|
|
|
}
|
|
|
|
|
2007-01-30 02:47:19 -05:00
|
|
|
const char SYMEXPORT *alpm_pkg_get_version(pmpkg_t *pkg)
|
2006-11-20 04:10:23 -05:00
|
|
|
{
|
2007-03-01 14:07:38 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2006-11-20 04:10:23 -05:00
|
|
|
/* Sanity checks */
|
|
|
|
ASSERT(handle != NULL, return(NULL));
|
|
|
|
ASSERT(pkg != NULL, return(NULL));
|
|
|
|
|
2007-03-01 14:07:38 -05:00
|
|
|
if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_BASE)) {
|
|
|
|
_alpm_db_read(pkg->data, pkg, INFRQ_BASE);
|
|
|
|
}
|
2006-11-20 04:10:23 -05:00
|
|
|
return pkg->version;
|
|
|
|
}
|
|
|
|
|
2007-01-30 02:47:19 -05:00
|
|
|
const char SYMEXPORT *alpm_pkg_get_desc(pmpkg_t *pkg)
|
2006-11-20 04:10:23 -05:00
|
|
|
{
|
2007-01-30 03:14:10 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2006-11-20 04:10:23 -05:00
|
|
|
/* Sanity checks */
|
|
|
|
ASSERT(handle != NULL, return(NULL));
|
|
|
|
ASSERT(pkg != NULL, return(NULL));
|
|
|
|
|
|
|
|
if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
|
2007-02-21 03:34:36 -05:00
|
|
|
_alpm_db_read(pkg->data, pkg, INFRQ_DESC);
|
2006-11-20 04:10:23 -05:00
|
|
|
}
|
|
|
|
return pkg->desc;
|
|
|
|
}
|
|
|
|
|
2007-01-30 02:47:19 -05:00
|
|
|
const char SYMEXPORT *alpm_pkg_get_url(pmpkg_t *pkg)
|
2006-11-20 04:10:23 -05:00
|
|
|
{
|
2007-01-30 03:14:10 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2006-11-20 04:10:23 -05:00
|
|
|
/* Sanity checks */
|
|
|
|
ASSERT(handle != NULL, return(NULL));
|
|
|
|
ASSERT(pkg != NULL, return(NULL));
|
|
|
|
|
|
|
|
if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
|
2007-02-21 03:34:36 -05:00
|
|
|
_alpm_db_read(pkg->data, pkg, INFRQ_DESC);
|
2006-11-20 04:10:23 -05:00
|
|
|
}
|
|
|
|
return pkg->url;
|
|
|
|
}
|
|
|
|
|
2007-01-30 02:47:19 -05:00
|
|
|
const char SYMEXPORT *alpm_pkg_get_builddate(pmpkg_t *pkg)
|
2006-11-20 04:10:23 -05:00
|
|
|
{
|
2007-01-30 03:14:10 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2006-11-20 04:10:23 -05:00
|
|
|
/* Sanity checks */
|
|
|
|
ASSERT(handle != NULL, return(NULL));
|
|
|
|
ASSERT(pkg != NULL, return(NULL));
|
|
|
|
|
|
|
|
if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
|
2007-02-21 03:34:36 -05:00
|
|
|
_alpm_db_read(pkg->data, pkg, INFRQ_DESC);
|
2006-11-20 04:10:23 -05:00
|
|
|
}
|
|
|
|
return pkg->builddate;
|
|
|
|
}
|
|
|
|
|
2007-01-30 02:47:19 -05:00
|
|
|
const char SYMEXPORT *alpm_pkg_get_buildtype(pmpkg_t *pkg)
|
2006-11-20 04:10:23 -05:00
|
|
|
{
|
2007-03-01 14:07:38 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2006-11-20 04:10:23 -05:00
|
|
|
/* Sanity checks */
|
|
|
|
ASSERT(handle != NULL, return(NULL));
|
|
|
|
ASSERT(pkg != NULL, return(NULL));
|
|
|
|
|
|
|
|
if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
|
2007-02-21 03:34:36 -05:00
|
|
|
_alpm_db_read(pkg->data, pkg, INFRQ_DESC);
|
2006-11-20 04:10:23 -05:00
|
|
|
}
|
|
|
|
return pkg->buildtype;
|
|
|
|
}
|
|
|
|
|
2007-01-30 02:47:19 -05:00
|
|
|
const char SYMEXPORT *alpm_pkg_get_installdate(pmpkg_t *pkg)
|
2006-11-20 04:10:23 -05:00
|
|
|
{
|
2007-01-30 03:14:10 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2006-11-20 04:10:23 -05:00
|
|
|
/* Sanity checks */
|
|
|
|
ASSERT(handle != NULL, return(NULL));
|
|
|
|
ASSERT(pkg != NULL, return(NULL));
|
|
|
|
|
|
|
|
if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
|
2007-02-21 03:34:36 -05:00
|
|
|
_alpm_db_read(pkg->data, pkg, INFRQ_DESC);
|
2006-11-20 04:10:23 -05:00
|
|
|
}
|
|
|
|
return pkg->installdate;
|
|
|
|
}
|
|
|
|
|
2007-01-30 02:47:19 -05:00
|
|
|
const char SYMEXPORT *alpm_pkg_get_packager(pmpkg_t *pkg)
|
2006-11-20 04:10:23 -05:00
|
|
|
{
|
2007-01-30 03:14:10 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2006-11-20 04:10:23 -05:00
|
|
|
/* Sanity checks */
|
|
|
|
ASSERT(handle != NULL, return(NULL));
|
|
|
|
ASSERT(pkg != NULL, return(NULL));
|
|
|
|
|
|
|
|
if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
|
2007-02-21 03:34:36 -05:00
|
|
|
_alpm_db_read(pkg->data, pkg, INFRQ_DESC);
|
2006-11-20 04:10:23 -05:00
|
|
|
}
|
|
|
|
return pkg->packager;
|
|
|
|
}
|
|
|
|
|
2007-01-30 02:47:19 -05:00
|
|
|
const char SYMEXPORT *alpm_pkg_get_md5sum(pmpkg_t *pkg)
|
2006-11-20 04:10:23 -05:00
|
|
|
{
|
2007-01-30 03:14:10 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2006-11-20 04:10:23 -05:00
|
|
|
/* Sanity checks */
|
|
|
|
ASSERT(handle != NULL, return(NULL));
|
|
|
|
ASSERT(pkg != NULL, return(NULL));
|
|
|
|
|
|
|
|
if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
|
2007-02-21 03:34:36 -05:00
|
|
|
_alpm_db_read(pkg->data, pkg, INFRQ_DESC);
|
2006-11-20 04:10:23 -05:00
|
|
|
}
|
|
|
|
return pkg->md5sum;
|
|
|
|
}
|
|
|
|
|
2007-01-30 02:47:19 -05:00
|
|
|
const char SYMEXPORT *alpm_pkg_get_sha1sum(pmpkg_t *pkg)
|
2006-11-20 04:10:23 -05:00
|
|
|
{
|
2007-01-30 03:14:10 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2006-11-20 04:10:23 -05:00
|
|
|
/* Sanity checks */
|
|
|
|
ASSERT(handle != NULL, return(NULL));
|
|
|
|
ASSERT(pkg != NULL, return(NULL));
|
|
|
|
|
|
|
|
if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
|
2007-02-21 03:34:36 -05:00
|
|
|
_alpm_db_read(pkg->data, pkg, INFRQ_DESC);
|
2006-11-20 04:10:23 -05:00
|
|
|
}
|
|
|
|
return pkg->sha1sum;
|
|
|
|
}
|
|
|
|
|
2007-01-30 02:47:19 -05:00
|
|
|
const char SYMEXPORT *alpm_pkg_get_arch(pmpkg_t *pkg)
|
2006-11-20 04:10:23 -05:00
|
|
|
{
|
2007-01-30 03:14:10 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2006-11-20 04:10:23 -05:00
|
|
|
/* Sanity checks */
|
|
|
|
ASSERT(handle != NULL, return(NULL));
|
|
|
|
ASSERT(pkg != NULL, return(NULL));
|
|
|
|
|
|
|
|
if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
|
2007-02-21 03:34:36 -05:00
|
|
|
_alpm_db_read(pkg->data, pkg, INFRQ_DESC);
|
2006-11-20 04:10:23 -05:00
|
|
|
}
|
|
|
|
return pkg->arch;
|
|
|
|
}
|
|
|
|
|
2007-01-30 02:47:19 -05:00
|
|
|
unsigned long SYMEXPORT alpm_pkg_get_size(pmpkg_t *pkg)
|
2006-11-20 04:10:23 -05:00
|
|
|
{
|
2007-01-30 03:14:10 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2006-11-20 04:10:23 -05:00
|
|
|
/* Sanity checks */
|
|
|
|
ASSERT(handle != NULL, return(-1));
|
|
|
|
ASSERT(pkg != NULL, return(-1));
|
|
|
|
|
|
|
|
if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
|
2007-02-21 03:34:36 -05:00
|
|
|
_alpm_db_read(pkg->data, pkg, INFRQ_DESC);
|
2006-11-20 04:10:23 -05:00
|
|
|
}
|
|
|
|
return pkg->size;
|
|
|
|
}
|
|
|
|
|
2007-01-30 02:47:19 -05:00
|
|
|
unsigned long SYMEXPORT alpm_pkg_get_isize(pmpkg_t *pkg)
|
2006-11-20 04:10:23 -05:00
|
|
|
{
|
2007-01-30 03:14:10 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2006-11-20 04:10:23 -05:00
|
|
|
/* Sanity checks */
|
|
|
|
ASSERT(handle != NULL, return(-1));
|
|
|
|
ASSERT(pkg != NULL, return(-1));
|
|
|
|
|
|
|
|
if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
|
2007-02-21 03:34:36 -05:00
|
|
|
_alpm_db_read(pkg->data, pkg, INFRQ_DESC);
|
2006-11-20 04:10:23 -05:00
|
|
|
}
|
2006-11-22 04:03:41 -05:00
|
|
|
return pkg->isize;
|
2006-11-20 04:10:23 -05:00
|
|
|
}
|
|
|
|
|
2007-01-30 02:47:19 -05:00
|
|
|
pmpkgreason_t SYMEXPORT alpm_pkg_get_reason(pmpkg_t *pkg)
|
2006-11-20 04:10:23 -05:00
|
|
|
{
|
2007-01-30 03:14:10 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2006-11-20 04:10:23 -05:00
|
|
|
/* Sanity checks */
|
|
|
|
ASSERT(handle != NULL, return(-1));
|
|
|
|
ASSERT(pkg != NULL, return(-1));
|
|
|
|
|
|
|
|
if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
|
2007-02-21 03:34:36 -05:00
|
|
|
_alpm_db_read(pkg->data, pkg, INFRQ_DESC);
|
2006-11-20 04:10:23 -05:00
|
|
|
}
|
|
|
|
return pkg->reason;
|
|
|
|
}
|
|
|
|
|
2007-01-30 02:47:19 -05:00
|
|
|
alpm_list_t SYMEXPORT *alpm_pkg_get_licenses(pmpkg_t *pkg)
|
2006-11-20 04:10:23 -05:00
|
|
|
{
|
2007-01-30 03:14:10 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2006-11-20 04:10:23 -05:00
|
|
|
/* Sanity checks */
|
|
|
|
ASSERT(handle != NULL, return(NULL));
|
|
|
|
ASSERT(pkg != NULL, return(NULL));
|
|
|
|
|
|
|
|
if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
|
2007-02-21 03:34:36 -05:00
|
|
|
_alpm_db_read(pkg->data, pkg, INFRQ_DESC);
|
2006-11-20 04:10:23 -05:00
|
|
|
}
|
2007-03-03 03:13:59 -05:00
|
|
|
return pkg->licenses;
|
2006-11-20 04:10:23 -05:00
|
|
|
}
|
|
|
|
|
2007-01-30 02:47:19 -05:00
|
|
|
alpm_list_t SYMEXPORT *alpm_pkg_get_groups(pmpkg_t *pkg)
|
2006-11-20 04:10:23 -05:00
|
|
|
{
|
2007-01-30 03:14:10 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2006-11-20 04:10:23 -05:00
|
|
|
/* Sanity checks */
|
|
|
|
ASSERT(handle != NULL, return(NULL));
|
|
|
|
ASSERT(pkg != NULL, return(NULL));
|
|
|
|
|
|
|
|
if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
|
2007-02-21 03:34:36 -05:00
|
|
|
_alpm_db_read(pkg->data, pkg, INFRQ_DESC);
|
2006-11-20 04:10:23 -05:00
|
|
|
}
|
|
|
|
return pkg->groups;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* depends */
|
2007-01-30 02:47:19 -05:00
|
|
|
alpm_list_t SYMEXPORT *alpm_pkg_get_depends(pmpkg_t *pkg)
|
2006-11-20 04:10:23 -05:00
|
|
|
{
|
2007-01-30 03:14:10 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2006-11-20 04:10:23 -05:00
|
|
|
/* Sanity checks */
|
|
|
|
ASSERT(handle != NULL, return(NULL));
|
|
|
|
ASSERT(pkg != NULL, return(NULL));
|
|
|
|
|
|
|
|
if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DEPENDS)) {
|
2007-02-21 03:34:36 -05:00
|
|
|
_alpm_db_read(pkg->data, pkg, INFRQ_DEPENDS);
|
2006-11-20 04:10:23 -05:00
|
|
|
}
|
|
|
|
return pkg->depends;
|
|
|
|
}
|
|
|
|
|
2007-01-30 02:47:19 -05:00
|
|
|
alpm_list_t SYMEXPORT *alpm_pkg_get_removes(pmpkg_t *pkg)
|
2006-11-20 04:10:23 -05:00
|
|
|
{
|
2007-01-30 03:14:10 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2006-11-20 04:10:23 -05:00
|
|
|
/* Sanity checks */
|
|
|
|
ASSERT(handle != NULL, return(NULL));
|
|
|
|
ASSERT(pkg != NULL, return(NULL));
|
|
|
|
|
|
|
|
if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DEPENDS)) {
|
2007-02-21 03:34:36 -05:00
|
|
|
_alpm_db_read(pkg->data, pkg, INFRQ_DEPENDS);
|
2006-11-20 04:10:23 -05:00
|
|
|
}
|
|
|
|
return pkg->removes;
|
|
|
|
}
|
|
|
|
|
2007-01-30 02:47:19 -05:00
|
|
|
alpm_list_t SYMEXPORT *alpm_pkg_get_requiredby(pmpkg_t *pkg)
|
2006-11-20 04:10:23 -05:00
|
|
|
{
|
2007-01-30 03:14:10 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2006-11-20 04:10:23 -05:00
|
|
|
/* Sanity checks */
|
|
|
|
ASSERT(handle != NULL, return(NULL));
|
|
|
|
ASSERT(pkg != NULL, return(NULL));
|
|
|
|
|
|
|
|
if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DEPENDS)) {
|
2007-02-21 03:34:36 -05:00
|
|
|
_alpm_db_read(pkg->data, pkg, INFRQ_DEPENDS);
|
2006-11-20 04:10:23 -05:00
|
|
|
}
|
|
|
|
return pkg->requiredby;
|
|
|
|
}
|
|
|
|
|
2007-01-30 02:47:19 -05:00
|
|
|
alpm_list_t SYMEXPORT *alpm_pkg_get_conflicts(pmpkg_t *pkg)
|
2006-11-20 04:10:23 -05:00
|
|
|
{
|
2007-01-30 03:14:10 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2006-11-20 04:10:23 -05:00
|
|
|
/* Sanity checks */
|
|
|
|
ASSERT(handle != NULL, return(NULL));
|
|
|
|
ASSERT(pkg != NULL, return(NULL));
|
|
|
|
|
|
|
|
if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DEPENDS)) {
|
2007-02-21 03:34:36 -05:00
|
|
|
_alpm_db_read(pkg->data, pkg, INFRQ_DEPENDS);
|
2006-11-20 04:10:23 -05:00
|
|
|
}
|
|
|
|
return pkg->conflicts;
|
|
|
|
}
|
|
|
|
|
2007-01-30 02:47:19 -05:00
|
|
|
alpm_list_t SYMEXPORT *alpm_pkg_get_provides(pmpkg_t *pkg)
|
2006-11-20 04:10:23 -05:00
|
|
|
{
|
2007-01-30 03:14:10 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2006-11-20 04:10:23 -05:00
|
|
|
/* Sanity checks */
|
|
|
|
ASSERT(handle != NULL, return(NULL));
|
|
|
|
ASSERT(pkg != NULL, return(NULL));
|
|
|
|
|
|
|
|
if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DEPENDS)) {
|
2007-02-21 03:34:36 -05:00
|
|
|
_alpm_db_read(pkg->data, pkg, INFRQ_DEPENDS);
|
2006-11-20 04:10:23 -05:00
|
|
|
}
|
|
|
|
return pkg->provides;
|
|
|
|
}
|
|
|
|
|
2007-01-30 02:47:19 -05:00
|
|
|
alpm_list_t SYMEXPORT *alpm_pkg_get_replaces(pmpkg_t *pkg)
|
2006-11-20 04:10:23 -05:00
|
|
|
{
|
2007-01-30 03:14:10 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2006-11-20 04:10:23 -05:00
|
|
|
/* Sanity checks */
|
|
|
|
ASSERT(handle != NULL, return(NULL));
|
|
|
|
ASSERT(pkg != NULL, return(NULL));
|
|
|
|
|
2007-02-23 03:00:06 -05:00
|
|
|
if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
|
|
|
|
_alpm_db_read(pkg->data, pkg, INFRQ_DESC);
|
2006-11-20 04:10:23 -05:00
|
|
|
}
|
|
|
|
return pkg->replaces;
|
|
|
|
}
|
|
|
|
|
2007-01-30 02:47:19 -05:00
|
|
|
alpm_list_t SYMEXPORT *alpm_pkg_get_files(pmpkg_t *pkg)
|
2006-11-20 04:10:23 -05:00
|
|
|
{
|
2007-01-30 03:14:10 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2006-11-20 04:10:23 -05:00
|
|
|
/* 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)) {
|
2007-02-21 03:34:36 -05:00
|
|
|
_alpm_db_read(pkg->data, pkg, INFRQ_FILES);
|
2006-11-20 04:10:23 -05:00
|
|
|
}
|
|
|
|
return pkg->files;
|
|
|
|
}
|
|
|
|
|
2007-01-30 02:47:19 -05:00
|
|
|
alpm_list_t SYMEXPORT *alpm_pkg_get_backup(pmpkg_t *pkg)
|
2006-11-20 04:10:23 -05:00
|
|
|
{
|
2007-01-30 03:14:10 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2006-11-20 04:10:23 -05:00
|
|
|
/* 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)) {
|
2007-02-21 03:34:36 -05:00
|
|
|
_alpm_db_read(pkg->data, pkg, INFRQ_FILES);
|
2006-11-20 04:10:23 -05:00
|
|
|
}
|
|
|
|
return pkg->backup;
|
|
|
|
}
|
|
|
|
|
2007-01-30 02:47:19 -05:00
|
|
|
unsigned short SYMEXPORT alpm_pkg_has_scriptlet(pmpkg_t *pkg)
|
2006-11-20 04:10:23 -05:00
|
|
|
{
|
2007-01-30 03:14:10 -05:00
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
2006-11-20 04:10:23 -05:00
|
|
|
/* 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)) {
|
2007-02-21 03:34:36 -05:00
|
|
|
_alpm_db_read(pkg->data, pkg, INFRQ_SCRIPTLET);
|
2006-11-20 04:10:23 -05:00
|
|
|
}
|
|
|
|
return pkg->scriptlet;
|
|
|
|
}
|
|
|
|
|
2007-03-01 14:07:38 -05:00
|
|
|
/* TODO this should either be public, or done somewhere else */
|
2007-02-04 03:26:52 -05:00
|
|
|
int _alpm_pkg_istoonew(pmpkg_t *pkg)
|
|
|
|
{
|
|
|
|
time_t t;
|
|
|
|
|
|
|
|
ALPM_LOG_FUNC;
|
|
|
|
|
|
|
|
if (!handle->upgradedelay)
|
|
|
|
return 0;
|
|
|
|
time(&t);
|
|
|
|
return((pkg->date + handle->upgradedelay) > t);
|
|
|
|
}
|
2005-03-14 20:51:43 -05:00
|
|
|
/* vim: set ts=2 sw=2 noet: */
|