From 791de1929731f457ef789a7d7e5894cadab090df Mon Sep 17 00:00:00 2001 From: ading2210 Date: Tue, 3 Oct 2023 10:39:24 -0700 Subject: [PATCH] check if binwalk has already been run --- bootloader/bin/bootstrap.sh | 6 +++--- build.sh | 13 ++++++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/bootloader/bin/bootstrap.sh b/bootloader/bin/bootstrap.sh index 2c81ec3..8766bf5 100644 --- a/bootloader/bin/bootstrap.sh +++ b/bootloader/bin/bootstrap.sh @@ -23,14 +23,14 @@ invoke_terminal() { enable_debug_console() { local tty="$1" - info -e '\033[1;33m[cros_debug] enabled on '${tty}'.\033[m' + echo -e '\033[1;33m[cros_debug] enabled on '${tty}'.\033[m' invoke_terminal "${tty}" "[Bootstrap Debug Console]" "/bin/busybox sh" } main() { - info "...:::||| Bootstrapping ChromeOS Factory Shim |||:::..." - info "TTY: ${TTY}, LOG: ${LOG_TTY}, INFO: ${INFO_TTY}, DEBUG: ${DEBUG_TTY}" + echo "...:::||| Bootstrapping ChromeOS Factory Shim |||:::..." + echo "TTY: ${TTY}, LOG: ${LOG_TTY}, echo: ${echo_TTY}, DEBUG: ${DEBUG_TTY}" echo "idk please work" enable_debug_console "/dev/pts/0" diff --git a/build.sh b/build.sh index c99c0e5..692cdd3 100755 --- a/build.sh +++ b/build.sh @@ -50,20 +50,27 @@ kernel_loop="${shim_loop}p2" #KERN-A should always be p2 echo "copying shim kernel to new file in /tmp" kernel_dir=/tmp/shim_kernel -rm -rf $kernel_dir mkdir $kernel_dir -p dd if=$kernel_loop of=$kernel_dir/kernel.bin bs=1M status=none echo "extracting data from kernel" previous_dir=$(pwd) cd $kernel_dir -binwalk_out=$(binwalk --extract kernel.bin --run-as=root) +if [ -e "${kernel_dir}/binwalk.out" ]; then + #don't run binwalk again if we don't need to + binwalk_out=$(cat $kernel_dir/binwalk.out) +else + binwalk_out=$(binwalk --extract kernel.bin --run-as=root) + echo $binwalk_out > $kernel_dir/binwalk.out +fi #i can't be bothered to learn how to use sed extracted_file=$(echo $binwalk_out | pcregrep -o1 "\d+\s+0x([0-9A-F]+)\s+gzip compressed data") echo "extracting initramfs archive from kernel (this may take a while)" cd _kernel.bin.extracted/ -binwalk --extract $extracted_file --run-as=root > /dev/null +if [ ! -e "_${extracted_file}.extracted/" ]; then + binwalk --extract $extracted_file --run-as=root > /dev/null +fi cd "_${extracted_file}.extracted/" cpio_file=$(file ./* | pcregrep -o1 "([0-9A-F]+):\s+ASCII cpio archive")