diff options
author | Dan McGee <dan@archlinux.org> | 2011-12-12 10:53:14 -0600 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-12-12 12:45:40 -0600 |
commit | 1a1f5540a4533ea41038128026c75fe023410a99 (patch) | |
tree | bd8b67fb16dac6efa29c6a4f593faf79cfe75fd4 /src | |
parent | 074cf4cb951b85b95e706df77b8bf01cbd84d35f (diff) |
pacman: process all sync targets before exiting on error
If someone specifies a bogus line such as
pacman -S baz adsf/boo base-devel
we are better off trying to process all targets and showing all relevant
errors before exiting. This is easier in -U and -R operations where we
aren't dealing with groups, but here we attempt to skip group selection
once we know a target has errored to avoid cluttering the output and
hiding the real problem.
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/pacman/sync.c | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/src/pacman/sync.c b/src/pacman/sync.c index 1003a421..9015b086 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -616,7 +616,7 @@ static int process_pkg(alpm_pkg_t *pkg) return 0; } -static int process_group(alpm_list_t *dbs, const char *group) +static int process_group(alpm_list_t *dbs, const char *group, int error) { int ret = 0; alpm_list_t *i; @@ -628,6 +628,12 @@ static int process_group(alpm_list_t *dbs, const char *group) return 1; } + if(error) { + /* we already know another target errored. there is no reason to prompt the + * user here; we already validated the group name so just move on since we + * won't actually be installing anything anyway. */ + goto cleanup; + } if(config->print == 0) { printf(_(":: There are %d members in group %s:\n"), count, @@ -666,12 +672,14 @@ static int process_group(alpm_list_t *dbs, const char *group) } } } + cleanup: alpm_list_free(pkgs); return ret; } -static int process_targname(alpm_list_t *dblist, const char *targname) +static int process_targname(alpm_list_t *dblist, const char *targname, + int error) { alpm_pkg_t *pkg = alpm_find_dbs_satisfier(config->handle, dblist, targname); @@ -685,20 +693,20 @@ static int process_targname(alpm_list_t *dblist, const char *targname) return process_pkg(pkg); } /* fallback on group */ - return process_group(dblist, targname); + return process_group(dblist, targname, error); } -static int process_target(const char *target) +static int process_target(const char *target, int error) { /* process targets */ char *targstring = strdup(target); char *targname = strchr(targstring, '/'); - char *dbname = NULL; int ret = 0; - alpm_list_t *dblist = NULL; + alpm_list_t *dblist; if(targname && targname != targstring) { - alpm_db_t *db = NULL; + alpm_db_t *db; + const char *dbname; *targname = '\0'; targname++; @@ -710,14 +718,15 @@ static int process_target(const char *target) ret = 1; goto cleanup; } - dblist = alpm_list_add(dblist, db); - ret = process_targname(dblist, targname); + dblist = alpm_list_add(NULL, db); + ret = process_targname(dblist, targname, error); alpm_list_free(dblist); } else { targname = targstring; dblist = alpm_option_get_syncdbs(config->handle); - ret = process_targname(dblist, targname); + ret = process_targname(dblist, targname, error); } + cleanup: free(targstring); if(ret && access(target, R_OK) == 0) { @@ -730,6 +739,7 @@ cleanup: static int sync_trans(alpm_list_t *targets) { + int retval = 0; alpm_list_t *i; /* Step 1: create a new transaction... */ @@ -740,12 +750,16 @@ static int sync_trans(alpm_list_t *targets) /* process targets */ for(i = targets; i; i = alpm_list_next(i)) { const char *targ = i->data; - if(process_target(targ) == 1) { - trans_release(); - return 1; + if(process_target(targ, retval) == 1) { + retval = 1; } } + if(retval) { + trans_release(); + return retval; + } + if(config->op_s_upgrade) { printf(_(":: Starting full system upgrade...\n")); alpm_logaction(config->handle, "starting full system upgrade\n"); |