Move -Sp implementation to the front-end
This patch kills one of our hackish pseudo transactions: PRINTURIS. (The other one is -Sw) From now on, front-end must not call trans_commit in case of -Sp, it should print the uris of target packages "by hand" instead. PRINTURIS flag was removed, NOCONFLICTS flag can be passed to skip conflict checks. Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
8146f6f1c6
commit
baf5852555
|
@ -283,7 +283,7 @@ typedef enum _pmtransflag_t {
|
|||
PM_TRANS_FLAG_DOWNLOADONLY = 0x200,
|
||||
PM_TRANS_FLAG_NOSCRIPTLET = 0x400,
|
||||
PM_TRANS_FLAG_NOCONFLICTS = 0x800,
|
||||
PM_TRANS_FLAG_PRINTURIS = 0x1000,
|
||||
/* 0x1000 flag can go here */
|
||||
PM_TRANS_FLAG_NEEDED = 0x2000,
|
||||
PM_TRANS_FLAG_ALLEXPLICIT = 0x4000,
|
||||
PM_TRANS_FLAG_UNNEEDED = 0x8000,
|
||||
|
@ -365,10 +365,6 @@ typedef enum _pmtransevt_t {
|
|||
* A line of text is passed to the callback.
|
||||
*/
|
||||
PM_TRANS_EVT_SCRIPTLET_INFO,
|
||||
/** Print URI.
|
||||
* The database's URI and the package's filename are passed to the callback.
|
||||
*/
|
||||
PM_TRANS_EVT_PRINTURI,
|
||||
/** Files will be downloaded from a repository.
|
||||
* The repository's tree name is passed to the callback.
|
||||
*/
|
||||
|
|
|
@ -497,8 +497,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync
|
|||
EVENT(trans, PM_TRANS_EVT_RESOLVEDEPS_DONE, NULL, NULL);
|
||||
}
|
||||
|
||||
/* We don't care about conflicts if we're just printing uris */
|
||||
if(!(trans->flags & (PM_TRANS_FLAG_NOCONFLICTS | PM_TRANS_FLAG_PRINTURIS))) {
|
||||
if(!(trans->flags & PM_TRANS_FLAG_NOCONFLICTS)) {
|
||||
/* check for inter-conflicts and whatnot */
|
||||
EVENT(trans, PM_TRANS_EVT_INTERCONFLICTS_START, NULL, NULL);
|
||||
|
||||
|
@ -838,32 +837,27 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
|
|||
|
||||
fname = alpm_pkg_get_filename(spkg);
|
||||
ASSERT(fname != NULL, RET_ERR(PM_ERR_PKG_INVALID_NAME, -1));
|
||||
if(trans->flags & PM_TRANS_FLAG_PRINTURIS) {
|
||||
EVENT(trans, PM_TRANS_EVT_PRINTURI, (char *)alpm_db_get_url(current),
|
||||
(char *)fname);
|
||||
} else {
|
||||
if(spkg->download_size != 0) {
|
||||
alpm_list_t *delta_path = spkg->delta_path;
|
||||
if(delta_path) {
|
||||
alpm_list_t *dlts = NULL;
|
||||
if(spkg->download_size != 0) {
|
||||
alpm_list_t *delta_path = spkg->delta_path;
|
||||
if(delta_path) {
|
||||
alpm_list_t *dlts = NULL;
|
||||
|
||||
for(dlts = delta_path; dlts; dlts = dlts->next) {
|
||||
pmdelta_t *d = dlts->data;
|
||||
for(dlts = delta_path; dlts; dlts = dlts->next) {
|
||||
pmdelta_t *d = dlts->data;
|
||||
|
||||
if(d->download_size != 0) {
|
||||
/* add the delta filename to the download list if
|
||||
* it's not in the cache */
|
||||
files = alpm_list_add(files, strdup(d->delta));
|
||||
}
|
||||
|
||||
/* keep a list of the delta files for md5sums */
|
||||
deltas = alpm_list_add(deltas, d);
|
||||
if(d->download_size != 0) {
|
||||
/* add the delta filename to the download list if
|
||||
* it's not in the cache */
|
||||
files = alpm_list_add(files, strdup(d->delta));
|
||||
}
|
||||
|
||||
} else {
|
||||
/* not using deltas, so add the file to the download list */
|
||||
files = alpm_list_add(files, strdup(fname));
|
||||
/* keep a list of the delta files for md5sums */
|
||||
deltas = alpm_list_add(deltas, d);
|
||||
}
|
||||
|
||||
} else {
|
||||
/* not using deltas, so add the file to the download list */
|
||||
files = alpm_list_add(files, strdup(fname));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -880,9 +874,6 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
|
|||
FREELIST(files);
|
||||
}
|
||||
}
|
||||
if(trans->flags & PM_TRANS_FLAG_PRINTURIS) {
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* clear out value to let callback know we are done */
|
||||
if(handle->totaldlcb) {
|
||||
|
|
|
@ -226,9 +226,6 @@ void cb_trans_evt(pmtransevt_t event, void *data1, void *data2)
|
|||
case PM_TRANS_EVT_SCRIPTLET_INFO:
|
||||
printf("%s", (char*)data1);
|
||||
break;
|
||||
case PM_TRANS_EVT_PRINTURI:
|
||||
printf("%s/%s\n", (char*)data1, (char*)data2);
|
||||
break;
|
||||
case PM_TRANS_EVT_RETRIEVE_START:
|
||||
printf(_(":: Retrieving packages from %s...\n"), (char*)data1);
|
||||
break;
|
||||
|
|
|
@ -57,6 +57,7 @@ typedef struct __config_t {
|
|||
unsigned short op_s_sync;
|
||||
unsigned short op_s_search;
|
||||
unsigned short op_s_upgrade;
|
||||
unsigned short op_s_printuris;
|
||||
|
||||
unsigned short group;
|
||||
pmtransflag_t flags;
|
||||
|
|
|
@ -462,7 +462,8 @@ static int parseargs(int argc, char *argv[])
|
|||
case 'o': config->op_q_owns = 1; break;
|
||||
case 'p':
|
||||
config->op_q_isfile = 1;
|
||||
config->flags |= PM_TRANS_FLAG_PRINTURIS;
|
||||
config->op_s_printuris = 1;
|
||||
config->flags |= PM_TRANS_FLAG_NOCONFLICTS;
|
||||
break;
|
||||
case 'q':
|
||||
config->quiet = 1;
|
||||
|
|
|
@ -666,23 +666,32 @@ static int sync_trans(alpm_list_t *targets)
|
|||
goto cleanup;
|
||||
}
|
||||
|
||||
if(!(alpm_trans_get_flags() & PM_TRANS_FLAG_PRINTURIS)) {
|
||||
int confirm;
|
||||
|
||||
display_synctargets(packages);
|
||||
printf("\n");
|
||||
|
||||
if(config->op_s_downloadonly) {
|
||||
confirm = yesno(_("Proceed with download?"));
|
||||
} else {
|
||||
confirm = yesno(_("Proceed with installation?"));
|
||||
/* Step 3: actually perform the operation */
|
||||
if(config->op_s_printuris) {
|
||||
/* print uris */
|
||||
alpm_list_t *i;
|
||||
for(i = packages; i; i = alpm_list_next(i)) {
|
||||
pmpkg_t *pkg = alpm_sync_get_pkg((pmsyncpkg_t *)alpm_list_getdata(i));
|
||||
pmdb_t *db = alpm_pkg_get_db(pkg);
|
||||
printf("%s/%s\n", alpm_db_get_url(db), alpm_pkg_get_filename(pkg));
|
||||
}
|
||||
if(!confirm) {
|
||||
goto cleanup;
|
||||
}
|
||||
}/* else 'print uris' requested. We're done at this point */
|
||||
/* we are done */
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
display_synctargets(packages);
|
||||
printf("\n");
|
||||
|
||||
int confirm;
|
||||
if(config->op_s_downloadonly) {
|
||||
confirm = yesno(_("Proceed with download?"));
|
||||
} else {
|
||||
confirm = yesno(_("Proceed with installation?"));
|
||||
}
|
||||
if(!confirm) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* Step 3: actually perform the installation */
|
||||
if(alpm_trans_commit(&data) == -1) {
|
||||
pm_fprintf(stderr, PM_LOG_ERROR, _("failed to commit transaction (%s)\n"),
|
||||
alpm_strerrorlast());
|
||||
|
@ -739,7 +748,7 @@ int pacman_sync(alpm_list_t *targets)
|
|||
alpm_list_t *sync_dbs = NULL;
|
||||
|
||||
/* Display only errors with -Sp and -Sw operations */
|
||||
if(config->flags & (PM_TRANS_FLAG_DOWNLOADONLY | PM_TRANS_FLAG_PRINTURIS)) {
|
||||
if((config->flags & PM_TRANS_FLAG_DOWNLOADONLY) || config->op_s_printuris) {
|
||||
config->logmask &= ~PM_LOG_WARNING;
|
||||
}
|
||||
|
||||
|
@ -811,7 +820,7 @@ int pacman_sync(alpm_list_t *targets)
|
|||
}
|
||||
|
||||
alpm_list_t *targs = alpm_list_strdup(targets);
|
||||
if(!(config->flags & (PM_TRANS_FLAG_DOWNLOADONLY | PM_TRANS_FLAG_PRINTURIS))) {
|
||||
if(!(config->flags & PM_TRANS_FLAG_DOWNLOADONLY) && !config->op_s_printuris) {
|
||||
/* check for newer versions of packages to be upgraded first */
|
||||
alpm_list_t *packages = syncfirst();
|
||||
if(packages) {
|
||||
|
|
Loading…
Reference in New Issue