Date: Wed, 5 May 2021 08:25:31 GMT From: Baptiste Daroussin <bapt@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: eabdd103a155 - stable/12 - pkg(7): when bootstrapping first search for pkg.pkg file then pkg. Message-ID: <202105050825.1458PVML028854@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/12 has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=eabdd103a155f8c643ab7504cd509fc607b9fd64 commit eabdd103a155f8c643ab7504cd509fc607b9fd64 Author: Baptiste Daroussin <bapt@FreeBSD.org> AuthorDate: 2021-03-12 17:36:30 +0000 Commit: Baptiste Daroussin <bapt@FreeBSD.org> CommitDate: 2021-05-05 08:19:58 +0000 pkg(7): when bootstrapping first search for pkg.pkg file then pkg. The package extension is going to be changed to .pkg to be among other things resilient to the change of compression format used and reduce the impact of all third party tool of that change. Ensure the bootstrap knows about it Reviewed by: manu Differential revision: https://reviews.freebsd.org/D29232 (cherry picked from commit a2aac2f5e5642740507a3cadb98046f3dd434ce4) (cherry picked from commit c244b1d8a38731041d0f3ff4191192a85dd8608b) --- usr.sbin/pkg/pkg.c | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/usr.sbin/pkg/pkg.c b/usr.sbin/pkg/pkg.c index 59348f7fc478..c499fb28c42d 100644 --- a/usr.sbin/pkg/pkg.c +++ b/usr.sbin/pkg/pkg.c @@ -84,6 +84,12 @@ struct fingerprint { STAILQ_ENTRY(fingerprint) next; }; +static const char *bootstrap_names [] = { + "pkg.pkg", + "pkg.txz", + NULL +}; + STAILQ_HEAD(fingerprint_list, fingerprint); static int @@ -836,6 +842,7 @@ bootstrap_pkg(bool force, const char *fetchOpts) const char *packagesite; const char *signature_type; char pkgstatic[MAXPATHLEN]; + const char *bootstrap_name; fd_sig = -1; ret = -1; @@ -858,22 +865,29 @@ bootstrap_pkg(bool force, const char *fetchOpts) if (strncmp(URL_SCHEME_PREFIX, packagesite, strlen(URL_SCHEME_PREFIX)) == 0) packagesite += strlen(URL_SCHEME_PREFIX); - snprintf(url, MAXPATHLEN, "%s/Latest/pkg.txz", packagesite); - - snprintf(tmppkg, MAXPATHLEN, "%s/pkg.txz.XXXXXX", - getenv("TMPDIR") ? getenv("TMPDIR") : _PATH_TMP); - - if ((fd_pkg = fetch_to_fd(url, tmppkg, fetchOpts)) == -1) + 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(url, tmppkg, fetchOpts)) != -1) + break; + bootstrap_name = NULL; + } + if (bootstrap_name == NULL) goto fetchfail; if (signature_type != NULL && strcasecmp(signature_type, "NONE") != 0) { if (strcasecmp(signature_type, "FINGERPRINTS") == 0) { - snprintf(tmpsig, MAXPATHLEN, "%s/pkg.txz.sig.XXXXXX", - getenv("TMPDIR") ? getenv("TMPDIR") : _PATH_TMP); - snprintf(url, MAXPATHLEN, "%s/Latest/pkg.txz.sig", - packagesite); + snprintf(tmpsig, MAXPATHLEN, "%s/%s.sig.XXXXXX", + getenv("TMPDIR") ? getenv("TMPDIR") : _PATH_TMP, + bootstrap_name); + snprintf(url, MAXPATHLEN, "%s/Latest/%s.sig", + packagesite, bootstrap_name); if ((fd_sig = fetch_to_fd(url, tmpsig, fetchOpts)) == -1) { fprintf(stderr, "Signature for pkg not " @@ -886,10 +900,11 @@ bootstrap_pkg(bool force, const char *fetchOpts) } else if (strcasecmp(signature_type, "PUBKEY") == 0) { snprintf(tmpsig, MAXPATHLEN, - "%s/pkg.txz.pubkeysig.XXXXXX", - getenv("TMPDIR") ? getenv("TMPDIR") : _PATH_TMP); - snprintf(url, MAXPATHLEN, "%s/Latest/pkg.txz.pubkeysig", - packagesite); + "%s/%s.pubkeysig.XXXXXX", + getenv("TMPDIR") ? getenv("TMPDIR") : _PATH_TMP, + bootstrap_name); + snprintf(url, MAXPATHLEN, "%s/Latest/%s.pubkeysig", + packagesite, bootstrap_name); if ((fd_sig = fetch_to_fd(url, tmpsig, fetchOpts)) == -1) { fprintf(stderr, "Signature for pkg not "
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202105050825.1458PVML028854>