check dependencies in build.sh

This commit is contained in:
ading2210 2023-10-02 12:06:06 -07:00
parent fc4c6b5e51
commit 8f412ba1b1
4 changed files with 24 additions and 10 deletions

View File

@ -29,10 +29,6 @@ enable_debug_console() {
main() { main() {
# Setup environment.
#kill_frecon
#tty_init
info "...:::||| Bootstrapping ChromeOS Factory Shim |||:::..." info "...:::||| Bootstrapping ChromeOS Factory Shim |||:::..."
info "TTY: ${TTY}, LOG: ${LOG_TTY}, INFO: ${INFO_TTY}, DEBUG: ${DEBUG_TTY}" info "TTY: ${TTY}, LOG: ${LOG_TTY}, INFO: ${INFO_TTY}, DEBUG: ${DEBUG_TTY}"
echo "idk please work" echo "idk please work"

View File

@ -11,9 +11,18 @@ print_help() {
echo "Usage: ./build.sh path_to_shim" 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() { create_loop() {
local loop_device=$(losetup -f) local loop_device=$(losetup -f)
losetup -P $loop_device $1 losetup -P $loop_device "${1}"
echo $loop_device echo $loop_device
} }
@ -27,10 +36,18 @@ if [ -z "$1" ]; then
exit 1 exit 1
fi 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" 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 kernel_loop="${shim_loop}p2" #KERN-A should always be p2
echo "copying shim kernel to new file in /tmp" echo "copying shim kernel to new file in /tmp"

View File

@ -10,6 +10,7 @@ fi
initramfs_path=$(realpath $1) initramfs_path=$(realpath $1)
rm "${initramfs_path}/init" -f rm "${initramfs_path}/init" -f
cp bootloader/init.sh "${initramfs_path}/sbin/init" cp bootloader/init.sh "${initramfs_path}/bin/init"
cp bootloader/bootstrap.sh "${initramfs_path}/sbin/bootstrap.sh" cp bootloader/bootstrap.sh "${initramfs_path}/bin/bootstrap.sh"
chmod +x "${initramfs_path}/sbin/*.sh"
find ${initramfs_path}/bin -name "*" -exec chmod +x {} \;