[-stable@ removed, as there's no need to cross-post this.  dhw]

On Fri, Jan 06, 2012 at 06:50:33PM +0100, Oliver Pinter wrote:
> Hi All!
> 
> When svn installed and the source stored in git, then now the version 
> detection failed. The attached patch fixed this situation.
> ...

Caveat: I don't use git.

Given that folks will use various combinations of VCSen to maintain
their source trees, rather than hacking/munging newvers.sh whenever
the behavior of a certain subset of VCSen changes, why not change
newvers.sh to source the site-specific code in question?

We (the FreeBSD project) could provide some sample files, but folks
who want to do something different would have an easy way to do
that without hacking newvers.sh.

E.g., the attached.  I would normally make the file being sourced a
symlink to a selected file.  Note: Yes, some of the examples are absurd.
The point is to illustrate the idea.

I've been using this code in head, stable/9, and stable/8 since late
November; I track eack of those daily (both on a build machine and on my
laptop).

Peace,
david
-- 
David H. Wolfskill                              da...@catwhisker.org
Depriving a girl or boy of an opportunity for education is evil.

See http://www.catwhisker.org/~david/publickey.gpg for my public key.
diff -Nru conf/get_version_from_jot.sh conf/get_version_from_jot.sh
--- conf/get_version_from_jot.sh	1969-12-31 16:00:00.000000000 -0800
+++ conf/get_version_from_jot.sh	2011-11-20 08:29:19.000000000 -0800
@@ -0,0 +1,4 @@
+# Sample get_version_from_vcs.sh as a silly example
+get_version_from_vcs() {
+	jot -r 1 $( date +%s )
+}
diff -Nru conf/get_version_from_null.sh conf/get_version_from_null.sh
--- conf/get_version_from_null.sh	1969-12-31 16:00:00.000000000 -0800
+++ conf/get_version_from_null.sh	2011-11-19 11:24:51.000000000 -0800
@@ -0,0 +1,4 @@
+# Sample get_version_from_vcs.sh as a silly example
+get_version_from_vcs() {
+	echo ""
+}
diff -Nru conf/get_version_from_svn.sh conf/get_version_from_svn.sh
--- conf/get_version_from_svn.sh	1969-12-31 16:00:00.000000000 -0800
+++ conf/get_version_from_svn.sh	2011-11-29 13:32:25.000000000 -0800
@@ -0,0 +1,17 @@
+# Sample get_version_from_vcs.sh for use with SVN
+get_version_from_vcs() {
+	for dir in /bin /usr/bin /usr/local/bin; do
+		if [ -x "${dir}/svnversion" ] ; then
+			svnversion=${dir}/svnversion
+			break
+		fi
+	done
+	if [ -n "$svnversion" ] ; then
+		svn=`cd ${SYSDIR} && $svnversion`
+		case "$svn" in
+		[0-9]*) svn="r${svn}" ;;
+		*)	unset svn ;;
+		esac
+	fi
+	echo "$svn"
+}
diff -Nru conf/get_version_from_vcs.sh conf/get_version_from_vcs.sh
--- conf/get_version_from_vcs.sh	1969-12-31 16:00:00.000000000 -0800
+++ conf/get_version_from_vcs.sh	2011-11-20 08:29:45.000000000 -0800
@@ -0,0 +1,5 @@
+# dhw's get_version_from_vcs.sh for use with SVN to get GRN for entire /usr/src
+# I know where I keep svnversion, so I don't need to look for it.
+get_version_from_vcs() {
+	/usr/local/bin/svnversion /usr/src/
+}
diff -Nru conf/newvers.sh conf/newvers.sh
--- conf/newvers.sh	2012-01-06 10:40:08.000000000 -0800
+++ conf/newvers.sh	2012-01-06 10:47:58.000000000 -0800
@@ -87,51 +87,25 @@
 v=`cat version` u=${USER:-root} d=`pwd` h=${HOSTNAME:-`hostname`} t=`date`
 i=`${MAKE:-make} -V KERN_IDENT`
 
-for dir in /bin /usr/bin /usr/local/bin; do
-	if [ -x "${dir}/svnversion" ] ; then
-		svnversion=${dir}/svnversion
-		break
-	fi
-	if [ -d "${SYSDIR}/../.git" -a -x "${dir}/git" ] ; then
-		git_cmd="${dir}/git --git-dir=${SYSDIR}/../.git"
-		break
-	fi
-done
-
-if [ -n "$svnversion" ] ; then
-	svn=`cd ${SYSDIR} && $svnversion`
-	case "$svn" in
-	[0-9]*)	svn=" r${svn}" ;;
-	*)	unset svn ;;
-	esac
+if [ -r ${SYSDIR}/conf/get_version_from_vcs.sh ] ; then
+	. ${SYSDIR}/conf/get_version_from_vcs.sh
+else
+	# Fallback function to get a "version ID" if we can't find
+	# a replacement function.
+	get_version_from_vcs() {
+		date +%s
+	}
 fi
+version_from_vcs=`get_version_from_vcs`
 
-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`
-	if [ -n "$svn" ] ; then
-		svn=" r${svn}"
-		git="=${git}"
-	else
-		svn=`$git_cmd log | fgrep 'git-svn-id:' | head -1 | \
-		     sed -n 's/^.*@\([0-9][0-9]*\).*$/\1/p'`
-		if [ -n $svn ] ; then
-			svn=" r${svn}"
-			git="+${git}"
-		else
-			git=" ${git}"
-		fi
-	fi
-	if $git_cmd --work-tree=${SYSDIR}/.. diff-index \
-	    --name-only HEAD | read dummy; then
-		git="${git}-dirty"
-	fi
+if [ -n "$version_from_vcs" ]; then
+	version_from_vcs=" $version_from_vcs"
 fi
 
 cat << EOF > vers.c
 $COPYRIGHT
-#define SCCSSTR "@(#)${VERSION} #${v}${svn}${git}: ${t}"
-#define VERSTR "${VERSION} #${v}${svn}${git}: ${t}\\n    ${u}@${h}:${d}\\n"
+#define SCCSSTR "@(#)${VERSION} #${v}${version_from_vcs}: ${t}"
+#define VERSTR "${VERSION} #${v}${version_from_vcs}: ${t}\\n    ${u}@${h}:${d}\\n"
 #define RELSTR "${RELEASE}"
 
 char sccs[sizeof(SCCSSTR) > 128 ? sizeof(SCCSSTR) : 128] = SCCSSTR;

Attachment: pgpGXZewWGG04.pgp
Description: PGP signature

Reply via email to