From swhetzel@gmail.com  Mon Jan 17 17:46:28 2005
Return-Path: <swhetzel@gmail.com>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 02DBB16A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 17 Jan 2005 17:46:28 +0000 (GMT)
Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.195])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 5876943D48
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 17 Jan 2005 17:46:27 +0000 (GMT)
	(envelope-from swhetzel@gmail.com)
Received: by wproxy.gmail.com with SMTP id 58so105315wri
        for <FreeBSD-gnats-submit@freebsd.org>; Mon, 17 Jan 2005 09:46:27 -0800 (PST)
Received: by 10.54.46.10 with SMTP id t10mr184184wrt;
        Mon, 17 Jan 2005 09:46:26 -0800 (PST)
Received: by 10.54.29.4 with HTTP; Mon, 17 Jan 2005 09:46:26 -0800 (PST)
Message-Id: <790a9fff05011709468bffc19@mail.gmail.com>
Date: Mon, 17 Jan 2005 11:46:26 -0600
From: Scot Hetzel <swhetzel@gmail.com>
Reply-To: Scot Hetzel <swhetzel@gmail.com>
To: FreeBSD-gnats-submit@freebsd.org
Subject: sys directory link points to wrong location

>Number:         76362
>Category:       bin
>Synopsis:       [patch] sys directory link points to wrong location
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jan 17 17:50:21 GMT 2005
>Closed-Date:    
>Last-Modified:  Sat May 15 21:40:07 UTC 2010
>Originator:     Scot W. Hetzel
>Release:        FreeBSD 5.3-STABLE i386
>Organization:
>Environment:
System: FreeBSD bsd5x.hetzel.org 5.3-STABLE FreeBSD 5.3-STABLE #5: Fri
Jan 14 07:29:32 CST 2005
root@bsd5x.hetzel.org:/usr/obj/usr/src/5x/sys/GENERIC i386


>Description:
I have my source tree setup so that I have 3 branches checked out under
/usr/src.  I then have /sys linked to /usr/src/5x/sys on the 5-STABLE
system as shown below:

#ls -l / /usr/src

/:
total 67
:
lrwxr-xr-x   1 root  wheel        14 Jan  9 13:53 sys -> usr/src/5x/sys
:

/usr/src:
total 97416
drwxrwxr-x   2 root  operator       512 Jan 15 15:35 .snap
drwxr-xr-x  23 root  wheel         1024 Jan 15 16:52 4x
drwxr-xr-x  22 root  wheel         1024 Jan 15 16:49 5x
drwxr-xr-x  22 root  wheel         1024 Jan 15 16:49 6x
lrwxrwxrwx   1 root  wheel            4 Dec  5 01:52 sys -> /sys

The problem is that when I perform a make installkernel in /usr/src/5x,
the /sys link is reset to /usr/src/sys.  I then have to remove this link
and change it back to /usr/src/5x/sys, otherwise when I try to build a
port that requires the kernel sources, it will fail.

>How-To-Repeat:
Set up your /usr/src as shown above, then do a make installkernel

>Fix:

Apply the following patch to -CURRENT, and then MFC to 5-STABLE and
4-STABLE after a few days.

Index: etc/Makefile
===================================================================
RCS file: /home/ncvs/src/etc/Makefile,v
retrieving revision 1.337
diff -u -r1.337 Makefile
--- etc/Makefile	21 Dec 2004 10:15:59 -0000	1.337
+++ etc/Makefile	15 Jan 2005 23:19:22 -0000
@@ -5,6 +5,12 @@
 SUBDIR=	sendmail
 .endif
 
+.if !defined(RELEASEDIR)
+SYSDIR=	${.CURDIR:S/^\///:S/etc//}sys
+.else
+SYSDIR=	usr/src/sys
+.endif
+
 BIN1=	amd.map apmd.conf auth.conf \
 	crontab csh.cshrc csh.login csh.logout devd.conf devfs.conf \
 	dhclient.conf disktab fbtab ftpusers gettytab group \
@@ -200,7 +206,7 @@
 .if !defined(NO_SENDMAIL)
 	mtree -deU ${MTREE_FOLLOWS_SYMLINKS} -f
${.CURDIR}/mtree/BSD.sendmail.dist -p ${DESTDIR}/
 .endif
-	cd ${DESTDIR}/; rm -f ${DESTDIR}/sys; ln -s usr/src/sys sys
+	cd ${DESTDIR}/; rm -f ${DESTDIR}/sys; ln -s ${SYSDIR} sys
 	cd ${DESTDIR}/usr/share/man/en.ISO8859-1; ln -sf ../man* .
 	cd ${DESTDIR}/usr/share/man; \
 	set - `grep "^[a-zA-Z]" ${.CURDIR}/man.alias`; \
>Release-Note:
>Audit-Trail:

From: Scot Hetzel <swhetzel@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: bin/76362: sys directory link points to wrong location
Date: Wed, 26 Jan 2005 10:02:58 -0600

 One optimization change:
 
 SYSDIR=	${.CURDIR:S/^\///:S/etc//}sys
 
 to
 
 SYSDIR=	${.CURDIR:S/^\///:S/etc/sys/}
 
 Scot

From: Jilles Tjoelker <jilles@stack.nl>
To: bug-followup@FreeBSD.org, swhetzel@gmail.com
Cc:  
Subject: Re: bin/76362: [patch] sys directory link points to wrong location
Date: Sat, 15 May 2010 23:34:59 +0200

 I would recommend to always make it such that /usr/src are the sources
 corresponding to what this machine is running. That means either a
 directory (if you use just one branch) or a symlink to the actual
 location. The /sys symlink can then be left unchanged, and this patch is
 not needed.
 
 -- 
 Jilles Tjoelker
>Unformatted:
