add the image builder to the main build.sh

This commit is contained in:
ading2210 2023-10-02 15:57:49 -07:00
parent 7313d20584
commit 2db4cdc814
2 changed files with 24 additions and 4 deletions

View File

@ -11,11 +11,11 @@ fi
. ./build_image.sh
print_help() {
echo "Usage: ./build.sh path_to_shim"
echo "Usage: ./build.sh output_path shim_path"
}
check_deps() {
local needed_commands="cpio binwalk pcregrep cgpt realpath"
local needed_commands="cpio binwalk pcregrep realpath"
for command in $needed_commands; do
if ! command -v $command &> /dev/null; then
echo $command
@ -41,7 +41,8 @@ if [ "${missing_commands}" ]; then
exit 1
fi
shim_path=$(realpath "${1}")
output_path=$(realpath "${1}")
shim_path=$(realpath "${2}")
echo "created loop device for shim"
shim_loop=$(create_loop "${shim_path}")
@ -78,5 +79,22 @@ cd $previous_dir
echo "patching initramfs"
patch_initramfs $initramfs_dir
echo "creating disk image"
create_image $output_path 20 200
echo "creating loop device for the image"
image_loop=$(create_loop ${output_path})
echo "creating partitions on the disk image"
create_partitions $image_loop "${kernel_dir}/kernel.bin"
echo "copying data into the image"
rootfs_dir=/tmp/rootfs
rm $rootfs_dir -rf
mkdir $rootfs_dir
touch $rootfs_dir/testfile
populate_partitions $image_loop $initramfs_dir $rootfs_dir
echo "cleaning up loop devices"
losetup -d $shim_loop
losetup -d $shim_loop
losetup -d $image_loop

View File

@ -11,6 +11,7 @@ create_loop() {
echo $loop_device
}
#useful in the future... maybe
make_mountable() {
sh lib/ssd_util.sh --no_resign_kernel --remove_rootfs_verification -i $1
printf '\000' | dd of=$1 seek=$((0x464 + 3)) conv=notrunc count=1 bs=1
@ -60,6 +61,7 @@ partition_disk() {
}
safe_mount() {
umount $2 || /bin/true
rm -rf $2
mkdir -p $2
mount $1 $2