2 # Copyright (c) 2016-2018 Matias Fonzo, <selk@dragora.org>.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
18 # Exit immediately on any error
21 # Override locale settings
25 # Get physical working directory, absolute path name
26 CWD
=$
(CDPATH
= cd -P -- $
(dirname -- "$0") && printf "$PWD")
31 for node
in "${rootdir}/usr/src/qi/archive" \
32 "${rootdir}/usr/src/qi/patches" \
33 "${rootdir}/usr/src/qi/recipes" \
34 "${rootdir}/usr/src/qi/sources" \
37 "${rootdir}/dev/pts" \
40 if mount |
grep -q "$node"
42 echo "Unmounting ${node} ..."
45 echo "Doing a lazy unmount for $node ..."
52 # Autodetermine the path of /tools
56 echo "${PROGRAM}: cannot determine ${rootdir}: /tools does not exist as symlink" 1>&2
59 if test -L /tools
-a ! -e /tools
61 echo "${PROGRAM}: cannot access /tools: Dangling symlink" 1>&2
65 # Set canonical name to compose the root directory, removing
66 # the last component from the path name "/tools"
68 rootdir
=$
(CDPATH
= cd -P -- /tools
&& printf "$PWD")
69 rootdir
="${rootdir%/*}"
71 # Unmount directories and file systems before the next mounting
75 # Create required directory for destination
76 mkdir
-p -- "${rootdir}/dev" \
77 "${rootdir}/dev/pts" \
80 "${rootdir}/usr/src/qi/archive" \
81 "${rootdir}/usr/src/qi/patches" \
82 "${rootdir}/usr/src/qi/recipes" \
83 "${rootdir}/usr/src/qi/sources"
85 echo "Mounting virtual file systems ..."
86 mount
-o bind /dev
"${rootdir}/dev"
87 mount
-t devpts devpts
"${rootdir}/dev/pts"
88 mount
-t proc proc
"${rootdir}/proc"
89 mount
-t sysfs sysfs
"${rootdir}/sys"
91 echo "Binding directories to mount: archive, patches, recipes, sources ..."
92 mount
-o bind "${CWD}/archive" "${rootdir}/usr/src/qi/archive"
93 mount
-o bind "${CWD}/patches" "${rootdir}/usr/src/qi/patches"
94 mount
-o bind "${CWD}/recipes" "${rootdir}/usr/src/qi/recipes"
95 mount
-o bind "${CWD}/sources" "${rootdir}/usr/src/qi/sources"
97 # Add trap for unmount the series, signalled or not
98 trap 'echo ; unmountSeries' EXIT HUP QUIT ABRT TERM
100 echo "Entering via chroot $rootdir ..."
101 chroot
"$rootdir" /tools
/bin
/env
-i \
102 PATH
=/bin
:/usr
/bin
:/sbin
:/usr
/sbin
:/tools
/bin \
108 PKG_CONFIG
=/usr
/bin
/pkgconf \
109 PKG_CONFIG_PATH
=/usr
/local
/lib
/pkgconfig
:/usr
/local
/share
/pkgconfig
:/usr
/lib
/pkgconfig
:/usr
/share
/pkgconfig \