add github action to build the rootfs

This commit is contained in:
ading2210 2024-01-25 21:12:20 +00:00
parent 9840555faa
commit 73a2a38698
4 changed files with 57 additions and 26 deletions

26
.github/workflows/build-rootfs.yaml vendored Normal file
View File

@ -0,0 +1,26 @@
name: build-rootfs
run-name: Build the base Debian rootfs
on: [push]
jobs:
main:
runs-on: ubuntu-latest
steps:
- name: download repo
uses: actions/checkout@v4
- name: install deps
run: |
sudo apt-get install debootstrap coreutils -y
- name: run build
id: run_build
run: sudo DEBUG=1 ./build_rootfs.sh data/rootfs bookworm hostname=shimboot root_passwd=root username=user user_passwd=user
- name: archive rootfs
run: tar -vcf data/rootfs.tar.gz -C data/rootfs ./
- name: upload rootfs
uses: actions/upload-artifact@v4
with:
name: rootfs_tar
path: data/rootfs.tar.gz

View File

@ -14,15 +14,6 @@ print_help() {
echo "Usage: ./build.sh output_path shim_path rootfs_dir"
}
check_deps() {
local needed_commands="cpio binwalk pcregrep realpath cgpt mkfs.ext4 mkfs.ext2 fdisk rsync"
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
@ -33,13 +24,8 @@ if [ -z "$3" ]; then
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
. ./common.sh
assert_deps "cpio binwalk pcregrep realpath cgpt mkfs.ext4 mkfs.ext2 fdisk rsync"
output_path=$(realpath "${1}")
shim_path=$(realpath "${2}")

View File

@ -17,9 +17,21 @@ if [ -z "$1" ]; then
echo "Usage: ./build_complete.sh board_name"
echo "Valid named arguments (specify with 'key=value'):"
echo " compress_img - Compress the final disk image into a zip file. Set this to any value to enable this option."
echo " rootfs_dir - Use a different rootfs for the build. The directory you select will be copied before any patches are applied."
exit 1
fi
parse_args "$@"
needed_deps="wget python3 unzip zip git debootstrap cpio binwalk pcregrep cgpt mkfs.ext4 mkfs.ext2 fdisk rsync"
if ! check_deps "$needed_deps"; then
#install deps automatically on debian and ubuntu
if [ -f "/etc/debian_version" ]; then
echo "attempting to install build deps"
apt-get install wget python3-all unzip zip debootstrap cpio binwalk pcregrep cgpt rsync -y
fi
assert_deps "$needed_deps"
fi
cleanup_path=""
sigint_handler() {
if [ $cleanup_path ]; then
@ -77,22 +89,27 @@ download_and_unzip $reco_url $reco_zip $reco_bin
echo "downloading shim image"
download_and_unzip $shim_url $shim_zip $shim_bin
rootfs_dir="$(realpath data/rootfs_$board)"
rm -rf $rootfs_dir
mkdir -p $rootfs_dir
if [ ! "${args['rootfs_dir']}" ]; then
rootfs_dir="$(realpath data/rootfs_$board)"
rm -rf $rootfs_dir
mkdir -p $rootfs_dir
echo "building debian rootfs"
./build_rootfs.sh $rootfs_dir bookworm \
hostname=shimboot-$board \
root_passwd=root \
username=user \
user_passwd=user
echo "building debian rootfs"
./build_rootfs.sh $rootfs_dir bookworm \
hostname=shimboot-$board \
root_passwd=root \
username=user \
user_passwd=user
else
rootfs_dir="$(realpath "${args['rootfs_dir']}")"
fi
echo "patching debian rootfs"
./patch_rootfs.sh $shim_bin $reco_bin $rootfs_dir
echo "building final disk image"
final_image="$base_dir/data/shimboot_$board.bin"
rm -rf $final_image
./build.sh $final_image $shim_bin data/rootfs
echo "build complete! the final disk image is located at $final_image"

View File

@ -29,11 +29,13 @@ fi
assert_deps "realpath debootstrap"
parse_args "$@"
rootfs_dir=$(realpath "${1}")
rootfs_dir=$(realpath -m "${1}")
release_name="${2}"
packages="${args['custom_packages']-'task-xfce-desktop'}"
chroot_mounts="proc sys dev run"
mkdir -p $rootfs_dir
unmount_all() {
for mountpoint in $chroot_mounts; do
umount -l "$rootfs_dir/$mountpoint"