Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm/sync.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2007-05-31 02:51:28 -0400
committerDan McGee <dan@archlinux.org>2007-05-31 02:51:28 -0400
commit7bd2ff685188d0d9b6ab6c6f43f6d28811936881 (patch)
tree30bbb96d2bbb8a6c63d9f7e7e6ac1c8b4b818148 /lib/libalpm/sync.c
parent722db4535ae6690d8834ffebf3a0de3a880188f9 (diff)
Move DB and cache dirs away from there dependence on ROOTDIR
This change allows us to use all autoconf specified paths, most notably $(localstatedir). It is quite a change and touches a lot of files, as all references to the DB and cache were done with the ROOTDIR as a prefix. * add --lock command-line option to pacman to specify the location of the lockfile (this can now be specified at configure time by setting the $localstatedir path). * Rip quite a few settings out of configure.ac as they are now picked by setting the paths during configure or make. * Fix bug with /tmp fallback for sync downloads not working correctly (related to root location, now the system tmp dir is used). * Simplified the parameters to some libalpm functions, and added get/set for the new lockfile option. * Renamed several of the DEFS to names without the PM_ prefix. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/sync.c')
-rw-r--r--lib/libalpm/sync.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 87f8c720..5b573b72 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -777,7 +777,7 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
alpm_list_t *i, *j, *files = NULL;
pmtrans_t *tr = NULL;
int replaces = 0, retval = 0;
- char ldir[PATH_MAX];
+ const char *cachedir;
int varcache = 1;
ALPM_LOG_FUNC;
@@ -787,7 +787,7 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
trans->state = STATE_DOWNLOADING;
/* group sync records by repository and download */
- snprintf(ldir, PATH_MAX, "%s%s", handle->root, handle->cachedir);
+ cachedir = alpm_option_get_cachedir();
for(i = handle->dbs_sync; i; i = i->next) {
pmdb_t *current = i->data;
@@ -806,7 +806,7 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
EVENT(trans, PM_TRANS_EVT_PRINTURI, (char *)alpm_db_get_url(current), (char *)fname);
} else {
struct stat buf;
- snprintf(path, PATH_MAX, "%s/%s", ldir, fname);
+ snprintf(path, PATH_MAX, "%s/%s", cachedir, fname);
if(stat(path, &buf)) {
/* file is not in the cache dir, so add it to the list */
files = alpm_list_add(files, strdup(fname));
@@ -820,22 +820,23 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
if(files) {
struct stat buf;
EVENT(trans, PM_TRANS_EVT_RETRIEVE_START, current->treename, NULL);
- if(stat(ldir, &buf)) {
+ if(stat(cachedir, &buf)) {
/* no cache directory.... try creating it */
- _alpm_log(PM_LOG_WARNING, _("no %s cache exists, creating...\n"), ldir);
- alpm_logaction(_("warning: no %s cache exists, creating..."), ldir);
- if(_alpm_makepath(ldir)) {
+ _alpm_log(PM_LOG_WARNING, _("no %s cache exists, creating...\n"), cachedir);
+ alpm_logaction(_("warning: no %s cache exists, creating..."), cachedir);
+ if(_alpm_makepath(cachedir)) {
/* couldn't mkdir the cache directory, so fall back to /tmp and unlink
* the package afterwards.
*/
_alpm_log(PM_LOG_WARNING, _("couldn't create package cache, using /tmp instead\n"));
alpm_logaction(_("warning: couldn't create package cache, using /tmp instead"));
- snprintf(ldir, PATH_MAX, "%stmp", alpm_option_get_root());
- alpm_option_set_cachedir(ldir);
+ alpm_option_set_cachedir("/tmp");
+ cachedir = alpm_option_get_cachedir();
varcache = 0;
}
}
- if(_alpm_downloadfiles(current->servers, ldir, files)) {
+ if(_alpm_downloadfiles(current->servers, alpm_option_get_cachedir(),
+ files)) {
_alpm_log(PM_LOG_WARNING, _("failed to retrieve some files from %s\n"), current->treename);
RET_ERR(PM_ERR_RETRIEVE, -1);
}
@@ -871,7 +872,7 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
retval = 1;
continue;
}
- snprintf(str, PATH_MAX, "%s%s%s", handle->root, handle->cachedir, pkgname);
+ snprintf(str, PATH_MAX, "%s%s", alpm_option_get_cachedir(), pkgname);
md5sum2 = _alpm_MDFile(str);
sha1sum2 = _alpm_SHAFile(str);
if(md5sum2 == NULL && sha1sum2 == NULL) {
@@ -895,7 +896,7 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
}
if(doremove) {
char str[PATH_MAX];
- snprintf(str, PATH_MAX, "%s%s%s", handle->root, handle->cachedir, pkgname);
+ snprintf(str, PATH_MAX, "%s%s", alpm_option_get_cachedir(), pkgname);
unlink(str);
snprintf(ptr, 512, _("archive %s was corrupted (bad MD5 or SHA1 checksum)\n"), pkgname);
} else {
@@ -981,7 +982,7 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
char str[PATH_MAX];
fname = alpm_pkg_get_filename(spkg);
- snprintf(str, PATH_MAX, "%s%s%s", handle->root, handle->cachedir, fname);
+ snprintf(str, PATH_MAX, "%s%s", alpm_option_get_cachedir(), fname);
if(_alpm_trans_addtarget(tr, str) == -1) {
goto error;
}