1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-12-23 00:08:50 -05:00

- updated sync feature

- added 2 new transaction events
This commit is contained in:
Aurelien Foret 2005-04-13 19:59:04 +00:00
parent 45c7e10afc
commit e115a5829e
4 changed files with 117 additions and 141 deletions

View File

@ -220,6 +220,8 @@ enum {
PM_TRANS_EVT_FILECONFLICTS_DONE, PM_TRANS_EVT_FILECONFLICTS_DONE,
PM_TRANS_EVT_RESOLVEDEPS_START, PM_TRANS_EVT_RESOLVEDEPS_START,
PM_TRANS_EVT_RESOLVEDEPS_DONE, PM_TRANS_EVT_RESOLVEDEPS_DONE,
PM_TRANS_EVT_INTERCONFLICTS_START,
PM_TRANS_EVT_INTERCONFLICTS_DONE,
PM_TRANS_EVT_ADD_START, PM_TRANS_EVT_ADD_START,
PM_TRANS_EVT_ADD_DONE, PM_TRANS_EVT_ADD_DONE,
PM_TRANS_EVT_REMOVE_START, PM_TRANS_EVT_REMOVE_START,

View File

@ -311,21 +311,16 @@ int sync_prepare(pmdb_t *db, pmtrans_t *trans, PMList **data)
return(0); return(0);
} }
for(i = trans->packages; i; i = i->next) {
pmsyncpkg_t *sync = i->data;
list = pm_list_add(list, sync->spkg);
}
/* Resolve targets dependencies */
if(!(trans->flags & PM_TRANS_FLAG_NODEPS)) { if(!(trans->flags & PM_TRANS_FLAG_NODEPS)) {
TRANS_CB(trans, PM_TRANS_EVT_RESOLVEDEPS_START, NULL, NULL);
for(i = trans->packages; i; i = i->next) { for(i = trans->packages; i; i = i->next) {
pmsyncpkg_t *sync = i->data; pmsyncpkg_t *sync = i->data;
list = pm_list_add(list, sync->spkg); list = pm_list_add(list, sync->spkg);
} }
trail = pm_list_new(); trail = pm_list_new();
/* Resolve targets dependencies */
TRANS_CB(trans, PM_TRANS_EVT_RESOLVEDEPS_START, NULL, NULL);
_alpm_log(PM_LOG_FLOW1, "resolving targets dependencies");
for(i = trans->packages; i; i = i->next) { for(i = trans->packages; i; i = i->next) {
pmsyncpkg_t *sync = i->data; pmsyncpkg_t *sync = i->data;
pmpkg_t *spkg = sync->spkg; pmpkg_t *spkg = sync->spkg;
@ -338,7 +333,6 @@ int sync_prepare(pmdb_t *db, pmtrans_t *trans, PMList **data)
if called from makepkg, reason should be set to REASON_DEPEND if called from makepkg, reason should be set to REASON_DEPEND
spkg->reason = PM_PKG_REASON_EXPLICIT;*/ spkg->reason = PM_PKG_REASON_EXPLICIT;*/
} }
for(i = list; i; i = i->next) { for(i = list; i; i = i->next) {
pmpkg_t *spkg = i->data; pmpkg_t *spkg = i->data;
if(!find_pkginsync(spkg->name, trans->packages)) { if(!find_pkginsync(spkg->name, trans->packages)) {
@ -346,19 +340,15 @@ int sync_prepare(pmdb_t *db, pmtrans_t *trans, PMList **data)
trans->packages = pm_list_add(trans->packages, sync); trans->packages = pm_list_add(trans->packages, sync);
} }
} }
FREELISTPTR(list);
FREELISTPTR(trail);
TRANS_CB(trans, PM_TRANS_EVT_RESOLVEDEPS_DONE, NULL, NULL); TRANS_CB(trans, PM_TRANS_EVT_RESOLVEDEPS_DONE, NULL, NULL);
}
/* ORE /* ORE
check for inter-conflicts and whatnot */ check for inter-conflicts and whatnot */
_alpm_log(PM_LOG_FLOW1, "looking for inter-conflicts"); TRANS_CB(trans, PM_TRANS_EVT_INTERCONFLICTS_START, NULL, NULL);
deps = checkdeps(db, PM_TRANS_TYPE_UPGRADE, list); deps = checkdeps(db, PM_TRANS_TYPE_UPGRADE, list);
if(deps) { if(deps) {
int errorout = 0; int errorout = 0;
_alpm_log(PM_LOG_FLOW1, "looking for unresolvable dependencies");
for(i = deps; i; i = i->next) { for(i = deps; i; i = i->next) {
pmdepmissing_t *miss = i->data; pmdepmissing_t *miss = i->data;
if(miss->type == PM_DEP_TYPE_DEPEND || miss->type == PM_DEP_TYPE_REQUIRED) { if(miss->type == PM_DEP_TYPE_DEPEND || miss->type == PM_DEP_TYPE_REQUIRED) {
@ -379,7 +369,13 @@ int sync_prepare(pmdb_t *db, pmtrans_t *trans, PMList **data)
RET_ERR(PM_ERR_UNSATISFIED_DEPS, -1); RET_ERR(PM_ERR_UNSATISFIED_DEPS, -1);
} }
/* ORE /* ORE
then look for conflicts */ no unresolvable deps, so look for conflicts */
_alpm_log(PM_LOG_FLOW1, "looking for conflicts");
}
TRANS_CB(trans, PM_TRANS_EVT_INTERCONFLICTS_DONE, NULL, NULL);
FREELISTPTR(list);
FREELISTPTR(trail);
} }
/* ORE /* ORE

View File

@ -366,14 +366,10 @@ int pacman_sync(list_t *targets)
int retval = 0; int retval = 0;
list_t *final = NULL; list_t *final = NULL;
list_t *i; list_t *i;
PM_LIST *data; PM_LIST *packages, *data;
char *root; char *root;
char ldir[PATH_MAX]; char ldir[PATH_MAX];
int varcache = 1; int varcache = 1;
int done;
int count;
sync_t *current = NULL;
list_t *processed = NULL;
list_t *files = NULL; list_t *files = NULL;
if(pmc_syncs == NULL || !list_count(pmc_syncs)) { if(pmc_syncs == NULL || !list_count(pmc_syncs)) {
@ -549,11 +545,11 @@ int pacman_sync(list_t *targets)
/* list targets */ /* list targets */
if(!pmo_s_printuris) { if(!pmo_s_printuris) {
PM_LIST *packages, *lp;
list_t *list = NULL; list_t *list = NULL;
char *str; char *str;
unsigned long totalsize = 0; unsigned long totalsize = 0;
double mb; double mb;
PM_LIST *lp;
/* ORE /* ORE
for(i = rmtargs; i; i = i->next) { for(i = rmtargs; i; i = i->next) {
list = list_add(list, strdup(i->data)); list = list_add(list, strdup(i->data));
@ -603,7 +599,6 @@ int pacman_sync(list_t *targets)
MSG(NL, "\nTotal Package Size: %.1f MB\n", mb); MSG(NL, "\nTotal Package Size: %.1f MB\n", mb);
FREELIST(list); FREELIST(list);
FREE(str); FREE(str);
}
/* get confirmation */ /* get confirmation */
if(pmo_s_downloadonly) { if(pmo_s_downloadonly) {
@ -616,7 +611,7 @@ int pacman_sync(list_t *targets)
} }
} else { } else {
/* don't get any confirmation if we're called from makepkg */ /* don't get any confirmation if we're called from makepkg */
if(pmo_d_resolve || pmo_s_printuris) { if(pmo_d_resolve) {
confirm = 1; confirm = 1;
} else { } else {
if(pmo_noconfirm) { if(pmo_noconfirm) {
@ -632,70 +627,52 @@ int pacman_sync(list_t *targets)
retval = 1; retval = 1;
goto cleanup; goto cleanup;
} }
}
/* group sync records by repository and download */ /* group sync records by repository and download */
alpm_get_option(PM_OPT_ROOT, (long *)&root); alpm_get_option(PM_OPT_ROOT, (long *)&root);
snprintf(ldir, PATH_MAX, "%s" CACHEDIR, root); snprintf(ldir, PATH_MAX, "%s" CACHEDIR, root);
done = 0; for(i = pmc_syncs; i; i = i->next) {
count = 0;
processed = NULL;
current = NULL;
while(!done) {
PM_LIST *lp; PM_LIST *lp;
printf("in while\n"); sync_t *current = i->data;
if(current) {
processed = list_add(processed, current); for(lp = alpm_list_first(packages); lp; lp = alpm_list_next(lp)) {
current = NULL; PM_SYNCPKG *sync = alpm_list_getdata(lp);
} PM_PKG *spkg = alpm_sync_getinfo(sync, PM_SYNC_SYNCPKG);
for(lp = alpm_list_first(alpm_trans_getinfo(PM_TRANS_PACKAGES)); lp; lp = alpm_list_next(lp)) { PM_DB *dbs = alpm_pkg_getinfo(spkg, PM_PKG_DB);
PM_PKG *sync = alpm_list_getdata(lp);
if(current == NULL) { if(current->db == dbs) {
PM_DB *dbs = alpm_pkg_getinfo(sync, PM_PKG_DB);
/* we're starting on a new repository */
if(!list_is_ptrin(dbs, processed)) {
/* ORE
current = dbs;*/
current = NULL;
}
}
/*if(current && !strcmp(current->treename, sync->dbs->sync->treename)) {
struct stat buf; struct stat buf;
char path[PATH_MAX]; char path[PATH_MAX];
char *pkgname, *pkgver;
pkgname = alpm_pkg_getinfo(spkg, PM_PKG_NAME);
pkgver = alpm_pkg_getinfo(spkg, PM_PKG_VERSION);
if(pmo_s_printuris) { if(pmo_s_printuris) {
snprintf(path, PATH_MAX, "%s-%s%s", sync->pkg->name, sync->pkg->version, PKGEXT); server_t *server = (server_t*)current->servers->data;
files = list_add(files, strdup(path)); snprintf(path, PATH_MAX, "%s-%s" PM_EXT_PKG, pkgname, pkgver);
if(!strcmp(server->protocol, "file")) {
MSG(NL, "%s://%s%s\n", server->protocol, server->path, path);
} else { } else {
snprintf(path, PATH_MAX, "%s/%s-%s%s", MSG(NL, "%s://%s%s%s\n", server->protocol,
ldir, sync->pkg->name, sync->pkg->version, PKGEXT); server->server, server->path, path);
}
} else {
snprintf(path, PATH_MAX, "%s/%s-%s" PM_EXT_PKG, ldir, pkgname, pkgver);
if(stat(path, &buf)) { if(stat(path, &buf)) {
// file is not in the cache dir, so add it to the list // /* file is not in the cache dir, so add it to the list */
snprintf(path, PATH_MAX, "%s-%s%s", sync->pkg->name, sync->pkg->version, PKGEXT); snprintf(path, PATH_MAX, "%s-%s" PM_EXT_PKG, pkgname, pkgver);
files = list_add(files, strdup(path)); files = list_add(files, strdup(path));
} else { } else {
vprint(" %s-%s%s is already in the cache\n", sync->pkg->name, sync->pkg->version, PKGEXT); vprint(" %s-%s" PM_EXT_PKG " is already in the cache\n", pkgname, pkgver);
count++; }
} }
} }
}*/
} }
if(files) { if(files) {
if(pmo_s_printuris) {
list_t *j;
server_t *server = (server_t*)current->servers->data;
for(j = files; j; j = j->next) {
if(!strcmp(server->protocol, "file")) {
MSG(NL, "%s://%s%s\n", server->protocol, server->path,
(char *)j->data);
} else {
MSG(NL, "%s://%s%s%s\n", server->protocol,
server->server, server->path, (char *)j->data);
}
}
} else {
struct stat buf; struct stat buf;
MSG(NL, "\n:: Retrieving packages from %s...\n", current->treename); MSG(NL, "\n:: Retrieving packages from %s...\n", current->treename);
fflush(stdout); fflush(stdout);
if(stat(ldir, &buf)) { if(stat(ldir, &buf)) {
@ -717,16 +694,13 @@ int pacman_sync(list_t *targets)
retval = 1; retval = 1;
goto cleanup; goto cleanup;
} }
}
count += list_count(files);
FREELIST(files); FREELIST(files);
} }
if(count == list_count(final)) {
done = 1;
} }
if(pmo_s_printuris) {
goto cleanup;
} }
printf("\n"); MSG(NL, "\n");
/* Check integrity of files */ /* Check integrity of files */
MSG(NL, "checking package integrity... "); MSG(NL, "checking package integrity... ");

View File

@ -50,9 +50,13 @@ void cb_trans(unsigned short event, void *data1, void *data2)
case PM_TRANS_EVT_RESOLVEDEPS_START: case PM_TRANS_EVT_RESOLVEDEPS_START:
MSG(NL, "resolving dependencies... "); MSG(NL, "resolving dependencies... ");
break; break;
case PM_TRANS_EVT_INTERCONFLICTS_START:
MSG(NL, "looking inter-conflicts... ");
break;
case PM_TRANS_EVT_CHECKDEPS_DONE: case PM_TRANS_EVT_CHECKDEPS_DONE:
case PM_TRANS_EVT_FILECONFLICTS_DONE: case PM_TRANS_EVT_FILECONFLICTS_DONE:
case PM_TRANS_EVT_RESOLVEDEPS_DONE: case PM_TRANS_EVT_RESOLVEDEPS_DONE:
case PM_TRANS_EVT_INTERCONFLICTS_DONE:
MSG(CL, "done.\n"); MSG(CL, "done.\n");
break; break;
case PM_TRANS_EVT_ADD_START: case PM_TRANS_EVT_ADD_START: