- indented properly sync_cleancache()
- reworked sync_list() - added a log
This commit is contained in:
parent
df5c0392fa
commit
2b0c91cff8
1 changed files with 98 additions and 91 deletions
|
@ -72,7 +72,7 @@ static int sync_cleancache(int level)
|
||||||
list_t *i, *j;
|
list_t *i, *j;
|
||||||
char dirpath[PATH_MAX];
|
char dirpath[PATH_MAX];
|
||||||
|
|
||||||
snprintf(dirpath, PATH_MAX, "%s"CACHEDIR, root);
|
snprintf(dirpath, PATH_MAX, "%s" CACHEDIR, root);
|
||||||
|
|
||||||
MSG(NL, "removing old packages from cache... ");
|
MSG(NL, "removing old packages from cache... ");
|
||||||
dir = opendir(dirpath);
|
dir = opendir(dirpath);
|
||||||
|
@ -98,7 +98,7 @@ static int sync_cleancache(int level)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/* we keep partially downloaded files */
|
/* we keep partially downloaded files */
|
||||||
if(strstr(str, PM_EXT_PKG".part")) {
|
if(strstr(str, PM_EXT_PKG ".part")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(split_pkgname(str, name, version) != 0) {
|
if(split_pkgname(str, name, version) != 0) {
|
||||||
|
@ -112,7 +112,7 @@ static int sync_cleancache(int level)
|
||||||
if(strstr(s, PM_EXT_PKG) == NULL) {
|
if(strstr(s, PM_EXT_PKG) == NULL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(strstr(s, PM_EXT_PKG".part")) {
|
if(strstr(s, PM_EXT_PKG ".part")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(split_pkgname(s, n, v) != 0) {
|
if(split_pkgname(s, n, v) != 0) {
|
||||||
|
@ -131,7 +131,7 @@ static int sync_cleancache(int level)
|
||||||
for(i = clean; i; i = i->next) {
|
for(i = clean; i; i = i->next) {
|
||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
|
|
||||||
snprintf(path, PATH_MAX, "%s"CACHEDIR"/%s", root, (char *)i->data);
|
snprintf(path, PATH_MAX, "%s" CACHEDIR "/%s", root, (char *)i->data);
|
||||||
unlink(path);
|
unlink(path);
|
||||||
}
|
}
|
||||||
FREELIST(clean);
|
FREELIST(clean);
|
||||||
|
@ -139,7 +139,7 @@ static int sync_cleancache(int level)
|
||||||
/* full cleanup */
|
/* full cleanup */
|
||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
|
|
||||||
snprintf(path, PATH_MAX, "%s"CACHEDIR, root);
|
snprintf(path, PATH_MAX, "%s" CACHEDIR, root);
|
||||||
|
|
||||||
MSG(NL, "removing all packages from cache... ");
|
MSG(NL, "removing all packages from cache... ");
|
||||||
if(rmrf(path)) {
|
if(rmrf(path)) {
|
||||||
|
@ -152,6 +152,7 @@ static int sync_cleancache(int level)
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MSG(CL, "done.\n");
|
MSG(CL, "done.\n");
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
@ -181,7 +182,7 @@ static int sync_synctree(list_t *syncs)
|
||||||
mtime = lastupdate;
|
mtime = lastupdate;
|
||||||
|
|
||||||
/* build a one-element list */
|
/* build a one-element list */
|
||||||
snprintf(path, PATH_MAX, "%s"PM_EXT_DB, sync->treename);
|
snprintf(path, PATH_MAX, "%s" PM_EXT_DB, sync->treename);
|
||||||
files = list_add(files, strdup(path));
|
files = list_add(files, strdup(path));
|
||||||
|
|
||||||
snprintf(path, PATH_MAX, "%s%s", root, dbpath);
|
snprintf(path, PATH_MAX, "%s%s", root, dbpath);
|
||||||
|
@ -193,9 +194,9 @@ static int sync_synctree(list_t *syncs)
|
||||||
ERR(NL, "failed to synchronize %s\n", sync->treename);
|
ERR(NL, "failed to synchronize %s\n", sync->treename);
|
||||||
success--;
|
success--;
|
||||||
} else if(ret < 0) {
|
} else if(ret < 0) {
|
||||||
MSG(NL, ":: %s is up to date\n", sync->treename);
|
MSG(NL, " %s is up to date\n", sync->treename);
|
||||||
} else {
|
} else {
|
||||||
snprintf(path, PATH_MAX, "%s%s/%s"PM_EXT_DB, root, dbpath, sync->treename);
|
snprintf(path, PATH_MAX, "%s%s/%s" PM_EXT_DB, root, dbpath, sync->treename);
|
||||||
if(alpm_db_update(sync->db, path, newmtime) == -1) {
|
if(alpm_db_update(sync->db, path, newmtime) == -1) {
|
||||||
ERR(NL, "failed to synchronize %s (%s)\n", sync->treename, alpm_strerror(pm_errno));
|
ERR(NL, "failed to synchronize %s (%s)\n", sync->treename, alpm_strerror(pm_errno));
|
||||||
success--;
|
success--;
|
||||||
|
@ -313,36 +314,38 @@ static int sync_info(list_t *syncs, list_t *targets)
|
||||||
|
|
||||||
static int sync_list(list_t *syncs, list_t *targets)
|
static int sync_list(list_t *syncs, list_t *targets)
|
||||||
{
|
{
|
||||||
list_t *i, *treenames = NULL;
|
list_t *i;
|
||||||
|
list_t *ls = NULL;
|
||||||
|
|
||||||
if(targets) {
|
if(targets) {
|
||||||
for(i = targets; i; i = i->next) {
|
for(i = targets; i; i = i->next) {
|
||||||
list_t *j;
|
list_t *j;
|
||||||
sync_t *sync = NULL;
|
sync_t *sync = NULL;
|
||||||
|
|
||||||
for(j = syncs; j; j = j->next) {
|
for(j = syncs; j && !sync; j = j->next) {
|
||||||
sync_t *s = j->data;
|
sync_t *s = j->data;
|
||||||
|
|
||||||
if(strcmp(i->data, s->treename) == 0) {
|
if(strcmp(i->data, s->treename) == 0) {
|
||||||
MALLOC(sync, sizeof(sync_t));
|
sync = s;
|
||||||
sync->treename = i->data;
|
|
||||||
sync->db = s->db;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sync == NULL) {
|
if(sync == NULL) {
|
||||||
ERR(NL, "repository \"%s\" was not found.\n", (char *)i->data);
|
ERR(NL, "repository \"%s\" was not found.\n", (char *)i->data);
|
||||||
list_free(treenames);
|
for(j = ls; j; j = j->next) {
|
||||||
|
j->data = NULL;
|
||||||
|
}
|
||||||
|
list_free(ls);
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
treenames = list_add(treenames, sync);
|
ls = list_add(ls, sync);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
treenames = syncs;
|
ls = syncs;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = treenames; i; i = i->next) {
|
for(i = ls; i; i = i->next) {
|
||||||
PM_LIST *lp;
|
PM_LIST *lp;
|
||||||
sync_t *sync = i->data;
|
sync_t *sync = i->data;
|
||||||
|
|
||||||
|
@ -354,7 +357,10 @@ static int sync_list(list_t *syncs, list_t *targets)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(targets) {
|
if(targets) {
|
||||||
list_free(treenames);
|
for(i = ls; i; i = i->next) {
|
||||||
|
i->data = NULL;
|
||||||
|
}
|
||||||
|
list_free(ls);
|
||||||
}
|
}
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
|
@ -424,6 +430,7 @@ int pacman_sync(list_t *targets)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pmo_s_upgrade) {
|
if(pmo_s_upgrade) {
|
||||||
|
MSG(NL, ":: Starting local database upgrade...\n");
|
||||||
alpm_logaction("starting full system upgrade");
|
alpm_logaction("starting full system upgrade");
|
||||||
if(alpm_trans_sysupgrade() == -1) {
|
if(alpm_trans_sysupgrade() == -1) {
|
||||||
ERR(NL, "%s\n", alpm_strerror(pm_errno));
|
ERR(NL, "%s\n", alpm_strerror(pm_errno));
|
||||||
|
|
Loading…
Add table
Reference in a new issue