diff --git a/build.sh b/build.sh index a804dd2..71a4d61 100755 --- a/build.sh +++ b/build.sh @@ -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 \ No newline at end of file +losetup -d $shim_loop +losetup -d $image_loop \ No newline at end of file diff --git a/build_image.sh b/build_image.sh index 731a589..71b617e 100755 --- a/build_image.sh +++ b/build_image.sh @@ -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