From 8f412ba1b1bfa68cccf11b84707e885458b7b269 Mon Sep 17 00:00:00 2001 From: ading2210 Date: Mon, 2 Oct 2023 12:06:06 -0700 Subject: [PATCH] check dependencies in build.sh --- bootloader/{ => bin}/bootstrap.sh | 4 ---- bootloader/{ => bin}/init.sh | 0 build.sh | 23 ++++++++++++++++++++--- patch_initramfs.sh | 7 ++++--- 4 files changed, 24 insertions(+), 10 deletions(-) rename bootloader/{ => bin}/bootstrap.sh (94%) rename bootloader/{ => bin}/init.sh (100%) diff --git a/bootloader/bootstrap.sh b/bootloader/bin/bootstrap.sh similarity index 94% rename from bootloader/bootstrap.sh rename to bootloader/bin/bootstrap.sh index df30f4d..2c81ec3 100644 --- a/bootloader/bootstrap.sh +++ b/bootloader/bin/bootstrap.sh @@ -29,10 +29,6 @@ enable_debug_console() { main() { - # Setup environment. - #kill_frecon - #tty_init - info "...:::||| Bootstrapping ChromeOS Factory Shim |||:::..." info "TTY: ${TTY}, LOG: ${LOG_TTY}, INFO: ${INFO_TTY}, DEBUG: ${DEBUG_TTY}" echo "idk please work" diff --git a/bootloader/init.sh b/bootloader/bin/init.sh similarity index 100% rename from bootloader/init.sh rename to bootloader/bin/init.sh diff --git a/build.sh b/build.sh index 8bf94b2..fa9c224 100755 --- a/build.sh +++ b/build.sh @@ -11,9 +11,18 @@ print_help() { echo "Usage: ./build.sh path_to_shim" } +check_deps() { + local needed_commands="cpio binwalk pcregrep" + for command in $needed_commands; do + if ! command -v $command &> /dev/null; then + echo $command + fi + done +} + create_loop() { local loop_device=$(losetup -f) - losetup -P $loop_device $1 + losetup -P $loop_device "${1}" echo $loop_device } @@ -27,10 +36,18 @@ if [ -z "$1" ]; then exit 1 fi -shim_path=$(realpath $1) +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 + +shim_path=$(realpath "${1}") echo "created loop device for shim" -shim_loop=$(create_loop $shim_path) +shim_loop=$(create_loop "${shim_path}") kernel_loop="${shim_loop}p2" #KERN-A should always be p2 echo "copying shim kernel to new file in /tmp" diff --git a/patch_initramfs.sh b/patch_initramfs.sh index 7f795d6..173de45 100755 --- a/patch_initramfs.sh +++ b/patch_initramfs.sh @@ -10,6 +10,7 @@ fi initramfs_path=$(realpath $1) rm "${initramfs_path}/init" -f -cp bootloader/init.sh "${initramfs_path}/sbin/init" -cp bootloader/bootstrap.sh "${initramfs_path}/sbin/bootstrap.sh" -chmod +x "${initramfs_path}/sbin/*.sh" \ No newline at end of file +cp bootloader/init.sh "${initramfs_path}/bin/init" +cp bootloader/bootstrap.sh "${initramfs_path}/bin/bootstrap.sh" + +find ${initramfs_path}/bin -name "*" -exec chmod +x {} \; \ No newline at end of file