#!/bin/bash test $# -eq 2 || { echo "Usage: $0 "; exit 1; } # No provision for spaces or other weird characters in pathnames. So sue me. CHROOT=$1 INSTDIR=$2 mkdir $CHROOT || exit 1 cd $CHROOT || exit 1 ( # Produce a list of file names, one per line, that will be copied # into the template tree of system files for the chroot jails. # 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_* \ /usr/share/fonts \ /etc/fonts -type f # 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 ) | while read file; do cp --parents $file . done