newvers.sh: Take the src/ dir as an argument instead of hard coding it.
authorSascha Wildner <saw@online.de>
Tue, 19 May 2009 14:04:12 +0000 (16:04 +0200)
committerSascha Wildner <saw@online.de>
Tue, 19 May 2009 19:18:43 +0000 (21:18 +0200)
This fixes the issue where the last number in our version was included
only if /usr/src was present at build time, which resulted in different
output of uname -r, sysctl kern.{osrelease,version}, etc. across
different systems (e.g. "2.3.1-DEVELOPMENT" vs. "2.3-DEVELOPMENT").

This commit also removes the passing of ${KERN_IDENT} and ${IDENT} to
newvers.sh (both of which are not used by it) and performs some
additional cleanup.

Brought-to-my-attention-by: Antonio Huete Jimenez <ahuete.devel@gmail.com>
Reviewed-by: dillon
sys/conf/kern.post.mk
sys/conf/newvers.sh

index e95b3ce..8a36fe3 100644 (file)
@@ -224,7 +224,7 @@ ioconf.o:
        ${NORMAL_C}
 
 vers.c: $S/conf/newvers.sh $S/sys/param.h ${SYSTEM_DEP}
-       sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT}
+       sh $S/conf/newvers.sh $S/..
 
 # XXX strictly, everything depends on Makefile because changes to ${PROF}
 # only appear there, but we don't handle that.
index f4de7e2..84d0a91 100644 (file)
 # $FreeBSD: src/sys/conf/newvers.sh,v 1.44.2.30 2003/04/04 07:02:46 murray Exp $
 # $DragonFly: src/sys/conf/newvers.sh,v 1.23 2008/07/14 04:01:44 dillon Exp $
 
+# The directory where the source resides
+#
+SRCDIR=$1
+if [ "${SRCDIR}" = "" ]; then
+    SRCDIR=$(dirname $0)/../..
+fi
+
 # Set the branch
 #
 BRANCH="RELEASE_2_2"
@@ -63,15 +70,13 @@ if [ "${REVISION}" != "${BRANCH}" ]; then
     REVISION=$(echo $REVISION | sed -e 's/_/./g')
 fi
 
-for chkdir in machine/../../.. .. ../.. ../../.. /usr/src; do
-    if [ -f ${chkdir}/sys/conf/subvers-${SHORTTAG} ]; then
-       SUBVER=$(tail -1 ${chkdir}/sys/conf/subvers-${SHORTTAG} | awk '{ print $1; }')
-       if [ "X${SUBVER}" != "X" ]; then
-           REVISION="${REVISION}.${SUBVER}"
-           break
-       fi
+if [ -f ${SRCDIR}/sys/conf/subvers-${SHORTTAG} ]; then
+    SUBVER=$(tail -1 ${SRCDIR}/sys/conf/subvers-${SHORTTAG} | awk '{ print $1; }')
+    if [ "X${SUBVER}" != "X" ]; then
+       REVISION="${REVISION}.${SUBVER}"
+       break
     fi
-done
+fi
 
 RELEASE="${REVISION}-${BRANCH}"
 VERSION="${TYPE} ${RELEASE}"
@@ -81,24 +86,19 @@ if [ "X${PARAMFILE}" != "X" ]; then
                ${PARAMFILE})
 else
        RELDATE=$(awk '/__DragonFly_version.*propagated to newvers/ {print $3}' \
-               $(dirname $0)/../sys/param.h)
+               ${SRCDIR}/sys/sys/param.h)
 fi
 
 
-b=share/examples/etc/bsd-style-copyright
 year=`date '+%Y'`
 # look for copyright template
-for bsd_copyright in ../$b ../../$b ../../../$b /usr/src/$b /usr/$b
-do
-       if [ -r "$bsd_copyright" ]; then
-               COPYRIGHT=`sed \
-                   -e "s/\[year\]/$year/" \
-                   -e 's/\[your name\]\.*/The DragonFly Project/' \
-                   -e '/\[id for your version control system, if any\]/d' \
-                   $bsd_copyright` 
-               break
-       fi
-done
+if [ -r ${SRCDIR}/share/examples/etc/bsd-style-copyright ]; then
+    COPYRIGHT=`sed \
+       -e "s/\[year\]/$year/" \
+       -e 's/\[your name\]\.*/The DragonFly Project/' \
+       -e '/\[id for your version control system, if any\]/d' \
+       ${SRCDIR}/share/examples/etc/bsd-style-copyright`
+fi
 
 # no copyright found, use a dummy
 if [ X"$COPYRIGHT" = X ]; then