pkgbase: fix incremental generation of packages

Replace the regex trying to catch the branch name of the existing
repository which was too naive with simpler glob matching.

As a result the only case when we only use the new packages are:
moving from alpha to beta
moving from beta to rc
moving from rc to release
changing the major version number for the main git branch

PR:		281393
Differential Revision:	D46874
This commit is contained in:
Baptiste Daroussin 2024-10-08 08:53:45 +02:00
parent d5e9faf1f3
commit 458dc7f303

View File

@ -571,28 +571,27 @@ VERSION= FreeBSD ${_REVISION}-${_BRANCH:C/-p[0-9]+$//} ${TARGET_ARCH} ${SRCRELDA
.endif
MAJOR_REVISION= ${_REVISION:R}
.if !defined(PKG_VERSION)
_PKG_REVISION= ${_REVISION}
_STRTIMENOW= %Y%m%d%H%M%S
_TIMENOW= ${_STRTIMENOW:gmtime}
BRANCH_EXT=
.if ${_BRANCH:MCURRENT*} || ${_BRANCH:MSTABLE*} || ${_BRANCH:MPRERELEASE*}
_PKG_REVISION= ${MAJOR_REVISION}
BRANCH_EXT= snap
EXTRA_REVISION= .${BRANCH_EXT}${_TIMENOW}
_PKG_REVISION:= ${MAJOR_REVISION}
BRANCH_EXT= ${MAJOR_REVISION}.snap
EXTRA_REVISION= .snap${_TIMENOW}
.elif ${_BRANCH:MALPHA*}
BRANCH_EXT= a${_BRANCH:C/ALPHA([0-9]+).*/\1/}
EXTRA_REVISION= .${BRANCH_EXT}.${_TIMENOW}
BRANCH_EXT= alpha
EXTRA_REVISION= .${_BRANCH:C/ALPHA([0-9]+).*/\1/}.${_TIMENOW}
.elif ${_BRANCH:MBETA*}
BRANCH_EXT= b${_BRANCH:C/BETA([0-9]+).*/\1/}
EXTRA_REVISION= .${BRANCH_EXT}.${_TIMENOW}
BRANCH_EXT= beta
EXTRA_REVISION= .${_BRANCH:C/BETA([0-9]+).*/\1/}.${_TIMENOW}
.elif ${_BRANCH:MRC*}
BRANCH_EXT= rc${_BRANCH:C/RC([0-9]+).*/\1/}
EXTRA_REVISION= .${BRANCH_EXT}.${_TIMENOW}
BRANCH_EXT= rc
EXTRA_REVISION= .rc${_BRANCH:C/RC([0-9]+).*/\1/}.${_TIMENOW}
.elif ${_BRANCH:M*-p*}
BRANCH_EXT= p${_BRANCH:C/.*-p([0-9]+$)/\1/}
EXTRA_REVISION= ${BRANCH_EXT}
EXTRA_REVISION= p${_BRANCH:C/.*-p([0-9]+$)/\1/}
.endif
.if !defined(PKG_VERSION)
PKG_VERSION:= ${_PKG_REVISION}${EXTRA_REVISION:C/[[:space:]]//g}
.endif
.endif # !defined(PKG_VERSION)
@ -2040,7 +2039,26 @@ PKG_EXT= pkg
.if exists(${PKG_ABI_FILE}) && exists(${REPODIR}/${PKG_ABI})
PKG_VERSION_FROM!=/usr/bin/readlink ${REPODIR}/${PKG_ABI}/latest
PKG_VERSION_FROM_DIR= ${REPODIR}/${PKG_ABI}/${PKG_VERSION_FROM}
BRANCH_EXT_FROM= ${PKG_VERSION_FROM:C/^[^[:alpha:]]+p?([[:alpha:]]*)[0-9]+$/\1/}
# Determine the name of the branch base on the version
# X.bY => beta
# X.aY => alpha
# X.rcY => rc
# X.snap => snap
# all others mean release
#
# This will be used when comparing to the branch that we are building
# to decide if we keep old packages or new packages when only their
# version differs
BRANCH_EXT_FROM=
.if ${PKG_VERSION_FROM:M*.snap*}
BRANCH_EXT_FROM= ${PKG_VERSION_FROM:C/.snap.*$//}.snap
.elif ${PKG_VERSION_FROM:M*.b*}
BRANCH_EXT_FROM= beta
.elif ${PKG_VERSION_FROM:M*.rc*}
BRANCH_EXT_FROM= rc
.elif ${PKG_VERSION_FROM:M*.a*}
BRANCH_EXT_FROM= alpha
.endif
.else
PKG_VERSION_FROM=
PKG_VERSION_FROM_DIR=
@ -2081,7 +2099,7 @@ real-update-packages: stage-packages .PHONY
continue; \
fi ; \
newsum=$$(pkg query -F ${REPODIR}/${PKG_ABI}/${PKG_VERSION}/$${newpkgname} '%X') ; \
if [ "${BRANCH_EXT_FROM}" == "${BRANCH_EXT:C/[0-9]+$//}" -a "$${oldsum}" == "$${newsum}" ]; then \
if [ "${BRANCH_EXT_FROM}" = "${BRANCH_EXT}" -a "$${oldsum}" = "$${newsum}" ]; then \
echo "==> Keeping old ${PKG_NAME_PREFIX}-$${pkgname}-${PKG_VERSION_FROM}.${PKG_EXT}" ; \
rm ${REPODIR}/${PKG_ABI}/${PKG_VERSION}/$${newpkgname} ; \
cp $${pkg} ${REPODIR}/${PKG_ABI}/${PKG_VERSION} ; \