From f8854734888ef5baf8a98becc63fc4a3d3da622f Mon Sep 17 00:00:00 2001 From: ading2210 Date: Tue, 11 Jun 2024 22:27:19 -0700 Subject: [PATCH] add arm support to other build scripts --- build_complete.sh | 7 +++++-- build_rootfs.sh | 7 +++++-- rootfs/opt/setup_rootfs.sh | 4 +++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/build_complete.sh b/build_complete.sh index 493f8f9..2c46ffe 100755 --- a/build_complete.sh +++ b/build_complete.sh @@ -12,6 +12,7 @@ print_help() { echo " desktop - The desktop environment to install. This defaults to 'xfce'. Valid options include:" echo " gnome, xfce, kde, lxde, gnome-flashback, cinnamon, mate, lxqt" echo " data_dir - The working directory for the scripts. This defaults to ./data" + echo " arch - The CPU architecture to build the shimboot image for. Set this to 'arm64' if you have an ARM Chromebook." } assert_root @@ -23,6 +24,7 @@ rootfs_dir="${args['rootfs_dir']}" quiet="${args['quiet']}" desktop="${args['desktop']-'xfce'}" data_dir="${args['data_dir']}" +arch="${args['arch']-'amd64'}" needed_deps="wget python3 unzip zip git debootstrap cpio binwalk pcregrep cgpt mkfs.ext4 mkfs.ext2 fdisk rsync depmod findmnt" if [ "$(check_deps "$needed_deps")" ]; then @@ -130,7 +132,8 @@ if [ ! "$rootfs_dir" ]; then custom_packages=$desktop_package \ hostname=shimboot-$board \ username=user \ - user_passwd=user + user_passwd=user \ + arch=$arch fi echo "patching debian rootfs" @@ -139,7 +142,7 @@ retry_cmd ./patch_rootfs.sh $shim_bin $reco_bin $rootfs_dir "quiet=$quiet" echo "building final disk image" final_image="$data_dir/shimboot_$board.bin" rm -rf $final_image -retry_cmd ./build.sh $final_image $shim_bin $rootfs_dir "quiet=$quiet" +retry_cmd ./build.sh $final_image $shim_bin $rootfs_dir "quiet=$quiet" "arch=$arch" echo "build complete! the final disk image is located at $final_image" echo "cleaning up" diff --git a/build_rootfs.sh b/build_rootfs.sh index 0964d30..5c3d975 100755 --- a/build_rootfs.sh +++ b/build_rootfs.sh @@ -19,6 +19,7 @@ print_help() { echo " username - The unprivileged user name for the new rootfs." echo " user_passwd - The password for the unprivileged user." echo " disable_base - Disable the base packages such as zram, cloud-utils, and command-not-found." + echo " arch - The CPU architecture to build the rootfs for." echo "If you do not specify the hostname and credentials, you will be prompted for them later." } @@ -30,6 +31,7 @@ parse_args "$@" rootfs_dir=$(realpath -m "${1}") release_name="${2}" packages="${args['custom_packages']-'task-xfce-desktop'}" +arch="${args['arch']-'amd64'}" chroot_mounts="proc sys dev run" mkdir -p $rootfs_dir @@ -56,7 +58,7 @@ if [ "$(need_remount "$rootfs_dir")" ]; then do_remount "$rootfs_dir" fi -debootstrap --arch amd64 $release_name $rootfs_dir http://deb.debian.org/debian/ +debootstrap --arch $arch $release_name $rootfs_dir http://deb.debian.org/debian/ cp -ar rootfs/* $rootfs_dir cp /etc/resolv.conf $rootfs_dir/etc/resolv.conf @@ -75,7 +77,8 @@ disable_base="${args['disable_base']}" chroot_command="/opt/setup_rootfs.sh \ '$DEBUG' '$release_name' '$packages' \ '$hostname' '$root_passwd' '$username' \ - '$user_passwd' '$enable_root' '$disable_base'" + '$user_passwd' '$enable_root' '$disable_base' \ + '$arch'" LC_ALL=C chroot $rootfs_dir /bin/bash -c "${chroot_command}" diff --git a/rootfs/opt/setup_rootfs.sh b/rootfs/opt/setup_rootfs.sh index fe57fcc..fc2633d 100755 --- a/rootfs/opt/setup_rootfs.sh +++ b/rootfs/opt/setup_rootfs.sh @@ -18,10 +18,11 @@ username="$6" user_passwd="$7" enable_root="$8" disable_base_pkgs="$9" +arch="${10}" custom_repo="https://shimboot.ading.dev/debian" custom_repo_domain="shimboot.ading.dev" -sources_entry="deb [trusted=yes arch=amd64] ${custom_repo} ${release_name} main" +sources_entry="deb [trusted=yes arch=$arch] ${custom_repo} ${release_name} main" export DEBIAN_FRONTEND="noninteractive" @@ -37,6 +38,7 @@ END apt-get install -y ca-certificates apt-get update installed_systemd="$(dpkg-query -W -f='${binary:Package}\n' | grep "systemd")" +apt-get clean apt-get install --reinstall $installed_systemd #enable shimboot services