/usr/sbin/chroot.fakechroot is in fakechroot 2.17.2-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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | #!/bin/bash
# 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, 2013 Piotr Roszatycki <dexter@debian.org>, LGPL
fakechroot_chroot_load_ldsoconf () {
fakechroot_chroot_files="$1"
fakechroot_chroot_newroot="$2"
for fakechroot_chroot_file in `eval echo $fakechroot_chroot_newroot$fakechroot_chroot_files`; do
fakechroot_chroot_file="${fakechroot_chroot_file#$fakechroot_chroot_newroot}"
sed -e 's/#.*//' -e '/^ *$/d' "$fakechroot_chroot_newroot$fakechroot_chroot_file" 2>/dev/null | while read fakechroot_chroot_line; do
case "$fakechroot_chroot_line" in
include*)
fakechroot_chroot_include=`echo "$fakechroot_chroot_line" | sed -e 's/^include *//' -e 's/ *$//'`
for fakechroot_chroot_incfile in `eval echo $fakechroot_chroot_newroot$fakechroot_chroot_include`; do
fakechroot_chroot_incfile="${fakechroot_chroot_incfile#$fakechroot_chroot_newroot}"
fakechroot_chroot_load_ldsoconf "$fakechroot_chroot_incfile" "$fakechroot_chroot_newroot"
done
;;
*)
echo "$fakechroot_chroot_newroot$fakechroot_chroot_line"
;;
esac
done
done
}
fakechroot_chroot_chroot="${FAKECHROOT_CMD_ORIG:-chroot}"
fakechroot_chroot_base="$FAKECHROOT_BASE_ORIG"
fakechroot_chroot_n=1
for fakechroot_chroot_opt in "$@"; do
case "$fakechroot_chroot_opt" in
-*)
continue
;;
*)
fakechroot_chroot_newroot="$fakechroot_chroot_opt"
break
;;
esac
fakechroot_chroot_n=$(($fakechroot_chroot_n + 1))
done
if [ -d "$fakechroot_chroot_newroot" ]; then
fakechroot_chroot_newroot=`cd "$fakechroot_chroot_opt"; pwd -P`
fakechroot_chroot_paths=
# append newroot to each directory from original LD_LIBRARY_PATH
fakechroot_chroot_IFS_bak="$IFS" IFS=:
for fakechroot_chroot_d in $LD_LIBRARY_PATH; do
fakechroot_chroot_paths="${fakechroot_chroot_paths:+$fakechroot_chroot_paths:}$fakechroot_chroot_base$fakechroot_chroot_newroot/${fakechroot_chroot_d#/}"
done
IFS="$fakechroot_chroot_IFS_bak"
# append newroot to each directory from new /etc/ld.so.conf
fakechroot_chroot_paths_ldsoconf=""
if [ -f "$fakechroot_chroot_newroot/etc/ld.so.conf" ]; then
fakechroot_chroot_paths_ldsoconf=`fakechroot_chroot_load_ldsoconf "/etc/ld.so.conf" "$fakechroot_chroot_newroot" | while read fakechroot_chroot_line; do printf ":%s%s" "$fakechroot_chroot_base" "$fakechroot_chroot_line"; done`
elif [ -d "$fakechroot_chroot_newroot/etc/ld.so.conf.d" ]; then
fakechroot_chroot_paths_ldsoconf=`fakechroot_chroot_load_ldsoconf "/etc/ld.so.conf.d/*" "$fakechroot_chroot_newroot" | while read fakechroot_chroot_line; do printf ":%s%s" "$fakechroot_chroot_base" "$fakechroot_chroot_line"; done`
fi
fakechroot_chroot_paths_ldsoconf="${fakechroot_chroot_paths_ldsoconf#:}"
fakechroot_chroot_paths="$fakechroot_chroot_paths${fakechroot_chroot_paths_ldsoconf:+:$fakechroot_chroot_paths_ldsoconf}${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
fakechroot_chroot_paths="${fakechroot_chroot_paths#:}"
fi
# call real chroot
if [ -n "$fakechroot_chroot_newroot" ] && ( test "$1" = "${@:1:$((1+0))}" ) 2>/dev/null && [ $fakechroot_chroot_n -le $# ]; then
# shell with arrays and built-in expr
env -u FAKECHROOT_BASE_ORIG FAKECHROOT_CMD_ORIG= LD_LIBRARY_PATH="$fakechroot_chroot_paths" FAKECHROOT_BASE="$fakechroot_chroot_base" \
"$fakechroot_chroot_chroot" "${@:1:$(($fakechroot_chroot_n - 1))}" "${fakechroot_chroot_newroot#$FAKECHROOT_BASE_ORIG}" "${@:$(($fakechroot_chroot_n + 1))}"
exit $?
else
# POSIX shell
env -u FAKECHROOT_BASE_ORIG FAKECHROOT_CMD_ORIG= LD_LIBRARY_PATH="$fakechroot_chroot_paths" FAKECHROOT_BASE="$fakechroot_chroot_base" \
"$fakechroot_chroot_chroot" "$@"
exit $?
fi
|