Commit 92afdd9f authored by Guido Gunther's avatar Guido Gunther

rootfs setup: do chroot setup upfront

so not every function has to bother with the proper setup.
parent 83216293
......@@ -84,8 +84,12 @@ function setup_uboot()
}
function unmount_binds()
function cleanup_chroot()
{
rm $basedir/etc/resolv.conf
mv $basedir/etc/resolv.conf.bak $basedir/etc/resolv.conf
rm $basedir/usr/sbin/policy-rc.d
umount $basedir/dev/pts
umount $basedir/dev
umount $basedir/sys
......@@ -93,6 +97,21 @@ function unmount_binds()
}
function prepare_chroot()
{
trap cleanup_chroot EXIT
mount -t proc chproc $basedir/proc
mount -t sysfs chsys $basedir/sys
mount -t devtmpfs chdev $basedir/dev || mount --bind /dev $basedir/dev
mount -t devpts chpts $basedir/dev/pts
echo -e '#!/bin/sh\nexit 101' > $basedir/usr/sbin/policy-rc.d
chmod 755 $basedir/usr/sbin/policy-rc.d
mv $basedir/etc/resolv.conf $basedir/etc/resolv.conf.bak
cp /etc/resolv.conf $basedir/etc
}
function setup_gui()
{
# Allow purism user to launch weston from the console
......@@ -110,15 +129,6 @@ function setup_gui()
function install_pkgs()
{
# Inspired by https://linux-sunxi.org/Mainline_Debian_HowTo
mount -t proc chproc $basedir/proc
mount -t sysfs chsys $basedir/sys
mount -t devtmpfs chdev $basedir/dev || mount --bind /dev $basedir/dev
mount -t devpts chpts $basedir/dev/pts
echo -e '#!/bin/sh\nexit 101' > $basedir/usr/sbin/policy-rc.d
chmod 755 $basedir/usr/sbin/policy-rc.d
mv $basedir/etc/resolv.conf $basedir/etc/resolv.conf.bak
cp /etc/resolv.conf $basedir/etc
(
export DEBIAN_FRONTEND=noninteractive
export DEBCONF_NONINTERACTIVE_SEEN=true
......@@ -129,20 +139,9 @@ function install_pkgs()
chroot $basedir apt-get -y update
chroot $basedir apt-get -y install $packages
)
rm $basedir/etc/resolv.conf
mv $basedir/etc/resolv.conf.bak $basedir/etc/resolv.conf
rm $basedir/usr/sbin/policy-rc.d
unmount_binds
}
function cleanup () {
unmount_binds
}
trap cleanup ERR
# create the directories so that this script can be tested without the generated filesystem
mkdir -p $basedir/etc/apt/apt.conf.d/
......@@ -201,8 +200,10 @@ console-common console-data/keymap/policy select Select keymap from full list
console-common console-data/keymap/full select en-latin1-nodeadkeys
EOF
prepare_chroot
setup_qemu
install_pkgs
setup_kernel
setup_uboot
setup_gui
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment