mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 02:11:53 +00:00
feature: 0.3.2 -> 0.3.3 upgrade (#1958)
* 0.3.2 -> 0.3.3 upgrade script * fix upgrade * integrated image * fix rip-image * no U option on older rsync * permissions and cleanup * fixes * label fs * fix progress reporting * only create rootfs for lite upgrade * shrink image after creating * fix for `blue` partitions
This commit is contained in:
47
build/raspberry-pi/make-upgrade-image.sh
Executable file
47
build/raspberry-pi/make-upgrade-image.sh
Executable file
@@ -0,0 +1,47 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
function partition_for () {
|
||||
if [[ "$1" =~ [0-9]+$ ]]; then
|
||||
echo "$1p$2"
|
||||
else
|
||||
echo "$1$2"
|
||||
fi
|
||||
}
|
||||
|
||||
TARGET_NAME=lite-upgrade.img
|
||||
TARGET_SIZE=7000000000
|
||||
|
||||
LOOPDEV=$(sudo losetup --show -fP raspios.img)
|
||||
sudo cat `partition_for ${LOOPDEV} 2` > $TARGET_NAME
|
||||
sudo losetup -d $LOOPDEV
|
||||
truncate -s $TARGET_SIZE $TARGET_NAME
|
||||
sudo e2fsck -f -y $TARGET_NAME
|
||||
sudo resize2fs $TARGET_NAME
|
||||
|
||||
TMPDIR=$(mktemp -d)
|
||||
mkdir $TMPDIR/target
|
||||
mkdir $TMPDIR/source
|
||||
|
||||
sudo mount update.img $TMPDIR/source
|
||||
|
||||
sudo mount $TARGET_NAME $TMPDIR/target
|
||||
|
||||
sudo mkdir -p $TMPDIR/target/update
|
||||
sudo rsync -acvAXH $TMPDIR/source/ $TMPDIR/target/update/
|
||||
sudo cp ./build/raspberry-pi/033-upgrade.sh $TMPDIR/target/usr/local/bin/033-upgrade.sh
|
||||
sudo cp ./build/raspberry-pi/033-upgrade.service $TMPDIR/target/etc/systemd/system/033-upgrade.service
|
||||
sudo ln -s /etc/systemd/system/033-upgrade.service $TMPDIR/target/etc/systemd/system/multi-user.target.wants/033-upgrade.service
|
||||
sudo cp ./build/raspberry-pi/nc-broadcast.service $TMPDIR/target/etc/systemd/system/nc-broadcast.service
|
||||
sudo ln -s /etc/systemd/system/nc-broadcast.service $TMPDIR/target/etc/systemd/system/multi-user.target.wants/nc-broadcast.service
|
||||
|
||||
sudo umount $TMPDIR/target
|
||||
|
||||
sudo e2fsck -f -y $TARGET_NAME
|
||||
sudo resize2fs -M $TARGET_NAME
|
||||
BLOCK_INFO=$(sudo dumpe2fs $TARGET_NAME)
|
||||
BLOCK_COUNT=$(echo "$BLOCK_INFO" | grep "Block count:" | sed 's/Block count:\s\+//g')
|
||||
BLOCK_SIZE=$(echo "$BLOCK_INFO" | grep "Block size:" | sed 's/Block size:\s\+//g')
|
||||
FS_SIZE=$[$BLOCK_COUNT*$BLOCK_SIZE]
|
||||
truncate -s $FS_SIZE $TARGET_NAME
|
||||
Reference in New Issue
Block a user