Last active
December 22, 2021 22:14
-
-
Save afresh1/daf96f561db05be705ed9a9e2982e4bf to your computer and use it in GitHub Desktop.
fill-chroot - Add files and their needed libs to a chroot directory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
chroot=/var/www # ${PWD} | |
copy_recurse() { | |
file=$1 | |
[ -e "${chroot}${file}" ] && return | |
mkdir -p $( dirname "${chroot}${file}" ) | |
cp -p "$file" "${chroot}${file}" | |
ldd "$file" 2>/dev/null | sed -e 's,^[^/]*,,' | while read f; do | |
[ -e "$f" ] && copy_recurse "$f" | |
done | |
} | |
for file in "$@"; do | |
copy_recurse "$file" | |
done | |
if [ -e "${chroot}/usr/libexec/ld.so" ]; then | |
mkdir -p "${chroot}/var/run" | |
LD_PATH=$( find "${chroot}"/usr -name '*.so.*' | while read f; do | |
dirname ${f#${chroot}} | |
done | sort -u ) | |
if [ -n "${LD_PATH}" ]; then | |
cp /sbin/ldconfig "${chroot}/ldconfig" | |
chroot "${chroot}" /ldconfig ${LD_PATH} | |
rm -f "${chroot}/ldconfig" | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment