/usr/sbin/chroot.fakechroot is in fakechroot 2.16-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | #!/bin/sh
# chroot
#
# Wrapper for chroot command which sets additional LD_LIBRARY_PATH for fake
# chroot environment. It copies original LD_LIBRARY_PATH and adds prefix to
# each directory for this variable.
#
# (c) 2011 Piotr Roszatycki <dexter@debian.org>, LGPL
load_ldsoconf () {
file="$1"
newroot="$2"
sed -e 's/#.*//' -e '/^ *$/d' "$newroot$file" 2>/dev/null | while read line; do
case "$line" in
include*)
include=`echo "$line" | sed -e 's/^include *//' -e 's/ *$//'`
for incfile in `eval echo $newroot$include`; do
incfile="${incfile#$newroot}"
load_ldsoconf "$incfile" "$newroot"
done
;;
*)
echo "$newroot$line"
;;
esac
done
}
chroot="${FAKECHROOT_CMD_ORIG:-chroot}"
FAKECHROOT_CMD_ORIG=
base="$FAKECHROOT_BASE_ORIG"
unset FAKECHROOT_BASE_ORIG
for opt in "$@"; do
case "$opt" in
-*)
continue
;;
*)
newroot="$1"
break
;;
esac
done
if [ -n "$newroot" ]; then
paths=
# append newroot to each directory from original LD_LIBRARY_PATH
IFS_bak="$IFS" IFS=:
for d in $LD_LIBRARY_PATH; do
paths="${paths:+$paths:}$base$newroot/${d#/}"
done
IFS="$IFS_bak"
# append newroot to each directory from new /etc/ld.so.conf
paths_ldsoconf=`load_ldsoconf "/etc/ld.so.conf" "$newroot" | while read line; do printf ":%s%s" "$base" "$line"; done`
paths_ldsoconf="${paths_ldsoconf#:}"
paths="$paths${paths_ldsoconf:+:$paths_ldsoconf}${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
paths="${paths#:}"
fi
# call real chroot
env LD_LIBRARY_PATH="$paths" FAKECHROOT_BASE="$base" "$chroot" "$@"
exit $?
|