123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- #! /bin/sh -
- # Copyright (c) 2016-2018 Matias Fonzo, <selk@dragora.org>.
- # Copyright (c) 2020 Matias Fonzo, <selk@dragora.org>.
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- PROGRAM="${0##*/}"
- # Exit immediately on any error
- set -e
- # Override locale settings
- LC_ALL=C
- export LC_ALL
- # Get current working directory
- CWD=$(dirname -- "$0")
- # Functions
- unmountSeries()
- {
- for node in "${rootdir}/usr/src/qi/archive" \
- "${rootdir}/usr/src/qi/patches" \
- "${rootdir}/usr/src/qi/recipes" \
- "${rootdir}/usr/src/qi/sources" \
- "${rootdir}/sys" \
- "${rootdir}/proc" \
- "${rootdir}/dev/pts" \
- "${rootdir}/dev" ; \
- do
- if mount | grep -q "$node"
- then
- echo "Unmounting ${node} ..."
- if ! umount "$node"
- then
- echo "Doing a lazy unmount for $node ..."
- umount -l "$node"
- fi
- fi
- done
- unset node
- }
- # Autodetermine the path of /tools
- if test ! -L /tools
- then
- echo "${PROGRAM}: cannot determine ${rootdir}: /tools does not exist as symlink" 1>&2
- exit 1
- fi
- if test -L /tools -a ! -e /tools
- then
- echo "${PROGRAM}: cannot access /tools: Dangling symlink" 1>&2
- exit 1
- fi
- # Set canonical name to compose the root directory, removing
- # the last component from the path name "/tools"
- rootdir="$(CDPATH= cd -P -- /tools && pwd -P)"
- rootdir="${rootdir%/*}"
- # Unmount directories and file systems before the next mounting
- unmountSeries
- # Create required directory for destination
- mkdir -p -- "${rootdir}/dev" \
- "${rootdir}/dev/pts" \
- "${rootdir}/proc" \
- "${rootdir}/sys" \
- "${rootdir}/usr/src/qi/archive" \
- "${rootdir}/usr/src/qi/patches" \
- "${rootdir}/usr/src/qi/recipes" \
- "${rootdir}/usr/src/qi/sources"
- echo "Mounting virtual file systems ..."
- mount -o bind /dev "${rootdir}/dev"
- mount -t devpts devpts "${rootdir}/dev/pts"
- mount -t proc proc "${rootdir}/proc"
- mount -t sysfs sysfs "${rootdir}/sys"
- echo "Binding directories to mount: archive, patches, recipes, sources ..."
- mount -o bind "${CWD}/archive" "${rootdir}/usr/src/qi/archive"
- mount -o bind "${CWD}/patches" "${rootdir}/usr/src/qi/patches"
- mount -o bind "${CWD}/recipes" "${rootdir}/usr/src/qi/recipes"
- mount -o bind "${CWD}/sources" "${rootdir}/usr/src/qi/sources"
- # Add trap for unmount the series, signalled or not
- trap 'echo ; unmountSeries' EXIT HUP QUIT ABRT TERM
- echo "Entering via chroot $rootdir ..."
- chroot "$rootdir" /tools/bin/env -i \
- PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin:/opt/trinity/bin \
- SHELL=/bin/sh \
- HOME=/root \
- TERM="${TERM:-linux}" \
- HOSTNAME=dragora \
- LC_CTYPE=C.UTF-8 \
- PKG_CONFIG=/usr/bin/pkgconf \
- PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/share/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig:/opt/trinity/lib/pkgconfig \
- QTDIR=/opt/trinity/lib/tqt3 \
- /bin/sh -
|