Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Jan 2017 01:38:34 +0000 (UTC)
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r312249 - stable/11/sys/conf
Message-ID:  <201701160138.v0G1cYM5070301@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: emaste
Date: Mon Jan 16 01:38:34 2017
New Revision: 312249
URL: https://svnweb.freebsd.org/changeset/base/312249

Log:
  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.

Modified:
  stable/11/sys/conf/newvers.sh
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/conf/newvers.sh
==============================================================================
--- stable/11/sys/conf/newvers.sh	Mon Jan 16 00:43:57 2017	(r312248)
+++ stable/11/sys/conf/newvers.sh	Mon Jan 16 01:38:34 2017	(r312249)
@@ -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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201701160138.v0G1cYM5070301>