don't modify shim and reco images at all

This commit is contained in:
ading2210 2024-05-13 11:03:17 -07:00
parent 16000d09e2
commit f9b3383698
3 changed files with 20 additions and 10 deletions

View File

@ -1,6 +1,7 @@
#!/bin/bash #!/bin/bash
. ./common.sh . ./common.sh
. ./image_utils.sh
print_help() { print_help() {
echo "Usage: ./build_complete.sh board_name" echo "Usage: ./build_complete.sh board_name"
@ -138,6 +139,9 @@ 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"
echo "build complete! the final disk image is located at $final_image" echo "build complete! the final disk image is located at $final_image"
echo "cleaning up"
clean_loops
if [ "$compress_img" ]; then if [ "$compress_img" ]; then
image_zip="$data_dir/shimboot_$board.zip" image_zip="$data_dir/shimboot_$board.zip"
echo "compressing disk image into a zip file" echo "compressing disk image into a zip file"

View File

@ -12,11 +12,6 @@ create_loop() {
echo $loop_device echo $loop_device
} }
#original shim rootfses have a non standard ext2 filesystem
make_mountable() {
printf '\000' | dd of=$1 seek=$((0x464 + 3)) conv=notrunc count=1 bs=1 status=none
}
#set required flags on the kernel partition #set required flags on the kernel partition
make_bootable() { make_bootable() {
cgpt add -i 2 -S 1 -T 5 -P 10 -l kernel $1 cgpt add -i 2 -S 1 -T 5 -P 10 -l kernel $1
@ -79,7 +74,7 @@ safe_mount() {
rm -rf $dest rm -rf $dest
mkdir -p $dest mkdir -p $dest
if [ "$opts" ]; then if [ "$opts" ]; then
mount $source $dest -o $dest mount $source $dest -o $opts
else else
mount $source $dest mount $source $dest
fi fi
@ -151,4 +146,17 @@ patch_initramfs() {
cp -r bootloader/* "${initramfs_path}/" cp -r bootloader/* "${initramfs_path}/"
find ${initramfs_path}/bin -name "*" -exec chmod +x {} \; find ${initramfs_path}/bin -name "*" -exec chmod +x {} \;
}
#clean up unused loop devices
clean_loops() {
local loop_devices="$(losetup -a | awk -F':' {'print $1'})"
for loop_device in $loop_devices; do
local mountpoints="$(cat /proc/mounts | grep "$loop_device")"
if [ ! "$mountpoints" ]; then
losetup -d $loop_device
else
echo "warning: not removing $loop_device because it is still mounted"
fi
done
} }

View File

@ -67,13 +67,11 @@ reco_rootfs="/tmp/reco_rootfs"
echo "mounting shim" echo "mounting shim"
shim_loop=$(create_loop "${shim_path}") shim_loop=$(create_loop "${shim_path}")
make_mountable "${shim_loop}p3" safe_mount "${shim_loop}p3" $shim_rootfs ro
safe_mount "${shim_loop}p3" $shim_rootfs
echo "mounting recovery image" echo "mounting recovery image"
reco_loop=$(create_loop "${reco_path}") reco_loop=$(create_loop "${reco_path}")
make_mountable "${reco_loop}p3" safe_mount "${reco_loop}p3" $reco_rootfs ro
safe_mount "${reco_loop}p3" $reco_rootfs
echo "copying modules to rootfs" echo "copying modules to rootfs"
copy_modules $shim_rootfs $reco_rootfs $target_rootfs copy_modules $shim_rootfs $reco_rootfs $target_rootfs