>Number:         174422
>Category:       misc
>Synopsis:       usr/src/sys/conf/newvers.sh, SYSDIR set to wrong directory
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Dec 13 22:40:00 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     Kimmo Paasiala
>Release:        9-STABLE
>Organization:
>Environment:
FreeBSD whitezone.rdnzl.info 9.1-PRERELEASE FreeBSD 9.1-PRERELEASE #0 r244185M: 
Thu Dec 13 23:08:38 EET 2012     
[email protected]:/usr/obj/usr/src/sys/RDNZL  amd64
>Description:
The newvers.sh script in /usr/src/sys/conf sets a wrong value to the SYSDIR 
variable when used from /usr/src/include/Makefile as part of the rule to create 
osreldate.h.

The Makefile in /usr/src/include sources the newvers.sh instead of executing 
it, this causes the SYSDIR variable to be set to "/bin/.." instead of the 
intended "/usr/src/sys/conf/.." because "dirname $0" returns the dirname part 
of "/bin/sh" instead of dirname of "/usr/src/sys/conf/newvers.sh".

This breaks at least the .git directory detection in newvers.sh if there 
happens to be a .git -directory in the root directory of the system. In such 
case builworld stops with an error at the .git directory detection.








>How-To-Repeat:
Create a git repository in the root directory with "git init" and attempt a 
"make buildworld" in /usr/src.
>Fix:
The attached patch should fix the problem. The fix tries to keep the newvers.sh 
compatible with other possible uses of it where it's not sourced by 
/usr/src/include/Makefile but executed directly.

In a discussion on the freebsd-stable mailing list it was noted that 
misc/160646 should be commited before commiting this patch.

Patch attached with submission follows:

Index: include/Makefile
===================================================================
--- include/Makefile    (revision 244138)
+++ include/Makefile    (working copy)
@@ -100,6 +100,7 @@
        @${ECHO} creating osreldate.h from newvers.sh
        @MAKE=${MAKE}; \
        PARAMFILE=${.CURDIR}/../sys/sys/param.h; \
+       SYSDIR=${.CURDIR}/../sys; \
        . ${.CURDIR}/../sys/conf/newvers.sh; \
        echo "$$COPYRIGHT" > osreldate.h; \
        echo "#ifdef _KERNEL" >> osreldate.h; \
Index: sys/conf/newvers.sh
===================================================================
--- sys/conf/newvers.sh (revision 244138)
+++ sys/conf/newvers.sh (working copy)
@@ -38,7 +38,7 @@
 fi
 RELEASE="${REVISION}-${BRANCH}"
 VERSION="${TYPE} ${RELEASE}"
-SYSDIR=$(dirname $0)/..
+: ${SYSDIR:=$(dirname $0)/..}
 
 if [ "X${PARAMFILE}" != "X" ]; then
        RELDATE=$(awk '/__FreeBSD_version.*propagated to newvers/ {print $3}' \


>Release-Note:
>Audit-Trail:
>Unformatted:
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "[email protected]"

Reply via email to