add github action to build the rootfs
This commit is contained in:
parent
9840555faa
commit
73a2a38698
|
@ -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
|
18
build.sh
18
build.sh
|
@ -14,15 +14,6 @@ print_help() {
|
||||||
echo "Usage: ./build.sh output_path shim_path rootfs_dir"
|
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
|
if [ "$EUID" -ne 0 ]; then
|
||||||
echo "this needs to be run as root."
|
echo "this needs to be run as root."
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -33,13 +24,8 @@ if [ -z "$3" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
missing_commands=$(check_deps)
|
. ./common.sh
|
||||||
if [ "${missing_commands}" ]; then
|
assert_deps "cpio binwalk pcregrep realpath cgpt mkfs.ext4 mkfs.ext2 fdisk rsync"
|
||||||
echo "You are missing dependencies needed for this script."
|
|
||||||
echo "Commands needed:"
|
|
||||||
echo "${missing_commands}"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
output_path=$(realpath "${1}")
|
output_path=$(realpath "${1}")
|
||||||
shim_path=$(realpath "${2}")
|
shim_path=$(realpath "${2}")
|
||||||
|
|
|
@ -17,9 +17,21 @@ if [ -z "$1" ]; then
|
||||||
echo "Usage: ./build_complete.sh board_name"
|
echo "Usage: ./build_complete.sh board_name"
|
||||||
echo "Valid named arguments (specify with 'key=value'):"
|
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 " 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
|
exit 1
|
||||||
fi
|
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=""
|
cleanup_path=""
|
||||||
sigint_handler() {
|
sigint_handler() {
|
||||||
if [ $cleanup_path ]; then
|
if [ $cleanup_path ]; then
|
||||||
|
@ -77,22 +89,27 @@ download_and_unzip $reco_url $reco_zip $reco_bin
|
||||||
echo "downloading shim image"
|
echo "downloading shim image"
|
||||||
download_and_unzip $shim_url $shim_zip $shim_bin
|
download_and_unzip $shim_url $shim_zip $shim_bin
|
||||||
|
|
||||||
rootfs_dir="$(realpath data/rootfs_$board)"
|
if [ ! "${args['rootfs_dir']}" ]; then
|
||||||
rm -rf $rootfs_dir
|
rootfs_dir="$(realpath data/rootfs_$board)"
|
||||||
mkdir -p $rootfs_dir
|
rm -rf $rootfs_dir
|
||||||
|
mkdir -p $rootfs_dir
|
||||||
|
|
||||||
echo "building debian rootfs"
|
echo "building debian rootfs"
|
||||||
./build_rootfs.sh $rootfs_dir bookworm \
|
./build_rootfs.sh $rootfs_dir bookworm \
|
||||||
hostname=shimboot-$board \
|
hostname=shimboot-$board \
|
||||||
root_passwd=root \
|
root_passwd=root \
|
||||||
username=user \
|
username=user \
|
||||||
user_passwd=user
|
user_passwd=user
|
||||||
|
else
|
||||||
|
rootfs_dir="$(realpath "${args['rootfs_dir']}")"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "patching debian rootfs"
|
echo "patching debian rootfs"
|
||||||
./patch_rootfs.sh $shim_bin $reco_bin $rootfs_dir
|
./patch_rootfs.sh $shim_bin $reco_bin $rootfs_dir
|
||||||
|
|
||||||
echo "building final disk image"
|
echo "building final disk image"
|
||||||
final_image="$base_dir/data/shimboot_$board.bin"
|
final_image="$base_dir/data/shimboot_$board.bin"
|
||||||
|
rm -rf $final_image
|
||||||
./build.sh $final_image $shim_bin data/rootfs
|
./build.sh $final_image $shim_bin data/rootfs
|
||||||
echo "build complete! the final disk image is located at $final_image"
|
echo "build complete! the final disk image is located at $final_image"
|
||||||
|
|
||||||
|
|
|
@ -29,11 +29,13 @@ fi
|
||||||
assert_deps "realpath debootstrap"
|
assert_deps "realpath debootstrap"
|
||||||
parse_args "$@"
|
parse_args "$@"
|
||||||
|
|
||||||
rootfs_dir=$(realpath "${1}")
|
rootfs_dir=$(realpath -m "${1}")
|
||||||
release_name="${2}"
|
release_name="${2}"
|
||||||
packages="${args['custom_packages']-'task-xfce-desktop'}"
|
packages="${args['custom_packages']-'task-xfce-desktop'}"
|
||||||
chroot_mounts="proc sys dev run"
|
chroot_mounts="proc sys dev run"
|
||||||
|
|
||||||
|
mkdir -p $rootfs_dir
|
||||||
|
|
||||||
unmount_all() {
|
unmount_all() {
|
||||||
for mountpoint in $chroot_mounts; do
|
for mountpoint in $chroot_mounts; do
|
||||||
umount -l "$rootfs_dir/$mountpoint"
|
umount -l "$rootfs_dir/$mountpoint"
|
||||||
|
|
Loading…
Reference in New Issue