summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoremaste <emaste@FreeBSD.org>2017-01-16 01:38:34 +0000
committeremaste <emaste@FreeBSD.org>2017-01-16 01:38:34 +0000
commita93bb23350d7c5e28a97ddc87d44464c5f82a7e7 (patch)
tree233b2fa7712c01ec660b53ed4e77d665baff05c6
parent87053058c930d6c4b7ba3d50296b56ec1083a9c2 (diff)
downloadFreeBSD-src-a93bb23350d7c5e28a97ddc87d44464c5f82a7e7.zip
FreeBSD-src-a93bb23350d7c5e28a97ddc87d44464c5f82a7e7.tar.gz
newvers.sh: add options to eliminate kernel build metadata
MFC r310112, r310114, r310273, r310279 r310112: newvers.sh: add option to eliminate kernel build metadata Build metadata (username, hostname, etc.) prevents the FreeBSD kernel from building reproducibly. Add an option to disable inclusion of that metadata but retain the release information and SVN/git VCS details. See https://reproducible-builds.org/ for additional background. r310114: newvers.sh: correct typo in comment r310273: newvers.sh: add -R option to include metadata only for unmodified src tree r310279: newvers.sh: consider as modified SVN mixed revision and other cases The newvers -R option is intended to include build metadata (e.g. user, host, time) if the build is from an unmodified VCS tree. For subversion it considered a trailing 'M' as an indication of a modified tree, and any other version string as modified. Also include mixed revision checkouts (e.g. 123:126), switched (123S) and partial (123P) working copies as modified: the revision number is insufficient to uniquely determine which source was used for the build.
-rw-r--r--sys/conf/newvers.sh56
1 files changed, 51 insertions, 5 deletions
diff --git a/sys/conf/newvers.sh b/sys/conf/newvers.sh
index 0d5f795..fa05d7d 100644
--- a/sys/conf/newvers.sh
+++ b/sys/conf/newvers.sh
@@ -30,6 +30,18 @@
# @(#)newvers.sh 8.1 (Berkeley) 4/20/94
# $FreeBSD$
+# Command line options:
+#
+# -r Reproducible build. Do not embed directory names, user
+# names, time stamps or other dynamic information into
+# the output file. This is intended to allow two builds
+# done at different times and even by different people on
+# different hosts to produce identical output.
+#
+# -R Reproducible build if the tree represents an unmodified
+# checkout from a version control system. Metadata is
+# included if the tree is modified.
+
TYPE="FreeBSD"
REVISION="11.0"
BRANCH="STABLE"
@@ -163,8 +175,16 @@ fi
if [ -n "$svnversion" ] ; then
svn=`cd ${SYSDIR} && $svnversion 2>/dev/null`
case "$svn" in
- [0-9]*) svn=" r${svn}" ;;
- *) unset svn ;;
+ [0-9]*[MSP]|*:*)
+ svn=" r${svn}"
+ modified=true
+ ;;
+ [0-9]*)
+ svn=" r${svn}"
+ ;;
+ *)
+ unset svn
+ ;;
esac
fi
@@ -196,6 +216,7 @@ if [ -n "$git_cmd" ] ; then
if $git_cmd --work-tree=${SYSDIR}/.. diff-index \
--name-only HEAD | read dummy; then
git="${git}-dirty"
+ modified=true
fi
fi
@@ -208,7 +229,10 @@ if [ -n "$p4_cmd" ] ; then
p4opened=`cd ${SYSDIR} && $p4_cmd opened ./... 2>&1`
case "$p4opened" in
File*) ;;
- //*) p4version="${p4version}+edit" ;;
+ //*)
+ p4version="${p4version}+edit"
+ modified=true
+ ;;
esac
;;
*) unset p4version ;;
@@ -227,10 +251,32 @@ if [ -n "$hg_cmd" ] ; then
fi
fi
+include_metadata=true
+while getopts rR opt; do
+ case "$opt" in
+ r)
+ include_metadata=
+ ;;
+ R)
+ if [ -z "${modified}" ]; then
+ include_metadata=
+ fi
+ esac
+done
+shift $((OPTIND - 1))
+
+if [ -z "${include_metadata}" ]; then
+ VERINFO="${VERSION} ${svn}${git}${hg}${p4version}"
+ VERSTR="${VERINFO}\\n"
+else
+ VERINFO="${VERSION} #${v}${svn}${git}${hg}${p4version}: ${t}"
+ VERSTR="${VERINFO}\\n ${u}@${h}:${d}\\n"
+fi
+
cat << EOF > vers.c
$COPYRIGHT
-#define SCCSSTR "@(#)${VERSION} #${v}${svn}${git}${hg}${p4version}: ${t}"
-#define VERSTR "${VERSION} #${v}${svn}${git}${hg}${p4version}: ${t}\\n ${u}@${h}:${d}\\n"
+#define SCCSSTR "@(#)${VERINFO}"
+#define VERSTR "${VERSTR}"
#define RELSTR "${RELEASE}"
char sccs[sizeof(SCCSSTR) > 128 ? sizeof(SCCSSTR) : 128] = SCCSSTR;
OpenPOWER on IntegriCloud