highlight status messages in the build scripts

This commit is contained in:
ading2210 2024-06-17 17:36:26 -07:00
parent e76d04244f
commit 291f616b6b
4 changed files with 50 additions and 32 deletions

View File

@ -22,32 +22,32 @@ output_path=$(realpath -m "${1}")
shim_path=$(realpath -m "${2}")
rootfs_dir=$(realpath -m "${3}")
echo "reading the shim image"
print_info "reading the shim image"
initramfs_dir=/tmp/shim_initramfs
kernel_img=/tmp/kernel.img
rm -rf $initramfs_dir $kernel_img
extract_initramfs_full $shim_path $initramfs_dir $kernel_img "${args['arch']}"
echo "patching initramfs"
print_info "patching initramfs"
patch_initramfs $initramfs_dir
echo "creating disk image"
print_info "creating disk image"
rootfs_size=$(du -sm $rootfs_dir | cut -f 1)
rootfs_part_size=$(($rootfs_size * 12 / 10 + 5))
#create a 20mb bootloader partition
#rootfs partition is 20% larger than its contents
create_image $output_path 20 $rootfs_part_size
echo "creating loop device for the image"
print_info "creating loop device for the image"
image_loop=$(create_loop ${output_path})
echo "creating partitions on the disk image"
print_info "creating partitions on the disk image"
create_partitions $image_loop $kernel_img
echo "copying data into the image"
print_info "copying data into the image"
populate_partitions $image_loop $initramfs_dir $rootfs_dir "${args['quiet']}"
rm -rf $initramfs_dir $kernel_img
echo "cleaning up loop devices"
print_info "cleaning up loop devices"
losetup -d $image_loop
echo "done"
print_info "done"

View File

@ -37,7 +37,7 @@ arm_boards="
kukui peach-pi peach-pit stumpy daisy-spring
"
if grep -q "$board" <<< "$arm_boards"; then
echo "automatically detected arm64 device name"
print_info "automatically detected arm64 device name"
arch="arm64"
fi
@ -45,7 +45,7 @@ needed_deps="wget python3 unzip zip git debootstrap cpio binwalk pcregrep cgpt m
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"
print_title "attempting to install build deps"
apt-get install wget python3-all unzip zip debootstrap cpio binwalk pcregrep cgpt kmod pv lz4 -y
if [ "$arch" = "arm64" ]; then
apt-get install qemu-user-static binfmt-support -y
@ -72,7 +72,7 @@ else
data_dir="$(realpath -m "$data_dir")"
fi
echo "downloading list of recovery images"
print_title "downloading list of recovery images"
reco_url="$(wget -qO- --show-progress $boards_url | python3 -c '
import json, sys
@ -87,7 +87,7 @@ if "models" in board:
reco_url = list(board["pushRecoveries"].values())[-1]
print(reco_url)
' $board)"
echo "found url: $reco_url"
print_info "found url: $reco_url"
shim_bin="$data_dir/shim_$board.bin"
shim_zip="$data_dir/shim_$board.zip"
@ -109,7 +109,7 @@ download_and_unzip() {
if [ ! -f "$bin_path" ]; then
cleanup_path="$bin_path"
echo "extracting $zip_path"
print_info "extracting $zip_path"
local total_bytes="$(unzip -lq $zip_path | tail -1 | xargs | cut -d' ' -f1)"
if [ ! "$quiet" ]; then
unzip -p $zip_path | pv -s $total_bytes > $bin_path
@ -128,10 +128,10 @@ retry_cmd() {
done
}
echo "downloading recovery image"
print_title "downloading recovery image"
download_and_unzip $reco_url $reco_zip $reco_bin
echo "downloading shim image"
print_title "downloading shim image"
download_and_unzip $shim_url $shim_zip $shim_bin
if [ ! "$rootfs_dir" ]; then
@ -143,7 +143,7 @@ if [ ! "$rootfs_dir" ]; then
rm -rf $rootfs_dir
mkdir -p $rootfs_dir
echo "building debian rootfs"
print_title "building debian rootfs"
./build_rootfs.sh $rootfs_dir $release \
custom_packages=$desktop_package \
hostname=shimboot-$board \
@ -152,22 +152,22 @@ if [ ! "$rootfs_dir" ]; then
arch=$arch
fi
echo "patching debian rootfs"
print_title "patching debian rootfs"
retry_cmd ./patch_rootfs.sh $shim_bin $reco_bin $rootfs_dir "quiet=$quiet"
echo "building final disk image"
print_title "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" "arch=$arch"
echo "build complete! the final disk image is located at $final_image"
print_info "build complete! the final disk image is located at $final_image"
echo "cleaning up"
print_title "cleaning up"
clean_loops
if [ "$compress_img" ]; then
image_zip="$data_dir/shimboot_$board.zip"
echo "compressing disk image into a zip file"
print_title "compressing disk image into a zip file"
zip -j $image_zip $final_image
echo "finished compressing the disk file"
echo "the finished zip file can be found at $image_zip"
print_info "finished compressing the disk file"
print_info "the finished zip file can be found at $image_zip"
fi

View File

@ -50,19 +50,19 @@ root_squashfs="$rootfs_dir/root.squashfs"
modules_squashfs="$rootfs_dir/modules.squashfs"
unionfs_dir="/tmp/unionfs-fuse"
echo "compiling unionfs-fuse"
print_info "compiling unionfs-fuse"
compile_unionfs $unionfs_dir/unionfs $unionfs_dir
echo "reading the shim image"
print_info "reading the shim image"
extract_initramfs_full $shim_path $rootfs_dir
rm -rf $rootfs_dir/init
echo "compressing old rootfs"
print_info "compressing old rootfs"
mksquashfs $old_dir $root_squashfs -noappend -comp gzip
echo "patching new rootfs"
print_info "patching new rootfs"
mv $unionfs_dir/unionfs $rootfs_dir/bin/unionfs
cp -ar squashfs/* $rootfs_dir/
chmod +x $rootfs_dir/bin/*
echo "done"
print_info "done"

View File

@ -6,6 +6,12 @@ if [ "$DEBUG" ]; then
export DEBUG=1
fi
ANSI_CLEAR='\033[0m'
ANSI_BOLD='\033[1m'
ANSI_RED='\033[1;31m'
ANSI_GREEN='\033[1;32m'
ANSI_BLUE='\033[1;34m'
check_deps() {
local needed_commands="$1"
for command in $needed_commands; do
@ -19,9 +25,9 @@ assert_deps() {
local needed_commands="$1"
local missing_commands=$(check_deps "$needed_commands")
if [ "${missing_commands}" ]; then
echo "You are missing dependencies needed for this script."
echo "Commands needed:"
echo "${missing_commands}"
print_error "You are missing dependencies needed for this script."
print_error "Commands needed:"
print_error "${missing_commands}"
exit 1
fi
}
@ -43,7 +49,7 @@ parse_args() {
assert_root() {
if [ "$EUID" -ne 0 ]; then
echo "this needs to be run as root."
print_error "This script needs to be run as root."
exit 1
fi
}
@ -54,3 +60,15 @@ assert_args() {
exit 1
fi
}
print_title() {
printf ">> ${ANSI_GREEN}${1}${ANSI_CLEAR}\n"
}
print_info() {
printf "${ANSI_BOLD}${1}${ANSI_CLEAR}\n"
}
print_error() {
printf "${ANSI_RED}${1}${ANSI_CLEAR}\n"
}