Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 09 Aug 2013 02:01:53 +0900 (JST)
From:      Hiroki Sato <hrs@FreeBSD.org>
To:        gjb@FreeBSD.org
Cc:        svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org
Subject:   Re: svn commit: r254094 - head/sys/conf
Message-ID:  <20130809.020153.1826008782812656990.hrs@allbsd.org>
In-Reply-To: <201308081559.r78Fx1h6034578@svn.freebsd.org>
References:  <201308081559.r78Fx1h6034578@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
----Security_Multipart0(Fri_Aug__9_02_01_53_2013_857)--
Content-Type: Multipart/Mixed;
 boundary="--Next_Part(Fri_Aug__9_02_01_53_2013_478)--"
Content-Transfer-Encoding: 7bit

----Next_Part(Fri_Aug__9_02_01_53_2013_478)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Glen Barber <gjb@FreeBSD.org> wrote
  in <201308081559.r78Fx1h6034578@svn.freebsd.org>:

gj> Author: gjb
gj> Date: Thu Aug  8 15:59:00 2013
gj> New Revision: 254094
gj> URL: http://svnweb.freebsd.org/changeset/base/254094
gj>
gj> Log:
gj>   When newvers.sh is run, it is possible that the svnversion
gj>   (or svnliteversion) in the current lookup path is not what
gj>   was used to check out the tree.  If an incompatible version
gj>   is used, the svn revision number is not reported in uname(1).
gj>
gj>   Run ${svnversion} on newvers.sh itself when evaluating if the
gj>   svn(1) in use is compatible with the tree.  Fallback to an
gj>   empty ${svnversion} if necessary.
gj>
gj>   With this change, svnliteversion from base is only used
gj>   if no compatible svnversion is found, so with this change,
gj>   the version of svn(1) from the ports tree is evaluated first.
gj>
gj>   Requested by:	many
gj>   MFC after:	3 days
gj>   X-MFC-To:	stable/9, releng/9.2 only
gj>
gj> Modified:
gj>   head/sys/conf/newvers.sh
gj>
gj> Modified: head/sys/conf/newvers.sh
gj> ==============================================================================
gj> --- head/sys/conf/newvers.sh	Thu Aug  8 11:53:47 2013	(r254093)
gj> +++ head/sys/conf/newvers.sh	Thu Aug  8 15:59:00 2013	(r254094)
gj> @@ -88,19 +88,31 @@ v=`cat version` u=${USER:-root} d=`pwd`
gj>  i=`${MAKE:-make} -V KERN_IDENT`
gj>  compiler_v=$($(${MAKE:-make} -V CC) -v 2>&1 | grep 'version')
gj>
gj> -if [ -x /usr/bin/svnliteversion ] ; then
gj> -	svnversion=/usr/bin/svnliteversion
gj> -fi
gj> -
gj>  for dir in /usr/bin /usr/local/bin; do
gj>  	if [ ! -z "${svnversion}" ] ; then
gj>  		break
gj>  	fi
gj>  	if [ -x "${dir}/svnversion" ] && [ -z ${svnversion} ] ; then
gj> -		svnversion=${dir}/svnversion
gj> -		break
gj> +		# Run svnversion from ${dir} on this script; if return code
gj> +		# is not zero, the checkout might not be compatible with the
gj> +		# svnversion being used.
gj> +		${dir}/svnversion $(basename ${0}) >/dev/null 2>&1
gj> +		if [ $? -eq 0 ]; then
gj> +			svnversion=${dir}/svnversion
gj> +			break
gj> +		fi
gj>  	fi
gj>  done
gj> +
gj> +if [ -z "${svnversion}" ] && [ -x /usr/bin/svnliteversion ] ; then
gj> +	/usr/bin/svnversion $(basename ${0}) >/dev/null 2>&1
gj> +	if [ $? -eq 0 ]; then
gj> +		svnversion=/usr/bin/svnliteversion
gj> +	else
gj> +		svnversion=
gj> +	fi
gj> +fi
gj> +

 I think this logic is unnecessarily complex.  svnversion does not
 need to run twice, at least.

 How about the attached patch?

-- Hiroki

----Next_Part(Fri_Aug__9_02_01_53_2013_478)--
Content-Type: Text/X-Patch; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="newvers.sh.20130809-1.diff"

Index: sys/conf/newvers.sh
===================================================================
--- sys/conf/newvers.sh	(revision 254095)
+++ sys/conf/newvers.sh	(working copy)
@@ -88,31 +88,20 @@
 i=`${MAKE:-make} -V KERN_IDENT`
 compiler_v=$($(${MAKE:-make} -V CC) -v 2>&1 | grep 'version')

-for dir in /usr/bin /usr/local/bin; do
-	if [ ! -z "${svnversion}" ] ; then
-		break
+for bin in $svnversion /usr/bin/svnversion /usr/local/bin/svnversion \
+    /usr/bin/svnliteversion; do
+	if svn=$("$bin" ${SYSDIR} 2>/dev/null); then
+		case "$svn" in
+		[0-9]*)	svn=" r${svn}"; break ;;
+		esac
+	else
+		# If return code is not zero, the binary is not found or
+		# the checkout might not be compatible with the svnversion
+		# being used.
+		unset svn
 	fi
-	if [ -x "${dir}/svnversion" ] && [ -z ${svnversion} ] ; then
-		# Run svnversion from ${dir} on this script; if return code
-		# is not zero, the checkout might not be compatible with the
-		# svnversion being used.
-		${dir}/svnversion $(basename ${0}) >/dev/null 2>&1
-		if [ $? -eq 0 ]; then
-			svnversion=${dir}/svnversion
-			break
-		fi
-	fi
 done

-if [ -z "${svnversion}" ] && [ -x /usr/bin/svnliteversion ] ; then
-	/usr/bin/svnversion $(basename ${0}) >/dev/null 2>&1
-	if [ $? -eq 0 ]; then
-		svnversion=/usr/bin/svnliteversion
-	else
-		svnversion=
-	fi
-fi
-
 for dir in /usr/bin /usr/local/bin; do
 	if [ -x "${dir}/p4" ] && [ -z ${p4_cmd} ] ; then
 		p4_cmd=${dir}/p4
@@ -127,14 +116,6 @@
 	done
 fi

-if [ -n "$svnversion" ] ; then
-	svn=`cd ${SYSDIR} && $svnversion 2>/dev/null`
-	case "$svn" in
-	[0-9]*)	svn=" r${svn}" ;;
-	*)	unset svn ;;
-	esac
-fi
-
 if [ -n "$git_cmd" ] ; then
 	git=`$git_cmd rev-parse --verify --short HEAD 2>/dev/null`
 	svn=`$git_cmd svn find-rev $git 2>/dev/null`

----Next_Part(Fri_Aug__9_02_01_53_2013_478)----

----Security_Multipart0(Fri_Aug__9_02_01_53_2013_857)--
Content-Type: application/pgp-signature
Content-Transfer-Encoding: 7bit

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.13 (FreeBSD)

iEYEABECAAYFAlIDzwEACgkQTyzT2CeTzy3TGgCeNtK40TfZpNmtiwWdNvRFMPlQ
FtAAoNl1zJ02QfvyjiCCRjD0ecpq1jyf
=oYBo
-----END PGP SIGNATURE-----

----Security_Multipart0(Fri_Aug__9_02_01_53_2013_857)----



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