[pacman-dev] [PATCH] skip unknown repo names for pacman -Sl
Brings pacman -Sl behavior in line with other listing operations. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> --- src/pacman/sync.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pacman/sync.c b/src/pacman/sync.c index 2093029..f8af176 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -503,12 +503,15 @@ static int sync_list(alpm_list_t *syncs, alpm_list_t *targets) if(db == NULL) { pm_printf(ALPM_LOG_ERROR, _("repository \"%s\" was not found.\n"), repo); - alpm_list_free(ls); - return 1; } ls = alpm_list_add(ls, db); } + + if(!ls) { + /* all of our targets were invalid */ + return 1; + } } else { ls = syncs; } -- 1.8.3
On 03/06/13 13:45, Andrew Gregory wrote:
Brings pacman -Sl behavior in line with other listing operations.
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> --- src/pacman/sync.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/pacman/sync.c b/src/pacman/sync.c index 2093029..f8af176 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -503,12 +503,15 @@ static int sync_list(alpm_list_t *syncs, alpm_list_t *targets) if(db == NULL) { pm_printf(ALPM_LOG_ERROR, _("repository \"%s\" was not found.\n"), repo); - alpm_list_free(ls); - return 1; }
ls = alpm_list_add(ls, db); } + + if(!ls) { + /* all of our targets were invalid */ + return 1; + } } else { ls = syncs; }
This needs a bit more. "pacman -Ql afsljk glibc" returns 1. So with "pacman -Sl asjkladfjk core", pacman should print the error about the unknown repo and then the list of core packages and return 1. Allan
Brings pacman -Sl behavior in line with other listing operations. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> --- v2: * return 1 if any repo names are invalid * remove the explicit return when all names are invalid, the for loop will take care of that on its own src/pacman/sync.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pacman/sync.c b/src/pacman/sync.c index 2093029..fc1314b 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -485,6 +485,7 @@ static int sync_list(alpm_list_t *syncs, alpm_list_t *targets) { alpm_list_t *i, *j, *ls = NULL; alpm_db_t *db_local = alpm_get_localdb(config->handle); + int ret = 0; if(targets) { for(i = targets; i; i = alpm_list_next(i)) { @@ -503,8 +504,7 @@ static int sync_list(alpm_list_t *syncs, alpm_list_t *targets) if(db == NULL) { pm_printf(ALPM_LOG_ERROR, _("repository \"%s\" was not found.\n"), repo); - alpm_list_free(ls); - return 1; + ret = 1; } ls = alpm_list_add(ls, db); @@ -536,7 +536,7 @@ static int sync_list(alpm_list_t *syncs, alpm_list_t *targets) alpm_list_free(ls); } - return 0; + return ret; } static alpm_db_t *get_db(const char *dbname) -- 1.8.3.1
participants (2)
-
Allan McRae
-
Andrew Gregory