mirror of
https://github.com/moparisthebest/pacman
synced 2024-11-10 11:35:00 -05:00
src/pacman/sync.c : cleanup of pacman_sync
By putting the search / group / info / list operations just after the -Sy op, we can simplify several checks : 1) the check for "missing targets". Since we took care of the above operations, we now have less cases to consider : * -Syu or -Su : we can proceed * -Sy : we can end now (this is actually a bugfix) * -S : this op requires targets, so exit with an error 2) the check to see if a transaction is needed. If we arrive at the end of the function, it is either because we have -Su or -S <targets> so we already know a transaction is needed there. Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
0966c33a72
commit
d030d12542
@ -796,15 +796,6 @@ int pacman_sync(alpm_list_t *targets)
|
|||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(targets == NULL && !(config->op_s_sync || config->op_s_upgrade
|
|
||||||
|| config->op_s_search || config->group
|
|
||||||
|| config->op_s_info || config->op_q_list)) {
|
|
||||||
/* don't proceed here unless we have an operation that doesn't require
|
|
||||||
* a target list */
|
|
||||||
pm_printf(PM_LOG_ERROR, _("no targets specified (use -h for help)\n"));
|
|
||||||
return(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(config->op_s_sync) {
|
if(config->op_s_sync) {
|
||||||
/* grab a fresh package list */
|
/* grab a fresh package list */
|
||||||
printf(_(":: Synchronizing package databases...\n"));
|
printf(_(":: Synchronizing package databases...\n"));
|
||||||
@ -812,35 +803,6 @@ int pacman_sync(alpm_list_t *targets)
|
|||||||
if(!sync_synctree(config->op_s_sync, sync_dbs)) {
|
if(!sync_synctree(config->op_s_sync, sync_dbs)) {
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
config->op_s_sync = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(needs_transaction()) {
|
|
||||||
alpm_list_t *targs = alpm_list_strdup(targets);
|
|
||||||
if(!(config->flags & (PM_TRANS_FLAG_DOWNLOADONLY | PM_TRANS_FLAG_PRINTURIS))) {
|
|
||||||
/* check for newer versions of packages to be upgraded first */
|
|
||||||
alpm_list_t *packages = syncfirst();
|
|
||||||
if(packages) {
|
|
||||||
printf(_(":: The following packages should be upgraded first :\n"));
|
|
||||||
list_display(" ", packages);
|
|
||||||
if(yesno(1, _(":: Do you want to cancel the current operation\n"
|
|
||||||
":: and upgrade these packages now?"))) {
|
|
||||||
FREELIST(targs);
|
|
||||||
targs = packages;
|
|
||||||
config->flags = 0;
|
|
||||||
config->op_s_upgrade = 0;
|
|
||||||
} else {
|
|
||||||
FREELIST(packages);
|
|
||||||
}
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int ret = sync_trans(targs);
|
|
||||||
FREELIST(targs);
|
|
||||||
if(ret == 1) {
|
|
||||||
return(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* search for a package */
|
/* search for a package */
|
||||||
@ -863,7 +825,43 @@ int pacman_sync(alpm_list_t *targets)
|
|||||||
return(sync_list(sync_dbs, targets));
|
return(sync_list(sync_dbs, targets));
|
||||||
}
|
}
|
||||||
|
|
||||||
return(0);
|
if(targets == NULL) {
|
||||||
|
if(config->op_s_upgrade) {
|
||||||
|
/* proceed */
|
||||||
|
} else if(config->op_s_sync) {
|
||||||
|
return(0);
|
||||||
|
} else {
|
||||||
|
/* don't proceed here unless we have an operation that doesn't require a
|
||||||
|
* target list */
|
||||||
|
pm_printf(PM_LOG_ERROR, _("no targets specified (use -h for help)\n"));
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
alpm_list_t *targs = alpm_list_strdup(targets);
|
||||||
|
if(!(config->flags & (PM_TRANS_FLAG_DOWNLOADONLY | PM_TRANS_FLAG_PRINTURIS))) {
|
||||||
|
/* check for newer versions of packages to be upgraded first */
|
||||||
|
alpm_list_t *packages = syncfirst();
|
||||||
|
if(packages) {
|
||||||
|
printf(_(":: The following packages should be upgraded first :\n"));
|
||||||
|
list_display(" ", packages);
|
||||||
|
if(yesno(1, _(":: Do you want to cancel the current operation\n"
|
||||||
|
":: and upgrade these packages now?"))) {
|
||||||
|
FREELIST(targs);
|
||||||
|
targs = packages;
|
||||||
|
config->flags = 0;
|
||||||
|
config->op_s_upgrade = 0;
|
||||||
|
} else {
|
||||||
|
FREELIST(packages);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int ret = sync_trans(targs);
|
||||||
|
FREELIST(targs);
|
||||||
|
|
||||||
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vim: set ts=2 sw=2 noet: */
|
/* vim: set ts=2 sw=2 noet: */
|
||||||
|
Loading…
Reference in New Issue
Block a user