Bug 76362 - [patch] sys directory link points to wrong location
Summary: [patch] sys directory link points to wrong location
Status: Closed Not Accepted
Alias: None
Product: Base System
Classification: Unclassified
Component: misc (show other bugs)
Version: 5.3-STABLE
Hardware: Any Any
: Normal Affects Some People
Assignee: Enji Cooper
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-01-17 17:50 UTC by Scot Hetzel
Modified: 2015-12-01 06:26 UTC (History)
2 users (show)

See Also:
ngie: mfc-stable9?
ngie: mfc-stable10?


Attachments
file.diff (991 bytes, patch)
2005-01-17 17:50 UTC, Scot Hetzel
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Scot Hetzel 2005-01-17 17:50:21 UTC
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.

Fix: Apply the following patch to -CURRENT, and then MFC to 5-STABLE and
4-STABLE after a few days.
How-To-Repeat: Set up your /usr/src as shown above, then do a make installkernel
Comment 1 Scot Hetzel 2005-01-26 16:02:58 UTC
One optimization change:

SYSDIR=	${.CURDIR:S/^\///:S/etc//}sys

to

SYSDIR=	${.CURDIR:S/^\///:S/etc/sys/}

Scot
Comment 2 Jilles Tjoelker freebsd_committer 2010-05-15 22:34:59 UTC
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
Comment 3 Enji Cooper freebsd_committer 2015-11-10 12:33:38 UTC
This is slightly better, potentially:

$ svn diff .
Index: Makefile
===================================================================
--- Makefile    (revision 290640)
+++ Makefile    (working copy)
@@ -392,7 +392,7 @@
                    ${METALOG.add} ; \
        done; true
 .endif
-       ${INSTALL_SYMLINK} usr/src/sys ${DESTDIR}/sys
+       ${INSTALL_SYMLINK} ${SRCTOP}/sys ${DESTDIR}/sys
 .if ${MK_MAN} != "no"
        cd ${DESTDIR}${SHAREDIR}/man; \
        for mandir in man*; do \
Comment 4 Enji Cooper freebsd_committer 2015-11-14 22:10:46 UTC
(In reply to NGie Cooper from comment #3)

This works with relative symlinks, i.e. DESTDIR != /:

$ svn diff etc/
Index: etc/Makefile
===================================================================
--- etc/Makefile    (revision 290831)
+++ etc/Makefile    (working copy)
@@ -408,7 +408,7 @@
                    ${METALOG.add} ; \
        done; true
 .endif
-       ${INSTALL_SYMLINK} usr/src/sys ${DESTDIR}/sys
+       ${INSTALL_SYMLINK} ${SRCTOP:C/^\///}/sys ${DESTDIR}/sys
 .if ${MK_MAN} != "no"
        cd ${DESTDIR}${SHAREDIR}/man; \
        for mandir in man*; do \
Comment 5 commit-hook freebsd_committer 2015-11-15 03:05:43 UTC
A commit references this bug:

Author: ngie
Date: Sun Nov 15 03:04:39 UTC 2015
New revision: 290840
URL: https://svnweb.freebsd.org/changeset/base/290840

Log:
  Setup the symlink to /sys to mirror one's current source, e.g. if my source
  tree was /usr/src/svn, /sys would point to usr/src/svn

  This fixes the assumption that the source tree will always exist at
  ${DESTDIR}/usr/src

  MFC after: 1 week
  PR: 76362
  Reported by: Scot Hetzel <swhetzel@gmail.com>
  Sponsored by: EMC / Isilon Storage Division

Changes:
  head/etc/Makefile
Comment 6 commit-hook freebsd_committer 2015-12-01 06:23:11 UTC
A commit references this bug:

Author: ngie
Date: Tue Dec  1 06:22:28 UTC 2015
New revision: 291568
URL: https://svnweb.freebsd.org/changeset/base/291568

Log:
  Revert r290840

  This request by the submitter was valid, but unfortunately there is a good deal
  of concern over breakage when DESTDIR != / or "", i.e. with release media.
  Making this change correct for all cases would make it markedly more complex
  than need be

  Requested by: bdrewery, ian, imp
  PR: 76362

Changes:
  head/etc/Makefile
Comment 7 Enji Cooper freebsd_committer 2015-12-01 06:26:39 UTC
I'm closing the bug because (as noted in r291568), committing this change has definite consequences when DESTDIR != "" and "/". It's best just to deal with explicit brokenness when implicit brokenness in those cases, and as I said elsewhere, I can script the correct behavior if needed.