2023-10-23 13:27:23 +03:00
|
|
|
#!/bin/bash
|
|
|
|
|
2024-04-24 01:27:59 +03:00
|
|
|
if [ -z $BANAN_DISK_IMAGE_PATH ]; then
|
2023-10-23 13:27:23 +03:00
|
|
|
echo "You must set the BANAN_DISK_IMAGE_PATH environment variable" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2024-04-24 01:27:59 +03:00
|
|
|
if [ -z $BANAN_SYSROOT_TAR ]; then
|
2023-11-04 17:50:43 +02:00
|
|
|
echo "You must set the BANAN_SYSROOT_TAR environment variable" >&2
|
2023-10-23 13:27:23 +03:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2024-04-24 01:27:59 +03:00
|
|
|
if [ -z $BANAN_BUILD_DIR ]; then
|
2023-11-20 14:12:35 +02:00
|
|
|
echo "You must set the BANAN_BUILD_DIR environment variable" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2024-04-24 01:27:59 +03:00
|
|
|
if [ "$1" == "full" ] || [ ! -f $BANAN_DISK_IMAGE_PATH ]; then
|
2024-08-22 14:23:16 +03:00
|
|
|
$BANAN_SCRIPT_DIR/image-create.sh || exit 1
|
2023-10-23 13:27:23 +03:00
|
|
|
fi
|
|
|
|
|
2024-04-24 01:27:59 +03:00
|
|
|
set -u
|
2023-10-23 13:27:23 +03:00
|
|
|
|
2024-04-24 01:27:59 +03:00
|
|
|
MOUNT_DIR="$BANAN_BUILD_DIR/mount"
|
|
|
|
mkdir -p $MOUNT_DIR
|
2023-11-20 13:24:15 +02:00
|
|
|
|
2024-04-24 01:27:59 +03:00
|
|
|
LOOP_DEV="$(sudo losetup --show -Pf $BANAN_DISK_IMAGE_PATH || exit 1)"
|
|
|
|
ROOT_PARTITION="${LOOP_DEV}p2"
|
|
|
|
if [ ! -b $ROOT_PARTITION ]; then
|
|
|
|
echo "Failed to probe partitions for banan disk image." >&2
|
|
|
|
sudo losetup -d $LOOP_DEV
|
|
|
|
exit 1
|
|
|
|
fi
|
2023-10-23 13:27:23 +03:00
|
|
|
|
2024-06-29 22:12:36 +03:00
|
|
|
if sudo mount $ROOT_PARTITION $MOUNT_DIR; then
|
|
|
|
cd $MOUNT_DIR
|
|
|
|
sudo tar xf $BANAN_SYSROOT_TAR
|
|
|
|
cd
|
|
|
|
|
|
|
|
sudo umount $MOUNT_DIR
|
|
|
|
fi
|
2023-10-23 13:27:23 +03:00
|
|
|
|
2024-04-24 01:27:59 +03:00
|
|
|
sudo losetup -d $LOOP_DEV
|