Re: [RFC] fix git detection code in newvers.sh when svn installed

2012-01-06 Thread Sergey Kandaurov
On 6 January 2012 21:50, Oliver Pinter pin...@tresorium.hu wrote:
 Hi All!

 When svn installed and the source stored in git, then now the version
 detection failed. The attached patch fixed this situation.


FWIW, a different version proposed by Maciej Milewski on -current
some time ago. I don't have/use git, so I cannot test these changes.
It is good in the sense that it doesn't duplicate a search path.
The patch is below for reference:

--- sys/conf/newvers.sh 2011-11-19 00:56:50.795815738 +0100
+++ sys/conf/newvers-patched.sh 2011-11-19 00:58:21.187818982 +0100
@@ -88,14 +88,14 @@
 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
+   if [ -x ${dir}/svnversion ] ; then
+   svnversion=${dir}/svnversion
+   break
+   fi
 done

 if [ -n $svnversion ] ; then


-- 
wbr,
pluknet
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: [RFC] fix git detection code in newvers.sh when svn installed

2012-01-06 Thread David Wolfskill
[-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.0 -0800
+++ conf/get_version_from_jot.sh	2011-11-20 08:29:19.0 -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.0 -0800
+++ conf/get_version_from_null.sh	2011-11-19 11:24:51.0 -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.0 -0800
+++ conf/get_version_from_svn.sh	2011-11-29 13:32:25.0 -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.0 -0800
+++ conf/get_version_from_vcs.sh	2011-11-20 08:29:45.0 -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.0 -0800
+++ conf/newvers.sh	2012-01-06 10:47:58.0 -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;


pgpGXZewWGG04.pgp
Description: PGP signature


Re: [RFC] fix git detection code in newvers.sh when svn installed

2012-01-06 Thread Garrett Cooper
On Fri, Jan 6, 2012 at 11:02 AM, Oliver Pinter pin...@tresorium.hu wrote:
 On Friday 06 January 2012 19:35:31 Sergey Kandaurov wrote:
 On 6 January 2012 21:50, Oliver Pinter pin...@tresorium.hu wrote:
  Hi All!
 
  When svn installed and the source stored in git, then now the version
  detection failed. The attached patch fixed this situation.

 FWIW, a different version proposed by Maciej Milewski on -current
 some time ago. I don't have/use git, so I cannot test these changes.
 It is good in the sense that it doesn't duplicate a search path.
 The patch is below for reference:

 --- sys/conf/newvers.sh       2011-11-19 00:56:50.795815738 +0100
 +++ sys/conf/newvers-patched.sh       2011-11-19 00:58:21.187818982 +0100
 @@ -88,14 +88,14 @@
  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
 +     if [ -x ${dir}/svnversion ] ; then
 +             svnversion=${dir}/svnversion
 +             break
 +     fi
  done

  if [ -n $svnversion ] ; then

 The problem with this, when git founded first and the source not stored in
 git, then the svn version not correctly set, due the loop first found git,
 and than breaked out.

 The same situation as my patch fixed, but from svn viewpoint.

This detection method might be worth mentioning as well (look for
SVNVERSION: 
http://freenas.svn.sourceforge.net/viewvc/freenas/trunk/build/nano_env?revision=9392view=markup
).
Cheers,
-Garrett
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: [RFC] fix git detection code in newvers.sh when svn installed

2012-01-06 Thread Oliver Pinter
On Friday 06 January 2012 19:35:31 Sergey Kandaurov wrote:
 On 6 January 2012 21:50, Oliver Pinter pin...@tresorium.hu wrote:
  Hi All!
 
  When svn installed and the source stored in git, then now the version
  detection failed. The attached patch fixed this situation.

 FWIW, a different version proposed by Maciej Milewski on -current
 some time ago. I don't have/use git, so I cannot test these changes.
 It is good in the sense that it doesn't duplicate a search path.
 The patch is below for reference:

 --- sys/conf/newvers.sh   2011-11-19 00:56:50.795815738 +0100
 +++ sys/conf/newvers-patched.sh   2011-11-19 00:58:21.187818982 +0100
 @@ -88,14 +88,14 @@
  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
 + if [ -x ${dir}/svnversion ] ; then
 + svnversion=${dir}/svnversion
 + break
 + fi
  done

  if [ -n $svnversion ] ; then

The problem with this, when git founded first and the source not stored in 
git, then the svn version not correctly set, due the loop first found git, 
and than breaked out.

The same situation as my patch fixed, but from svn viewpoint.

-- 
Oliver Pinter
(Tresorium)
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org