From a10f71c53af37a5c213bd56cedbee89f2d31d19a Mon Sep 17 00:00:00 2001 From: Tom Jones Date: Tue, 23 Jun 2020 15:14:54 +0000 Subject: [PATCH] pkg: Provide a friendlier message when bootstrap fails due to address resolution The current message when bootstapping pkg fails for any reason implies that pkg is not available. We have the error code from fetch so if bootstrap failed due to address resolution say so. Reviewed by: bapt, bz Approved by: bz (co-mentor) MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D25323 --- usr.sbin/pkg/pkg.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/usr.sbin/pkg/pkg.c b/usr.sbin/pkg/pkg.c index d22598dc36a..7e2359aa97b 100644 --- a/usr.sbin/pkg/pkg.c +++ b/usr.sbin/pkg/pkg.c @@ -915,10 +915,15 @@ bootstrap_pkg(bool force) fetchfail: warnx("Error fetching %s: %s", url, fetchLastErrString); - fprintf(stderr, "A pre-built version of pkg could not be found for " - "your system.\n"); - fprintf(stderr, "Consider changing PACKAGESITE or installing it from " - "ports: 'ports-mgmt/pkg'.\n"); + if (fetchLastErrCode == FETCH_RESOLV) { + fprintf(stderr, "Address resolution failed for %s.\n", packagesite); + fprintf(stderr, "Consider changing PACKAGESITE.\n"); + } else { + fprintf(stderr, "A pre-built version of pkg could not be found for " + "your system.\n"); + fprintf(stderr, "Consider changing PACKAGESITE or installing it from " + "ports: 'ports-mgmt/pkg'.\n"); + } cleanup: if (fd_sig != -1) {