| 1 |
#!/bin/sh |
| 2 |
# Copyright © 2011 Julian Andres Klode <[email protected]> |
| 3 |
# |
| 4 |
# schroot is free software: you can redistribute it and/or modify it |
| 5 |
# under the terms of the GNU General Public License as published by |
| 6 |
# the Free Software Foundation, either version 3 of the License, or |
| 7 |
# (at your option) any later version. |
| 8 |
# |
| 9 |
# schroot is distributed in the hope that it will be useful, but |
| 10 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 |
# General Public License for more details. |
| 13 |
# |
| 14 |
# You should have received a copy of the GNU General Public License |
| 15 |
# along with this program. If not, see |
| 16 |
# <http://www.gnu.org/licenses/>. |
| 17 |
# |
| 18 |
##################################################################### |
| 19 |
|
| 20 |
set -e |
| 21 |
|
| 22 |
. "$SETUP_DATA_DIR/common-data" |
| 23 |
. "$SETUP_DATA_DIR/common-functions" |
| 24 |
. "$SETUP_DATA_DIR/common-config" |
| 25 |
|
| 26 |
|
| 27 |
if [ "$STAGE" != "setup-start" ] && \ |
| 28 |
[ "$STAGE" != "setup-stop" ] && \ |
| 29 |
[ "$STAGE" != "setup-recover" ]; then |
| 30 |
exit 0 |
| 31 |
elif ! which update-binfmts > /dev/null 2>&1; then |
| 32 |
info "Missing update-binfmts; not enabling binfmt support" |
| 33 |
exit 0 |
| 34 |
fi |
| 35 |
|
| 36 |
shell="${CHROOT_PATH}/bin/sh" |
| 37 |
|
| 38 |
for emulator in $(update-binfmts --find "$shell"); do |
| 39 |
dst="${CHROOT_PATH}$emulator" |
| 40 |
if [ ! -e "$emulator" ]; then |
| 41 |
info "Missing emulator: $emulator; not enabling binfmt support" |
| 42 |
else |
| 43 |
[ -e "$dst" ] || { mkdir -p "$(dirname "$dst")"; touch "$dst"; } |
| 44 |
mount --bind "$emulator" "$dst" |
| 45 |
mount -o remount,ro,bind "$dst" |
| 46 |
fi |
| 47 |
done |