Re: git: 89f361f742ae - main - kern.post.mk allow NEWVERS_{ENV,ARGS}

From: Drew Gallatin <gallatin_at_fastmail.com>
Date: Wed, 13 Sep 2023 13:54:28 UTC
des seems to be addressing this in https://reviews.freebsd.org/D41845

On Wed, Sep 13, 2023, at 8:08 AM, Drew Gallatin wrote:
> Simon.
> 
> This changes the version strings of kernels built via the buildkernel target and adds a lot of redundancy.  Eg:
> 
> VERSTR changes from:
> 
> "FreeBSD 14.0-ALPHA1 #0 main-n264839-91d0876a20ce-dirty: Wed Sep 13 08:17:25 EDT 2023\n    gallatin@beast:/usr/src/sys/amd64/compile/GENERIC"
> 
> To:
> 
> "FreeBSD 14.0-ALPHA1 amd64 1400094 #0 main-n264839-91d0876a20ce-dirty: Wed Sep 13 08:21:13 EDT 2023\n    gallatin@beast:/usr/obj/usr/src/amd64.amd64/sys/GENERIC"
> 
> Note the extra "amd64 1400094"   This screws up some of our (Netflix) tooling, as its reflected via uname -a
> 
> It appears that when using the buildkernel target, VERSION is picked up from Makefile.inc1's VERSION, which I think is intended for CTFMERGE.    Was this intention?
> 
> Thanks,
> Drew
> 
> 
> 
> On Mon, Jul 17, 2023, at 2:04 PM, Simon J. Gerraty wrote:
>> The branch main has been updated by sjg:
>> 
>> URL: https://cgit.FreeBSD.org/src/commit/?id=89f361f742aeae11c8b2e28eae3d015882b6c0ee <https://cgit.freebsd.org/src/commit/?id=89f361f742aeae11c8b2e28eae3d015882b6c0ee>
>> 
>> commit 89f361f742aeae11c8b2e28eae3d015882b6c0ee
>> Author:     Simon J. Gerraty <sjg@FreeBSD.org>
>> AuthorDate: 2023-07-17 19:03:35 +0000
>> Commit:     Simon J. Gerraty <sjg@FreeBSD.org>
>> CommitDate: 2023-07-17 19:03:35 +0000
>> 
>>     kern.post.mk allow NEWVERS_{ENV,ARGS}
>>     
>>     Allow makefiles better control of newvers.sh env and args.
>>     Also allow variable overrides on command line.
>>     
>>     Reviewed by:    imp, stevek
>>     Sponsored by:   Juniper Networks, Inc.
>>     Differential Revision:  https://reviews.freebsd.org/D41012
>> ---
>> sys/conf/kern.post.mk |  5 +++--
>> sys/conf/newvers.sh   | 16 +++++++++++++---
>> 2 files changed, 16 insertions(+), 5 deletions(-)
>> 
>> diff --git a/sys/conf/kern.post.mk b/sys/conf/kern.post.mk
>> index c368d5f40df8..45df83e2d16b 100644
>> --- a/sys/conf/kern.post.mk
>> +++ b/sys/conf/kern.post.mk
>> @@ -444,11 +444,12 @@ config.o env.o hints.o vers.o vnode_if.o:
>> ${NORMAL_C}
>> ${NORMAL_CTFCONVERT}
>>  
>> +NEWVERS_ENV+= MAKE="${MAKE}"
>> .if ${MK_REPRODUCIBLE_BUILD} != "no"
>> -REPRO_FLAG="-R"
>> +NEWVERS_ARGS+= -R
>> .endif
>> vers.c: .NOMETA_CMP $S/conf/newvers.sh $S/sys/param.h ${SYSTEM_DEP:Nvers.*}
>> - MAKE="${MAKE}" sh $S/conf/newvers.sh ${REPRO_FLAG} ${KERN_IDENT}
>> + ${NEWVERS_ENV} sh $S/conf/newvers.sh ${NEWVERS_ARGS} ${KERN_IDENT}
>>  
>> vnode_if.c: $S/tools/vnode_if.awk $S/kern/vnode_if.src
>> ${AWK} -f $S/tools/vnode_if.awk $S/kern/vnode_if.src -c
>> diff --git a/sys/conf/newvers.sh b/sys/conf/newvers.sh
>> index 85346b1cdc29..e21b3f5ce2e2 100644
>> --- a/sys/conf/newvers.sh
>> +++ b/sys/conf/newvers.sh
>> @@ -58,13 +58,23 @@ BRANCH="CURRENT"
>> if [ -n "${BRANCH_OVERRIDE}" ]; then
>> BRANCH=${BRANCH_OVERRIDE}
>> fi
>> -RELEASE="${REVISION}-${BRANCH}"
>> -VERSION="${TYPE} ${RELEASE}"
>>  
>> if [ -z "${SYSDIR}" ]; then
>> -    SYSDIR=$(dirname $0)/..
>> + SYSDIR=$(dirname $0)/..
>> fi
>>  
>> +# allow random overrides
>> +while :
>> +do
>> + case "$1" in
>> + *=*) eval "$1"; shift;;
>> + *) break;;
>> + esac
>> +done
>> +
>> +RELEASE="${RELEASE:-${REVISION}-${BRANCH}}"
>> +VERSION="${VERSION:-${TYPE} ${RELEASE}}"
>> +
>> RELDATE=$(awk '/^#define[[:space:]]*__FreeBSD_version/ {print $3}' ${PARAMFILE:-${SYSDIR}/sys/param.h})
>>  
>> if [ -r "${SYSDIR}/../COPYRIGHT" ]; then
>> 
>