git: d45717e497d1 - stable/14 - release: don't keep old packages if the BRANCH changes

From: Baptiste Daroussin <bapt_at_FreeBSD.org>
Date: Thu, 27 Jun 2024 09:00:51 UTC
The branch stable/14 has been updated by bapt:

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

commit d45717e497d10d6f6584e10d39a13a4e5dcd214d
Author:     Siva Mahadevan <me@svmhdvn.name>
AuthorDate: 2024-06-05 18:11:38 +0000
Commit:     Baptiste Daroussin <bapt@FreeBSD.org>
CommitDate: 2024-06-27 08:58:52 +0000

    release: don't keep old packages if the BRANCH changes
    
    (cherry picked from commit 4231a5e5040403f4ae46a63bf6e1209d5eb7adb8)
---
 Makefile.inc1 | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/Makefile.inc1 b/Makefile.inc1
index 141a18d7b745..b2e7be43f2ee 100644
--- a/Makefile.inc1
+++ b/Makefile.inc1
@@ -550,17 +550,23 @@ MAJOR_REVISION=	${_REVISION:R}
 _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}
-EXTRA_REVISION=	.snap${_TIMENOW}
+BRANCH_EXT=	snap
+EXTRA_REVISION=	.${BRANCH_EXT}${_TIMENOW}
 .elif ${_BRANCH:MALPHA*}
-EXTRA_REVISION=	.a${_BRANCH:C/ALPHA([0-9]+).*/\1/}.${_TIMENOW}
+BRANCH_EXT=	a${_BRANCH:C/ALPHA([0-9]+).*/\1/}
+EXTRA_REVISION=	.${BRANCH_EXT}.${_TIMENOW}
 .elif ${_BRANCH:MBETA*}
-EXTRA_REVISION=	.b${_BRANCH:C/BETA([0-9]+).*/\1/}.${_TIMENOW}
+BRANCH_EXT=	b${_BRANCH:C/BETA([0-9]+).*/\1/}
+EXTRA_REVISION=	.${BRANCH_EXT}.${_TIMENOW}
 .elif ${_BRANCH:MRC*}
-EXTRA_REVISION=	.rc${_BRANCH:C/RC([0-9]+).*/\1/}.${_TIMENOW}
+BRANCH_EXT=	rc${_BRANCH:C/RC([0-9]+).*/\1/}
+EXTRA_REVISION=	.${BRANCH_EXT}.${_TIMENOW}
 .elif ${_BRANCH:M*-p*}
-EXTRA_REVISION=	p${_BRANCH:C/.*-p([0-9]+$)/\1/}
+BRANCH_EXT=	p${_BRANCH:C/.*-p([0-9]+$)/\1/}
+EXTRA_REVISION=	${BRANCH_EXT}
 .endif
 PKG_VERSION:=	${_PKG_REVISION}${EXTRA_REVISION:C/[[:space:]]//g}
 .endif
@@ -1995,9 +2001,11 @@ PKG_EXT=	pkg
 .if 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:]][^\.]*).*/\1/}
 .else
 PKG_VERSION_FROM=
 PKG_VERSION_FROM_DIR=
+BRANCH_EXT_FROM=
 .endif
 .endif
 .endif
@@ -2035,7 +2043,7 @@ real-update-packages: stage-packages .PHONY
 	    continue; \
 	  fi ; \
 	  newsum=$$(pkg query -F ${REPODIR}/${PKG_ABI}/${PKG_VERSION}/$${newpkgname} '%X') ; \
-	  if [ "$${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} ; \