Module Name: src
Committed By: snj
Date: Tue Dec 31 01:23:17 UTC 2024
Modified Files:
src [netbsd-10]: build.sh
Log Message:
Pull up following revision(s) (requested by martin in ticket #1031):
build.sh: 1.383, 1.384, 1.388
Add a new operation "show-revisionid" that extracts a marker usable
to recreate the source (depending on the revision control system
in use).
Fix typo in previous
build.sh: fix spelling and grammar in a help string
To generate a diff of this commit:
cvs rdiff -u -r1.365.2.3 -r1.365.2.4 src/build.sh
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/build.sh
diff -u src/build.sh:1.365.2.3 src/build.sh:1.365.2.4
--- src/build.sh:1.365.2.3 Sun Oct 13 15:12:59 2024
+++ src/build.sh Tue Dec 31 01:23:17 2024
@@ -1,5 +1,5 @@
#! /usr/bin/env sh
-# $NetBSD: build.sh,v 1.365.2.3 2024/10/13 15:12:59 martin Exp $
+# $NetBSD: build.sh,v 1.365.2.4 2024/12/31 01:23:17 snj Exp $
#
# Copyright (c) 2001-2022 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -1089,6 +1089,9 @@ help()
patterns or exact values in MACHINE or MACHINE_ARCH.
mkrepro-timestamp Show the latest source timestamp used for reproducable
builds and exit. Requires -P or -V MKREPRO=yes.
+ show-revisionid Show the revision ID of the current directory
+ (in SCM-dependent format) and exit.
+ Requires -P or -V MKREPRO=yes.
Options:
-a ARCH Set MACHINE_ARCH=ARCH. [Default: deduced from MACHINE]
@@ -1165,6 +1168,7 @@ parseoptions()
opts='a:B:C:c:D:Ehj:M:m:N:nO:oPR:rS:T:UuV:w:X:xZ:'
opt_a=false
opt_m=false
+ local did_show_info=false
if type getopts >/dev/null 2>&1; then
# Use POSIX getopts.
@@ -1411,7 +1415,13 @@ parseoptions()
mkrepro-timestamp)
setup_mkrepro quiet
echo ${MKREPRO_TIMESTAMP:-0}
- [ ${MKREPRO_TIMESTAMP:-0} -ne 0 ]; exit
+ did_show_info=true
+ ;;
+
+ show-revisionid)
+ setup_mkrepro quiet
+ echo ${NETBSD_REVISIONID}
+ did_show_info=true
;;
kernel=*|releasekernel=*|kernel.gdb=*)
@@ -1475,6 +1485,9 @@ parseoptions()
op="$( echo "$op" | tr -s '.-' '__')"
eval do_${op}=true
done
+
+ [ "$did_show_info" = true ] && [ ${MKREPRO_TIMESTAMP:-0} -ne 0 ] && exit
+
[ -n "${operations}" ] || usage "Missing OPERATION to perform"
# Set up MACHINE*. On a NetBSD host, these are allowed to be unset.
@@ -2010,7 +2023,7 @@ createmakewrapper()
eval cat <<EOF ${makewrapout}
#! ${HOST_SH}
# Set proper variables to allow easy "make" building of a NetBSD subtree.
-# Generated from: \$NetBSD: build.sh,v 1.365.2.3 2024/10/13 15:12:59 martin Exp $
+# Generated from: \$NetBSD: build.sh,v 1.365.2.4 2024/12/31 01:23:17 snj Exp $
# with these arguments: ${_args}
#
@@ -2345,7 +2358,7 @@ setup_mkrepro()
return
fi
if [ ${MKREPRO_TIMESTAMP-0} -ne 0 ]; then
- return;
+ return
fi
local dirs=${NETBSDSRCDIR-/usr/src}/
@@ -2354,8 +2367,10 @@ setup_mkrepro()
fi
MKREPRO_TIMESTAMP=0
+ NETBSD_REVISIONID=
local d
local t
+ local tag
local vcs
for d in ${dirs}; do
if [ -d "${d}CVS" ]; then
@@ -2363,6 +2378,7 @@ setup_mkrepro()
if [ ! -x "${cvslatest}" ]; then
buildtools
fi
+ local nbdate=$(print_tooldir_program date)
local cvslatestflags=
if ${do_expertmode}; then
@@ -2370,12 +2386,20 @@ setup_mkrepro()
fi
t=$("${cvslatest}" ${cvslatestflags} "${d}")
+ if [ -f "${d}CVS/Tag" ]; then
+ tag=$( sed 's/^T//' < "${d}CVS/Tag" )
+ else
+ tag=HEAD
+ fi
+ NETBSD_REVISIONID="${tag}-"$(${nbdate} -u -r ${t} '+%Y%m%d%H%M%S')
vcs=cvs
elif [ -d "${d}.git" -o -f "${d}.git" ]; then
t=$(cd "${d}" && git log -1 --format=%ct)
+ NETBSD_REVISIONID=$(cd "${d}" && git log -1 --format=%H)
vcs=git
elif [ -d "${d}.hg" ]; then
t=$(hg --repo "$d" log -r . --template '{date.unixtime}\n')
+ NETBSD_REVISIONID=$(hg --repo "$d" identify --template '{id}\n')
vcs=hg
elif [ -f "${d}.hg_archival.txt" ]; then
local stat=$(print_tooldir_program stat)
@@ -2384,6 +2408,7 @@ setup_mkrepro()
fi
t=$("${stat}" -t '%s' -f '%m' "${d}.hg_archival.txt")
+ NETBSD_REVISIONID=$(awk '/^node:/ { print $2 }' < "${d}.hg_archival.txt")
vcs=hg
else
bomb "Cannot determine VCS for '$d'"
@@ -2404,7 +2429,7 @@ setup_mkrepro()
statusmsg2 "MKREPRO_TIMESTAMP" \
"$(repro_date "${MKREPRO_TIMESTAMP}")"
fi
- export MKREPRO MKREPRO_TIMESTAMP
+ export MKREPRO MKREPRO_TIMESTAMP NETBSD_REVISIONID
}
main()