summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/package.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2007-06-04 20:50:16 +0200
committerDan McGee <dan@archlinux.org>2007-06-09 19:03:25 +0200
commit35a794c2ed4da7da44d3a04794fc90615e7c52e7 (patch)
tree75fd2667a69867795f6a32cc9bb1dc7d505e2004 /lib/libalpm/package.c
parentb6f3fe6957d0206485eac98fb2120578b75d0058 (diff)
downloadpacman-35a794c2ed4da7da44d3a04794fc90615e7c52e7.tar.gz
pacman-35a794c2ed4da7da44d3a04794fc90615e7c52e7.tar.xz
Allow multiple CacheDirs to be specified
This should hopefully allow multiple cache dirs to be specified in pacman.conf and/or on the command line, and allow pacman to test each one for the package file. The first one found to be writeable is used as the download cache. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/package.c')
-rw-r--r--lib/libalpm/package.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index e25ecbe4..16166691 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -103,7 +103,9 @@ int SYMEXPORT alpm_pkg_free(pmpkg_t *pkg)
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;
@@ -113,8 +115,14 @@ int alpm_pkg_checksha1sum(pmpkg_t *pkg)
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));
- snprintf(path, PATH_MAX, "%s/%s-%s" PKGEXT, handle->cachedir,
- alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg));
+ /* 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) {
@@ -146,7 +154,9 @@ int alpm_pkg_checksha1sum(pmpkg_t *pkg)
int alpm_pkg_checkmd5sum(pmpkg_t *pkg)
{
char path[PATH_MAX];
+ struct stat buf;
char *md5sum = NULL;
+ alpm_list_t *i;
int retval = 0;
ALPM_LOG_FUNC;
@@ -156,8 +166,14 @@ int alpm_pkg_checkmd5sum(pmpkg_t *pkg)
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));
- snprintf(path, PATH_MAX, "%s/%s-%s" PKGEXT, handle->cachedir,
- alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg));
+ /* 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;
+ }
+ }
md5sum = alpm_get_md5sum(path);
if(md5sum == NULL) {
@@ -182,6 +198,9 @@ int alpm_pkg_checkmd5sum(pmpkg_t *pkg)
return(retval);
}
+
+
+
/** Compare versions.
* @param ver1 first version
* @param ver2 secont version