2015-04-08 09:22:42 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
2015-06-08 08:58:34 -05:00
|
|
|
test $# -eq 2 || { echo "Usage: $0 <chroot template directory for system libs to create> <LO installation directory>"; exit 1; }
|
2015-04-08 09:22:42 -05:00
|
|
|
|
|
|
|
# No provision for spaces or other weird characters in pathnames. So sue me.
|
|
|
|
|
|
|
|
CHROOT=$1
|
|
|
|
INSTDIR=$2
|
|
|
|
|
|
|
|
mkdir $CHROOT || exit 1
|
|
|
|
|
2015-04-29 07:02:59 -05:00
|
|
|
CHROOT=`cd $CHROOT && /bin/pwd`
|
|
|
|
INSTDIR=`cd $INSTDIR && /bin/pwd`
|
|
|
|
|
|
|
|
cd / || exit 1
|
2015-04-08 09:22:42 -05:00
|
|
|
|
|
|
|
(
|
|
|
|
# Produce a list of file names, one per line, that will be copied
|
|
|
|
# into the template tree of system files for the chroot jails.
|
|
|
|
|
2015-05-22 05:36:49 -05:00
|
|
|
if [ `uname -s` = Linux ]; then
|
|
|
|
|
|
|
|
# First essential files and shared objects
|
|
|
|
find etc/passwd etc/group etc/hosts \
|
|
|
|
etc/resolv.conf \
|
|
|
|
lib/ld-* lib64/ld-* \
|
|
|
|
etc/ld.so.* \
|
|
|
|
lib/libnss_* lib64/libnss_* \
|
|
|
|
var/cache/fontconfig \
|
|
|
|
etc/fonts \
|
|
|
|
usr/share/liblangtag \
|
2015-07-07 04:44:16 -05:00
|
|
|
lib/*-linux-gnu/libnss* \
|
2015-05-22 05:36:49 -05:00
|
|
|
-type f
|
|
|
|
|
2015-07-07 04:44:16 -05:00
|
|
|
|
2015-07-06 12:35:50 -05:00
|
|
|
find lib/libnss_* lib64/libnss_* -type l
|
2015-07-07 04:44:16 -05:00
|
|
|
find lib/*-linux-gnu/libnss* -type l
|
2015-07-06 12:35:50 -05:00
|
|
|
|
2015-05-22 05:36:49 -05:00
|
|
|
# Go through the LO shared objects and check what system libraries
|
|
|
|
# they link to.
|
|
|
|
find $INSTDIR -name '*.so' -o -name '*.so.[0-9]*' |
|
|
|
|
while read file; do
|
|
|
|
ldd $file 2>/dev/null
|
|
|
|
done |
|
|
|
|
grep -v dynamic | cut -d " " -f 3 | grep -E '^(/lib|/usr)' | sort -u | sed -e 's,^/,,'
|
|
|
|
else
|
2015-05-22 08:34:13 -05:00
|
|
|
find usr/lib/dyld \
|
2015-05-22 10:55:05 -05:00
|
|
|
usr/lib/*.dylib \
|
2015-05-22 08:34:13 -05:00
|
|
|
usr/lib/system/*.dylib \
|
2015-05-22 10:55:05 -05:00
|
|
|
System/Library/Frameworks/Accelerate.framework \
|
|
|
|
System/Library/Frameworks/ApplicationServices.framework \
|
|
|
|
System/Library/Frameworks/CFNetwork.framework \
|
|
|
|
System/Library/Frameworks/Carbon.framework \
|
|
|
|
System/Library/Frameworks/CoreFoundation.framework \
|
|
|
|
System/Library/Frameworks/CoreGraphics.framework \
|
|
|
|
System/Library/Frameworks/CoreServices.framework \
|
|
|
|
System/Library/Frameworks/CoreText.framework \
|
|
|
|
System/Library/Frameworks/DiskArbitration.framework \
|
|
|
|
System/Library/Frameworks/Foundation.framework \
|
|
|
|
System/Library/Frameworks/ImageIO.framework \
|
|
|
|
System/Library/Frameworks/IOKit.framework \
|
|
|
|
System/Library/Frameworks/IOSurface.framework \
|
|
|
|
System/Library/Frameworks/NetFS.framework \
|
|
|
|
System/Library/Frameworks/OpenDirectory.framework \
|
|
|
|
System/Library/Frameworks/Security.framework \
|
|
|
|
System/Library/Frameworks/SystemConfiguration.framework \
|
|
|
|
System/Library/PrivateFrameworks/DataDetectorsCore.framework \
|
|
|
|
System/Library/PrivateFrameworks/MultitouchSupport.framework \
|
|
|
|
System/Library/PrivateFrameworks/NetAuth.framework \
|
|
|
|
System/Library/PrivateFrameworks/login.framework \
|
2015-05-22 08:34:13 -05:00
|
|
|
-type f
|
|
|
|
|
2015-05-22 05:36:49 -05:00
|
|
|
find $INSTDIR -name '*.dylib' |
|
|
|
|
while read file; do
|
|
|
|
otool -L $file 2>/dev/null
|
|
|
|
done |
|
2015-05-22 10:55:05 -05:00
|
|
|
sed -e 's/^[ ]//' | grep -E '^/(lib|usr/lib)/' | cut -d' ' -f1 | sort -u | sed -e 's,^/,,'
|
2015-05-22 05:36:49 -05:00
|
|
|
fi
|
2015-04-08 09:22:42 -05:00
|
|
|
) |
|
|
|
|
|
2015-04-29 07:02:59 -05:00
|
|
|
# Can't use -l because then symlinks won't be handled well enough.
|
|
|
|
# This will now copy the file a symlink points to, but whatever.
|
|
|
|
cpio -p -d -L $CHROOT
|
2015-04-27 07:49:25 -05:00
|
|
|
|
2015-07-18 13:28:12 -05:00
|
|
|
mkdir -p $CHROOT/tmp
|
|
|
|
|
2015-04-27 07:49:25 -05:00
|
|
|
# /usr/share/fonts needs to be taken care of separately because the
|
|
|
|
# directory time stamps must be preserved are for fontconfig to trust
|
|
|
|
# its cache.
|
|
|
|
|
2015-04-29 07:02:59 -05:00
|
|
|
cd $CHROOT || exit 1
|
|
|
|
|
2015-05-22 05:36:49 -05:00
|
|
|
if [ `uname -s` = Linux ]; then
|
|
|
|
mkdir -p usr/share || exit 1
|
|
|
|
cp -r -p /usr/share/fonts usr/share
|
2015-04-29 07:02:59 -05:00
|
|
|
|
2015-05-22 05:36:49 -05:00
|
|
|
if [ -h usr/share/fonts/ghostscript ]; then
|
|
|
|
mkdir usr/share/ghostscript || exit 1
|
|
|
|
cp -r -p /usr/share/ghostscript/fonts usr/share/ghostscript
|
|
|
|
fi
|
2015-04-29 07:02:59 -05:00
|
|
|
fi
|