pkgbase: allow update-packages for first-run of packaging

If ${REPODIR}/${PKG_ABI} does not exist when we begin real-update-packages,
skip the comparison with the non-existent previous repository and just
finish the repo off. This allows external scripts to just assume they can
run `update-packages` rather than figuring out if they'd previously run
`packages` for this Version/Arch combo.

PKG_VERSION_FROM_DIR was added so that we could perhaps detect the three
distinct cases:

1.) If the repo has not yet been created, PKG_VERSION_FROM_DIR will be
  empty.
2.) If the repo is in some intermediate state between created and fully
  initialized, PKG_VERSION_FROM_DIR may point to the ABI directory.
3.) If the repo is fully initialized, then PKG_VERSION_FROM_DIR points to
  the latest build to compare to.

Option #2 is explicitly unhandled at the moment, but this is no different
than it was before.

Reviewed-by:	manu
Differential-Revision:	https://reviews.freebsd.org/D28229
This commit is contained in:
Kyle Evans 2021-01-18 14:11:58 -06:00
parent 85ad7f8da1
commit 26490d9b74

View File

@ -1876,7 +1876,13 @@ PKG_ABI!=${PKG_CMD} -o ABI_FILE=${WSTAGEDIR}/usr/bin/uname config ABI
.if !defined(PKG_VERSION_FROM) && make(real-update-packages) .if !defined(PKG_VERSION_FROM) && make(real-update-packages)
.if defined(PKG_ABI) .if defined(PKG_ABI)
.if exists(${REPODIR}/${PKG_ABI})
PKG_VERSION_FROM!=/usr/bin/readlink ${REPODIR}/${PKG_ABI}/latest PKG_VERSION_FROM!=/usr/bin/readlink ${REPODIR}/${PKG_ABI}/latest
PKG_VERSION_FROM_DIR= ${REPODIR}/${PKG_ABI}/${PKG_VERSION_FROM}
.else
PKG_VERSION_FROM=
PKG_VERSION_FROM_DIR=
.endif
.endif .endif
.endif .endif
@ -1900,8 +1906,11 @@ real-packages: stage-packages create-packages sign-packages .PHONY
real-update-packages: stage-packages .PHONY real-update-packages: stage-packages .PHONY
${_+_}${MAKE} -C ${.CURDIR} PKG_VERSION=${PKG_VERSION} create-packages ${_+_}${MAKE} -C ${.CURDIR} PKG_VERSION=${PKG_VERSION} create-packages
.if empty(PKG_VERSION_FROM_DIR)
@echo "==> Bootstrapping repository, not checking for new packages"
.else
@echo "==> Checking for new packages (comparing ${PKG_VERSION} to ${PKG_VERSION_FROM})" @echo "==> Checking for new packages (comparing ${PKG_VERSION} to ${PKG_VERSION_FROM})"
@for pkg in ${REPODIR}/${PKG_ABI}/${PKG_VERSION_FROM}/${PKG_NAME_PREFIX}-*; do \ @for pkg in ${PKG_VERSION_FROM_DIR}/${PKG_NAME_PREFIX}-*; do \
pkgname=$$(pkg query -F $${pkg} '%n' | sed 's/${PKG_NAME_PREFIX}-\(.*\)/\1/') ; \ pkgname=$$(pkg query -F $${pkg} '%n' | sed 's/${PKG_NAME_PREFIX}-\(.*\)/\1/') ; \
newpkgname=${PKG_NAME_PREFIX}-$${pkgname}-${PKG_VERSION}.${PKG_FORMAT} ; \ newpkgname=${PKG_NAME_PREFIX}-$${pkgname}-${PKG_VERSION}.${PKG_FORMAT} ; \
oldsum=$$(pkg query -F $${pkg} '%X') ; \ oldsum=$$(pkg query -F $${pkg} '%X') ; \
@ -1917,6 +1926,7 @@ real-update-packages: stage-packages .PHONY
echo "==> New package $${newpkgname}" ; \ echo "==> New package $${newpkgname}" ; \
fi ; \ fi ; \
done done
.endif
${_+_}@cd ${.CURDIR}; \ ${_+_}@cd ${.CURDIR}; \
${MAKE} -f Makefile.inc1 PKG_VERSION=${PKG_VERSION} sign-packages ${MAKE} -f Makefile.inc1 PKG_VERSION=${PKG_VERSION} sign-packages