summaryrefslogtreecommitdiffstats
path: root/recipes-support/32b-env/files/set_32b_env_chroot.sh
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-support/32b-env/files/set_32b_env_chroot.sh')
-rwxr-xr-xrecipes-support/32b-env/files/set_32b_env_chroot.sh120
1 files changed, 120 insertions, 0 deletions
diff --git a/recipes-support/32b-env/files/set_32b_env_chroot.sh b/recipes-support/32b-env/files/set_32b_env_chroot.sh
new file mode 100755
index 0000000..8d450c4
--- /dev/null
+++ b/recipes-support/32b-env/files/set_32b_env_chroot.sh
@@ -0,0 +1,120 @@
1#!/bin/sh
2
3help()
4{
5 echo " The scope of this script is to setup an environment for 32b legacy applications."
6 echo " This is a replacement for MULTILIB mechanism which is not available yet for aarch64."
7 echo " chroot is used to setup an isolated environment for 32b applications"
8 echo " "
9 echo " Prerequisites:"
10 echo " - user must build a 32b amrv7 rootfs (e.q. build a image for qemuarm)"
11 echo " - user must copy 32b armv7 rootfs under 64b rootfs (e.q. /mnt/rootfs32)"
12 echo " - user must copy 32b application under 32b rootfs (e.q. /mnt/rootfs32/myapp)"
13 echo ""
14 echo " Run setup script to prepare the environment for 32b applications"
15 echo " > set_32b_env_chroot -r /mnt/rootfs32"
16 echo ""
17 echo " Run 32b applications"
18 echo " @> ./myapp/myexec"
19 echo ""
20 echo " In order to return to default root just type <exit>"
21 echo " @> exit"
22 exit
23}
24
25usage()
26{
27 echo "set_32b_env_chroot OPTIONS"
28 echo "OPTIONS:"
29 echo ""
30 echo " -r <32b_rootfs> : path to a 32b rootfs."
31 echo " -h : display help"
32 echo ""
33 exit
34}
35
36if [[ $# -eq 0 ]] ; then
37 echo "[ERR]: Missing script parameters!"
38 echo ""
39 usage
40fi
41
42while getopts "hr:" OPTION;
43do
44 case $OPTION in
45
46 r)
47 ROOTFS32b_PATH="$OPTARG"
48 ;;
49
50 ?)
51 help
52 ;;
53
54 esac
55done
56
57ABS_PATH=`cd "${ROOTFS32b_PATH}"; pwd`
58ROOTFS32b_PATH=${ABS_PATH}
59
60if [[ ! -d ${ROOTFS32b_PATH} ]] ; then
61 usage
62fi
63
64if [[ ! -d ${ROOTFS32b_PATH}/dev ]] ; then
65 mkdir ${ROOTFS32b_PATH}/dev
66fi
67
68if [[ ! -d ${ROOTFS32b_PATH}/proc ]] ; then
69 mkdir ${ROOTFS32b_PATH}/proc
70fi
71
72if [[ ! -d ${ROOTFS32b_PATH}/sys ]] ; then
73 mkdir ${ROOTFS32b_PATH}/sys
74fi
75
76if [[ ! -d ${ROOTFS32b_PATH}/etc ]] ; then
77 mkdir ${ROOTFS32b_PATH}/etc
78fi
79
80umount ${ROOTFS32b_PATH}/dev/pts 2>/dev/null
81umount ${ROOTFS32b_PATH}/dev 2>/dev/null
82mount --bind /dev ${ROOTFS32b_PATH}/dev
83if [[ "$?" != "0" ]] ; then
84 echo "Failed to mount /dev folder"
85 exit
86fi
87
88umount ${ROOTFS32b_PATH}/proc 2>/dev/null
89mount --bind /proc ${ROOTFS32b_PATH}/proc
90if [[ "$?" != "0" ]] ; then
91 echo "Failed to mount /proc folder"
92 exit
93fi
94
95umount ${ROOTFS32b_PATH}/sys 2>/dev/null
96mount --bind /sys ${ROOTFS32b_PATH}/sys
97if [[ "$?" != "0" ]] ; then
98 echo "Failed to mount /sys folder"
99 exit
100fi
101
102mount --bind /dev/pts ${ROOTFS32b_PATH}/dev/pts
103if [[ "$?" != "0" ]] ; then
104 echo "Failed to mount /dev/pts folder"
105 exit
106fi
107
108cp /etc/resolv.conf ${ROOTFS32b_PATH}/etc/resolv.conf
109if [[ "$?" != "0" ]] ; then
110 echo "Failed to copy resolv.conf file"
111 exit
112fi
113
114PATH=/bin:/sbin:/usr/bin:/usr/sbin
115
116echo "New root will be ${ROOTFS32b_PATH}/ type \"exit\" to return to /"
117chroot ${ROOTFS32b_PATH}/ /bin/sh
118if [[ "$?" != "0" ]] ; then
119 echo "Failed to start chroot!"
120fi