diff options
author | Dan McGee <dan@archlinux.org> | 2007-05-31 02:51:28 -0400 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2007-05-31 02:51:28 -0400 |
commit | 7bd2ff685188d0d9b6ab6c6f43f6d28811936881 (patch) | |
tree | 30bbb96d2bbb8a6c63d9f7e7e6ac1c8b4b818148 /src/pacman/sync.c | |
parent | 722db4535ae6690d8834ffebf3a0de3a880188f9 (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 'src/pacman/sync.c')
-rw-r--r-- | src/pacman/sync.c | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/src/pacman/sync.c b/src/pacman/sync.c index f013d45f..d04c7da9 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -61,7 +61,7 @@ static int split_pkgname(char *target, char *name, char *version) } strncpy(tmp, p, 512); /* trim file extension (if any) */ - if((p = strstr(tmp, PM_EXT_PKG))) { + if((p = strstr(tmp, PKGEXT))) { *p = '\0'; } /* trim architecture */ @@ -89,13 +89,7 @@ static int split_pkgname(char *target, char *name, char *version) static int sync_cleancache(int level) { - const char *root, *cachedir; - char dirpath[PATH_MAX]; - - root = alpm_option_get_root(); - cachedir = alpm_option_get_cachedir(); - - snprintf(dirpath, PATH_MAX, "%s%s", root, cachedir); + const char *cachedir = alpm_option_get_cachedir(); if(level == 1) { /* incomplete cleanup: we keep latest packages and partial downloads */ @@ -106,7 +100,7 @@ static int sync_cleancache(int level) if(!yesno(_("Do you want to remove old packages from cache? [Y/n] "))) return(0); printf(_("removing old packages from cache... ")); - dir = opendir(dirpath); + dir = opendir(cachedir); if(dir == NULL) { fprintf(stderr, _("error: could not access cache directory\n")); return(1); @@ -124,12 +118,12 @@ static int sync_cleancache(int level) char *str = alpm_list_getdata(i); char name[256], version[64]; - if(strstr(str, PM_EXT_PKG) == NULL) { + if(strstr(str, PKGEXT) == NULL) { clean = alpm_list_add(clean, strdup(str)); continue; } /* we keep partially downloaded files */ - if(strstr(str, PM_EXT_PKG ".part")) { + if(strstr(str, PKGEXT ".part")) { continue; } if(split_pkgname(str, name, version) != 0) { @@ -140,10 +134,10 @@ static int sync_cleancache(int level) char *s = alpm_list_getdata(j); char n[256], v[64]; - if(strstr(s, PM_EXT_PKG) == NULL) { + if(strstr(s, PKGEXT) == NULL) { continue; } - if(strstr(s, PM_EXT_PKG ".part")) { + if(strstr(s, PKGEXT ".part")) { continue; } if(split_pkgname(s, n, v) != 0) { @@ -163,7 +157,7 @@ static int sync_cleancache(int level) for(i = clean; i; i = alpm_list_next(i)) { char path[PATH_MAX]; - snprintf(path, PATH_MAX, "%s/%s", dirpath, (char *)alpm_list_getdata(i)); + snprintf(path, PATH_MAX, "%s/%s", cachedir, (char *)alpm_list_getdata(i)); unlink(path); } FREELIST(clean); @@ -173,12 +167,12 @@ static int sync_cleancache(int level) return(0); printf(_("removing all packages from cache... ")); - if(rmrf(dirpath)) { + if(rmrf(cachedir)) { fprintf(stderr, _("error: could not remove cache directory\n")); return(1); } - if(makepath(dirpath)) { + if(makepath(cachedir)) { fprintf(stderr, _("error: could not create new cache directory\n")); return(1); } @@ -492,8 +486,7 @@ int pacman_sync(alpm_list_t *targets) alpm_strerror(pm_errno)); if(pm_errno == PM_ERR_HANDLE_LOCK) { printf(_(" if you're sure a package manager is not already\n" - " running, you can remove %s%s.\n"), - alpm_option_get_root(), PM_LOCK); + " running, you can remove %s.\n"), LOCKFILE); } return(1); } |