pkgsrc-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: [PATCH] mksandbox fix for OS X Yosemite new kernel location



On 4/13/15 12:09 PM, Greg Troxel wrote:
> "J. Lewis Muir" <jlmuir%imca-cat.org@localhost> writes:
>> I don't know why the kernel needs to be copied on OS X in the first
>> place.  Was this done just to be like the other supported platforms,
>> and it was easy to do?  Or was it done because it was really needed?
>> If the kernel really does need to be copied, then the below patch
>> won't solve the problem on OS X Yosemite.  However, it would be
>> trivial to make a new patch that does copy the kernel from the
>> new location to wherever it should go in the sandbox (presumably
>> /System/Library/Kernels/kernel).  I'd be happy to provide such a
>> patch if that would be helpful.
> 
> I don't know why either, but some programs on some systems expect to
> have a kernel (to get symbols from).  So I think it's easier to copy
> the kernel from where it is (to the same place in the chroot) than
> to figure out why we don't need it.  A patch to do that (and tested)
> seems safe enough to apply.

Hi, Greg.

Thanks for your reply!  I created version 2 of the patch (below)
according to what you suggested; I tested it, and it works.

However, when testing the patch, I realized that mksandbox already
adds /System/Library to sandboxMountDirs (the directories to mount
read-only in the sandbox), so /System/Library/Kernels/kernel is already
accessible in the sandbox *without* this patch.  With this patch,
mksandbox will create (in the chroot sandbox) /System/Library/Kernels
and copy the kernel file into it, but then later it will mount the real
/System/Library at /System/Library in the sandbox, thus hiding the
kernel that was copied to /System/Library/Kernels/kernel earlier before
the mount.

So, maybe the first version of this patch would be better?

Here's a commit message (if you want to use it) for the first version:

===
On Darwin, set kernel=/mach_kernel only if the kernel exists there.
As of OS X Yosemite (10.10), the kernel is no longer at /mach_kernel
but instead at /System/Library/Kernels/kernel.  Since mksandbox mounts
/System/Library in the sandbox, the kernel is accessible there on
Yosemite and newer.
===

And here's a commit message (if you want to use it) for the second
version:

===
On Darwin, set kernel=/mach_kernel only if the kernel exists
there.  As of OS X Yosemite (10.10), the kernel is no longer at
/mach_kernel but instead at /System/Library/Kernels/kernel, so set
kernel=/System/Library/Kernels/kernel only if it exists there.  Note
that since mksandbox mounts /System/Library in the sandbox, copying
the kernel to /System/Library/Kernels/kernel doesn't achieve anything
because it will be hidden by the /System/Library mount.
===

Thanks!

Lewis

Index: files/mksandbox
===================================================================
RCS file: /cvsroot/pkgsrc/pkgtools/mksandbox/files/mksandbox,v
retrieving revision 1.6
diff -u -r1.6 mksandbox
--- files/mksandbox	24 Jul 2013 22:16:26 -0000	1.6
+++ files/mksandbox	13 Apr 2015 19:35:47 -0000
@@ -74,7 +74,11 @@
 	cpprog=/bin/cp
 	gtarprog=/usr/bin/gnutar
 	idprog=/usr/bin/id
-	kernel=/mach_kernel
+	if [ -f /mach_kernel ]; then
+		kernel=/mach_kernel
+	elif [ -f /System/Library/Kernels/kernel ]; then
+		kernel=/System/Library/Kernels/kernel
+	fi
 	mkdirprog="/bin/mkdir -p"
 	mountflags="-t nfs"
 	mounthost="localhost"
@@ -249,7 +253,9 @@
 
 if [ ! -z "$kernel" ]; then
 	echo "Copying the kernel"
-	$cpprog $kernel $sandbox
+	kerneldir=`echo $kernel | $sedprog  -e 's|/[^/]*$||;s|^$|/|'`
+	$mkdirprog $sandbox/$kerneldir
+	$cpprog $kernel $sandbox/$kerneldir
 fi
 
 if [ "$with_pkgsrc" = "yes" ]; then


Home | Main Index | Thread Index | Old Index