pyrois/make.project/arm_chroot.sh

68 lines
1.5 KiB
Bash
Raw Normal View History

#!/bin/bash
2023-05-26 02:38:19 +00:00
set -u
APPNAME="CHROOT VFS SETUP"
T_SYSROOT=${dir_sysroot}
2023-02-21 03:24:08 +00:00
set -a
assert_zero() {
if [[ "$1" -eq 0 ]]; then
return
else
exit $1
fi
}
# ISO 8601 variation
TIMESTAMP="$(date +%Y-%m-%d_%H:%M:%S)"
LOG_DIR="${dir_logs}/${APPNAME}-${TIMESTAMP}"
# the file to log to
LOGFILE="${APPNAME}.log"
logprint() {
mkdir -p "${LOG_DIR}"
echo "[$(date +%Y-%m-%d_%H:%M:%S)] [${APPNAME}] $1" \
| tee -a "${LOG_DIR}/${LOGFILE}"
}
is_mounted() {
findmnt $1 &> /dev/null
if [ $? != 0 ]; then
/usr/bin/false
else
logprint "Already mounted, skipping."
/usr/bin/true
fi
}
logprint "CHROOT VFS SETUP"
mkdir -pv ${T_SYSROOT}/{dev,proc,sys,run}
assert_zero $?
logprint "Bind mounting /dev from host to chroot sysroot..."
is_mounted ${T_SYSROOT}/dev || mount -v --bind /dev ${T_SYSROOT}/dev
assert_zero $?
logprint "Bind mounting /dev/pts from host to chroot sysroot..."
is_mounted ${T_SYSROOT}/dev/pts || mount -v --bind /dev/pts ${T_SYSROOT}/dev/pts
assert_zero $?
logprint "mounting proc filesystem from to chroot sysroot..."
is_mounted ${T_SYSROOT}/proc || mount -v -t proc proc ${T_SYSROOT}/proc
assert_zero $?
2023-02-21 03:24:08 +00:00
logprint "mounting shm"
# not a symlink on ubuntu
if [ -h ${T_SYSROOT}/dev/shm ]; then
2023-02-21 03:24:08 +00:00
mkdir -vp ${T_SYSROOT}/$(readlink "${T_SYSROOT}/dev/shm")
assert_zero $?
else
2023-02-21 03:24:08 +00:00
is_mounted ${T_SYSROOT}/dev/shm || mount -t tmpfs -o nosuid,nodev tmpfs ${T_SYSROOT}/dev/shm
fi
2023-02-21 03:24:08 +00:00
logprint "mounting rex_embedded for stage3 capability"
mkdir -p ${T_SYSROOT}/rex_embedded
is_mounted ${T_SYSROOT}/rex_embedded || mount -v --bind ${project_root} ${T_SYSROOT}/rex_embedded