#!/bin/sh # B12 (board, LFS host side): RAM-only Alpine chroot at /tmp/alpine on its own tmpfs (size-capped; umount frees everything). # chroot-up.sh (- = stream from stdin) # Mounts (only what X/apk need): proc, sysfs (ro), /dev (bind), /dev/pts (bind). No eMMC partition is touched. set -u; R=/tmp/alpine; SZ=${ALPINE_TMPFS_SIZE:-160m}; SRC=${1:-} log() { echo "[$(cut -d' ' -f1 /proc/uptime)] $*"; } mnt() { grep -q " $1 " /proc/mounts; } [ -n "$SRC" ] || { echo "usage: $0 "; exit 2; } mkdir -p $R mnt $R || mount -t tmpfs -o size=$SZ,mode=0755 alpine $R || { echo "CHROOT-UP FAIL tmpfs"; exit 1; } if [ ! -x $R/bin/busybox ]; then if [ "$SRC" = - ]; then tar xzf - -C $R; else tar xzf "$SRC" -C $R; fi || { echo "CHROOT-UP FAIL extract"; exit 1; } fi mnt $R/proc || mount -t proc proc $R/proc mnt $R/sys || { mount -o bind /sys $R/sys && mount -o remount,bind,ro $R/sys; } mnt $R/dev || mount -o bind /dev $R/dev mnt $R/dev/pts || mount -o bind /dev/pts $R/dev/pts # DNS for apk inside the chroot: bearer DNS from the modem controller (falls back to 77.88.8.8) DNS=$(sed -n 's/^DNS=//p' /run/aurora-modem/ipcfg 2>/dev/null | tr ',' ' '); [ -n "$DNS" ] || DNS=77.88.8.8 : > $R/etc/resolv.conf; for d in $DNS; do echo "nameserver $d" >> $R/etc/resolv.conf; done log "CHROOT-UP OK $(cat $R/etc/alpine-release) used=$(df -k $R | awk 'NR==2{print $3}')k mounts=$(grep -c " $R" /proc/mounts)"