git: 0cd9513a5ba5 - main - pkg: retire backwards compatibility bootstrap support

From: Ed Maste <emaste_at_FreeBSD.org>
Date: Tue, 14 Jan 2025 13:43:00 UTC
The branch main has been updated by emaste:

URL: https://cgit.FreeBSD.org/src/commit/?id=0cd9513a5ba5bcc5918d783f31279f91edbba2ee

commit 0cd9513a5ba5bcc5918d783f31279f91edbba2ee
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2024-10-07 17:10:58 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2025-01-14 13:42:36 +0000

    pkg: retire backwards compatibility bootstrap support
    
    pkg.pkg has been available for years and is the default in all supported
    releases.  Retire fallback support for pkg.txz.
    
    Reviewed by:    bapt
    Sponsored by:   The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D46990
---
 usr.sbin/pkg/pkg.c | 29 +++++++----------------------
 1 file changed, 7 insertions(+), 22 deletions(-)

diff --git a/usr.sbin/pkg/pkg.c b/usr.sbin/pkg/pkg.c
index 0b46d2831e9e..21ee1cd4bd30 100644
--- a/usr.sbin/pkg/pkg.c
+++ b/usr.sbin/pkg/pkg.c
@@ -91,11 +91,7 @@ struct fingerprint {
 	STAILQ_ENTRY(fingerprint) next;
 };
 
-static const char *bootstrap_names []  = {
-	"pkg.pkg",
-	"pkg.txz",
-	NULL
-};
+static const char *bootstrap_name = "pkg.pkg";
 
 STAILQ_HEAD(fingerprint_list, fingerprint);
 
@@ -851,7 +847,6 @@ bootstrap_pkg(bool force, const char *fetchOpts, struct repository *repo)
 	char tmpsig[MAXPATHLEN];
 	const char *packagesite;
 	char pkgstatic[MAXPATHLEN];
-	const char *bootstrap_name;
 
 	fd_sig = -1;
 	ret = -1;
@@ -865,18 +860,12 @@ bootstrap_pkg(bool force, const char *fetchOpts, struct repository *repo)
 	if (strncmp(URL_SCHEME_PREFIX, packagesite,
 	    strlen(URL_SCHEME_PREFIX)) == 0)
 		packagesite += strlen(URL_SCHEME_PREFIX);
-	for (int j = 0; bootstrap_names[j] != NULL; j++) {
-		bootstrap_name = bootstrap_names[j];
 
-		snprintf(url, MAXPATHLEN, "%s/Latest/%s", packagesite, bootstrap_name);
-		snprintf(tmppkg, MAXPATHLEN, "%s/%s.XXXXXX",
-		    getenv("TMPDIR") ? getenv("TMPDIR") : _PATH_TMP,
-		    bootstrap_name);
-		if ((fd_pkg = fetch_to_fd(repo, url, tmppkg, fetchOpts)) != -1)
-			break;
-		bootstrap_name = NULL;
-	}
-	if (bootstrap_name == NULL)
+	snprintf(url, MAXPATHLEN, "%s/Latest/%s", packagesite, bootstrap_name);
+	snprintf(tmppkg, MAXPATHLEN, "%s/%s.XXXXXX",
+	    getenv("TMPDIR") ? getenv("TMPDIR") : _PATH_TMP,
+	    bootstrap_name);
+	if ((fd_pkg = fetch_to_fd(repo, url, tmppkg, fetchOpts)) == -1)
 		goto fetchfail;
 
 	if (repo->signature_type == SIGNATURE_FINGERPRINT) {
@@ -918,11 +907,7 @@ bootstrap_pkg(bool force, const char *fetchOpts, struct repository *repo)
 	goto cleanup;
 
 fetchfail:
-	for (int j = 0; bootstrap_names[j] != NULL; j++) {
-		warnx("Attempted to fetch %s/Latest/%s", repo->url,
-		    bootstrap_names[j]);
-	}
-	warnx("Error: %s", fetchLastErrString);
+	warnx("Error fetching %s: %s", url, fetchLastErrString);
 	if (fetchLastErrCode == FETCH_RESOLV) {
 		fprintf(stderr, "Address resolution failed for %s.\n", packagesite);
 	} else {