FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

 
 
LinkBack Thread Tools
 
Old 12-12-2011, 03:55 PM
Dan McGee
 
Default 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>
---

Allan, I see what you mean, this isn't pretty.

I'm still OK with doing this if everyone else is, however. Feedback?

-Dan


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 1003a42..9015b08 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:
"), 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 = '';
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...
"));
alpm_logaction(config->handle, "starting full system upgrade
");
--
1.7.8
 

Thread Tools




All times are GMT. The time now is 12:27 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org