From aa579b843899ccba093f83faa942599ce1110c24 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Sat, 6 Jun 2009 11:03:29 -0500 Subject: Give sensible feedback when a repo has no configured servers This fixes FS#14899. When running an -Sp operation without servers configured for a repository, we would segfault, so add an assert to the backend method returning the first server preventing a null pointer dereference. In addition, add a new error code to libalpm that indicates we have no servers configured for a repository. This makes -Sy and -S operations fail gracefully and helpfully when a repo is set up with no servers, as the default mirrorlist in Arch is provided this way. Signed-off-by: Dan McGee --- src/pacman/sync.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/pacman/sync.c') diff --git a/src/pacman/sync.c b/src/pacman/sync.c index 68fb81a9..2e57b011 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -675,7 +675,15 @@ static int sync_trans(alpm_list_t *targets) for(i = packages; i; i = alpm_list_next(i)) { pmpkg_t *pkg = 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)); + const char *dburl = alpm_db_get_url(db); + if(dburl) { + printf("%s/%s\n", dburl, alpm_pkg_get_filename(pkg)); + } else { + /* can't use WARNING here, we don't show warnings in -Sp... */ + pm_fprintf(stderr, PM_LOG_ERROR, _("no database for package: %s\n"), + alpm_pkg_get_name(pkg)); + } + } /* we are done */ goto cleanup; -- cgit v1.2.3