setup base rootfs with debootstrap

This commit is contained in:
ading2210 2023-10-20 06:38:45 -04:00
parent a804bbabc7
commit 0fa4e3f054
4 changed files with 90 additions and 9 deletions

View File

@ -110,10 +110,10 @@ echo "copying data into the image"
rootfs_mount=/tmp/new_rootfs
populate_partitions $image_loop $initramfs_dir $rootfs_dir $rootfs_mount
echo "copying modules into the rootfs"
patch_rootfs $shim_rootfs $rootfs_mount || echo "failed patching rootfs"
umount $rootfs_mount
umount $shim_rootfs
#echo "copying modules into the rootfs"
#patch_rootfs $shim_rootfs $rootfs_mount || echo "failed patching rootfs"
#umount $rootfs_mount
#umount $shim_rootfs
echo "cleaning up loop devices"
losetup -d $shim_loop

47
build_rootfs.sh Executable file
View File

@ -0,0 +1,47 @@
#!/bin/bash
#build the debian rootfs
set -e
if [ "$DEBUG" ]; then
set -x
fi
print_help() {
echo "Usage: ./build_rootfs.sh rootfs_path release_name"
}
check_deps() {
local needed_commands="realpath debootstrap"
for command in $needed_commands; do
if ! command -v $command &> /dev/null; then
echo $command
fi
done
}
if [ "$EUID" -ne 0 ]; then
echo "this needs to be run as root."
exit 1
fi
if [ -z "$2" ]; then
print_help
exit 1
fi
missing_commands=$(check_deps)
if [ "${missing_commands}" ]; then
echo "You are missing dependencies needed for this script."
echo "Commands needed:"
echo "${missing_commands}"
exit 1
fi
rootfs_dir=$(realpath "${1}")
release_name="${2}"
debootstrap $release_name $rootfs_dir http://deb.debian.org/debian/
cp -r rootfs/* $rootfs_dir
chroot_command="DEBUG=${DEBUG} release_name=${release_name} /opt/setup_rootfs.sh"
chroot $rootfs_dir /bin/bash -c "${chroot_command}"

View File

@ -7,14 +7,20 @@ if [ "$DEBUG" ]; then
set -x
fi
patch_rootfs() {
copy_modules() {
local shim_rootfs=$(realpath $1)
local target_rootfs=$(realpath $2)
local reco_rootfs=$(realpath $2)
local target_rootfs=$(realpath $3)
cp -r "${shim_rootfs}/lib/modules/"* "${target_rootfs}/lib/modules/"
cp -r "${shim_rootfs}/lib/modprobe.d/"* "${target_rootfs}/lib/modprobe.d/"
cp -r "${shim_rootfs}/etc/modprobe.d/"* "${target_rootfs}/etc/modprobe.d/"
cp -r "${shim_rootfs}/lib/firmware/"* "${target_rootfs}/lib/firmware/"
cp -r "${reco_rootfs}/lib/modprobe.d/"* "${target_rootfs}/lib/modprobe.d/"
cp -r "${reco_rootfs}/etc/modprobe.d/"* "${target_rootfs}/etc/modprobe.d/"
}
patch_rootfs $1 $2
download_firmware() {
local firmware_url="https://chromium.googlesource.com/chromiumos/third_party/linux-firmware"
local firmware_path="/tmp/chromium-firmware"
git clone --branch master --depth=1 "${firmware_url}" $firmware_path
}

28
rootfs/opt/setup_rootfs.sh Executable file
View File

@ -0,0 +1,28 @@
#!/bin/bash
#setup the debian rootfs
#this is meant to be run within the chroot created by debootstrap
set -e
if [ "$DEBUG" ]; then
set -x
fi
custom_repo="https://shimboot.ading.dev/debian"
sources_entry="deb [trusted=yes] ${custom_repo} ${release_name} main"
#add shimboot repos
echo -e "${sources_entry}\n$(cat /etc/apt/sources.list)" > /etc/apt/sources.list
tee -a /etc/apt/preferences << END
Package: *
Pin: origin "${custom_repo}"
Pin-Priority: 1001
END
#install the patched systemd
apt-get install -y ca-certificates
apt-get update
apt-get upgrade -y
#install desktop
apt-get install -y xfce4 xfce4-goodies network-manager blueman firefox-esr sudo