pkgbase: don't remove the 'latest' symlink until the repo is final

We can encounter many issues in the pkg-repo(8) process which would
currently leave us with no more 'latest' symlink in the repository.  The
main problems with this are that we've now broken a subsequent
`update-packages` because we can't determine a PKG_VERSION_FROM, but
also we break configured clients that are still expecting to see *some*
repository.

Switch to just replacing the `latest` symlink entirely after we have
made it past the pkg-repo(8) step so that we only swap over when we have
a finished repository.

Reviewed by:	bapt, emaste
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D47303

(cherry picked from commit 8549e3ce0cd6d4a6187b3977d53ff56ce0ac9c5b)
This commit is contained in:
Kyle Evans 2024-10-29 15:50:49 -05:00
parent 6bf02434bd
commit 1e8db1f74e

View file

@ -2280,14 +2280,13 @@ real-sign-packages: _pkgbootstrap .PHONY
.if ${PKG_BIN_VERSION} < 11700
printf "packing_format = \"${PKG_FORMAT}\";\n" >> ${WSTAGEDIR}/meta
.endif
@[ -L "${REPODIR}/${PKG_ABI}/latest" ] && unlink ${REPODIR}/${PKG_ABI}/latest; \
${PKG_CMD} -o ABI=${PKG_ABI} repo -o OSVERSION="${SRCRELDATE}" \
@${PKG_CMD} -o ABI=${PKG_ABI} repo -o OSVERSION="${SRCRELDATE}" \
-m ${WSTAGEDIR}/meta \
-o ${REPODIR}/${PKG_ABI}/${PKG_VERSION} \
${REPODIR}/${PKG_ABI}/${PKG_VERSION} \
${PKG_REPO_SIGNING_KEY} ; \
cd ${REPODIR}/${PKG_ABI}; \
ln -s ${PKG_OUTPUT_DIR} latest
ln -hfs ${PKG_OUTPUT_DIR} latest
#
#