summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/add.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2007-06-18 05:25:07 +0200
committerDan McGee <dan@archlinux.org>2007-09-28 07:16:43 +0200
commitf7bbfe4052ca1060d2d1021dacd77923d8ab6786 (patch)
treec1013c79b1148874ff30effe4c84c99eb69b5a86 /lib/libalpm/add.c
parent0758012b6617fd25f3af84853611b9adaf65f674 (diff)
downloadpacman-f7bbfe4052ca1060d2d1021dacd77923d8ab6786.tar.gz
pacman-f7bbfe4052ca1060d2d1021dacd77923d8ab6786.tar.xz
Remove package name dependency from libalpm
Previously, package names must match a specified scheme or they will cause pacman add operations to fail. This is not a very intelligent or necessary way to act, so remove the dependency on the name of the package to be installed and read all relevant information from the metadata instead. This does have one causality to be addressed later- pacman cache cleaning functionality, which has never been phenomenal, just lost most capability. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/add.c')
-rw-r--r--lib/libalpm/add.c45
1 files changed, 9 insertions, 36 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
index 86e80778..442b3180 100644
--- a/lib/libalpm/add.c
+++ b/lib/libalpm/add.c
@@ -53,11 +53,9 @@
int _alpm_add_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name)
{
- pmpkg_t *info = NULL;
- pmpkg_t *dummy;
- char pkgname[PKG_NAME_LEN], pkgver[PKG_VERSION_LEN];
+ pmpkg_t *pkg = NULL;
+ const char *pkgname, *pkgver;
alpm_list_t *i;
- struct stat buf;
ALPM_LOG_FUNC;
@@ -67,24 +65,11 @@ int _alpm_add_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name)
_alpm_log(PM_LOG_DEBUG, "loading target '%s'\n", name);
- /* TODO FS#5120 we need a better way to check if a package is a valid package,
- * and read the metadata instead of relying on the filename for package name
- * and version */
- if(stat(name, &buf)) {
- pm_errno = PM_ERR_NOT_A_FILE;
- goto error;
- }
-
- if(_alpm_pkg_splitname(name, pkgname, pkgver, 1) == -1) {
- pm_errno = PM_ERR_PKG_INVALID_NAME;
- goto error;
- }
-
- /* no additional hyphens in version strings */
- if(strchr(pkgver, '-') != strrchr(pkgver, '-')) {
- pm_errno = PM_ERR_PKG_INVALID_NAME;
+ if(alpm_pkg_load(name, &pkg) != 0) {
goto error;
}
+ pkgname = alpm_pkg_get_name(pkg);
+ pkgver = alpm_pkg_get_version(pkg);
if(trans->type != PM_TRANS_TYPE_UPGRADE) {
/* only install this package if it is not already installed */
@@ -95,7 +80,7 @@ int _alpm_add_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name)
} else {
if(trans->flags & PM_TRANS_FLAG_FRESHEN) {
/* only upgrade/install this package if it is already installed and at a lesser version */
- dummy = _alpm_db_get_pkgfromcache(db, pkgname);
+ pmpkg_t *dummy = _alpm_db_get_pkgfromcache(db, pkgname);
if(dummy == NULL || _alpm_versioncmp(dummy->version, pkgver) >= 0) {
pm_errno = PM_ERR_PKG_CANT_FRESH;
goto error;
@@ -126,29 +111,17 @@ int _alpm_add_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name)
}
}
- _alpm_log(PM_LOG_DEBUG, "reading '%s' metadata\n", pkgname);
- info = _alpm_pkg_load(name);
- if(info == NULL) {
- /* pm_errno is already set by pkg_load() */
- goto error;
- }
- /* check to verify we're not getting fooled by a corrupted package */
- if(strcmp(pkgname, info->name) != 0 || strcmp(pkgver, info->version) != 0) {
- pm_errno = PM_ERR_PKG_INVALID;
- goto error;
- }
-
if(trans->flags & PM_TRANS_FLAG_ALLDEPS) {
- info->reason = PM_PKG_REASON_DEPEND;
+ pkg->reason = PM_PKG_REASON_DEPEND;
}
/* add the package to the transaction */
- trans->packages = alpm_list_add(trans->packages, info);
+ trans->packages = alpm_list_add(trans->packages, pkg);
return(0);
error:
- _alpm_pkg_free(info);
+ _alpm_pkg_free(pkg);
return(-1);
}