working automatic partition update
Signed-off-by: Michel Stempin <michel.stempin@wanadoo.fr>
This commit is contained in:
parent
115b031565
commit
332feb6fe9
|
@ -49,6 +49,12 @@ mount_share () {
|
||||||
|
|
||||||
# Create the directory structure if required
|
# Create the directory structure if required
|
||||||
(cd /mnt; mkdir -p "Atari lynx" "Game Boy" "Game Boy Color" "Game Boy Advance" "Game Gear" "Neo Geo Pocket" "NES" "PS1" "Sega Genesis" "Sega Master System" "SNES" "WonderSwan")
|
(cd /mnt; mkdir -p "Atari lynx" "Game Boy" "Game Boy Color" "Game Boy Advance" "Game Gear" "Neo Geo Pocket" "NES" "PS1" "Sega Genesis" "Sega Master System" "SNES" "WonderSwan")
|
||||||
|
|
||||||
|
# Check if there is an updte file
|
||||||
|
if [ -f /mnt/FunKey-*.swu ]; then
|
||||||
|
warn "found an update file, going into recovery mode"
|
||||||
|
recovery_mode
|
||||||
|
fi
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +79,7 @@ stop_share () {
|
||||||
# Stop sharing the backing store partition
|
# Stop sharing the backing store partition
|
||||||
echo > $BACKING_STORE_FILE || die 11 "the backing store partition is still mounted on host"
|
echo > $BACKING_STORE_FILE || die 11 "the backing store partition is still mounted on host"
|
||||||
|
|
||||||
# 3) Mount the backing store partition locally
|
# Mount the backing store partition locally
|
||||||
mount_share
|
mount_share
|
||||||
|
|
||||||
info "stopped sharing the backing store partition"
|
info "stopped sharing the backing store partition"
|
||||||
|
|
|
@ -2,13 +2,21 @@ software =
|
||||||
{
|
{
|
||||||
version = "0.6";
|
version = "0.6";
|
||||||
|
|
||||||
hardware-compatibility = [ "#RE:^Rev\.[A-E]$" ];
|
hardware-compatibility = [ "#RE:^Rev\.[D-E]$" ];
|
||||||
|
|
||||||
images: (
|
images: (
|
||||||
{
|
{
|
||||||
filename = "rootfs.ext2.tar.gz";
|
filename = "rootfs.ext2.gz";
|
||||||
device = "/dev/mmcblk0p2";
|
device = "/dev/mmcblk0p2";
|
||||||
compression = "zlib";
|
type = "raw";
|
||||||
|
installed-directly = true;
|
||||||
|
compressed = "zlib";
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
scripts: (
|
||||||
|
{
|
||||||
|
filename = "update_partition";
|
||||||
|
type = "shellscript";
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,77 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# Update partition script
|
||||||
|
|
||||||
|
source /usr/local/lib/utils
|
||||||
|
|
||||||
|
root_part_num=2
|
||||||
|
root_part=/dev/mmcblk0p${root_part_num}
|
||||||
|
root_mount=/tmp/rootfs
|
||||||
|
|
||||||
|
do_preinst()
|
||||||
|
{
|
||||||
|
notif "1/7 Extract update"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
do_postinst()
|
||||||
|
{
|
||||||
|
local version
|
||||||
|
|
||||||
|
notif "2/7 Resize root filesystem"
|
||||||
|
resize2fs ${root_part} >/dev/null 2>&1
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
notif "Cannot resize root filesystem"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
notif "3/7 Mount root filesystem"
|
||||||
|
mkdir -p ${root_mount}
|
||||||
|
mount -t ext4 ${root_part} ${root_mount} >/dev/null 2>&1
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
notif "Cannot mount root filesystem"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
notif "4/7 Create swap"
|
||||||
|
|
||||||
|
# Create an empty 128MB /swap file, change its permissions and format it as swap
|
||||||
|
dd if=/dev/zero of=${root_mount}/swap bs=1M count=128 >/dev/null 2>&1 &&
|
||||||
|
chmod 0600 ${root_mount}/swap >/dev/null 2>&1 &&
|
||||||
|
mkswap ${root_mount}/swap >/dev/null 2>&1
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
rm ${root_mount}/swap
|
||||||
|
umount ${root_mount} >/dev/null 2>&1
|
||||||
|
notif "Cannot create swap file"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
notif "5/7 Unmount root filesystem"
|
||||||
|
umount ${root_mount} >/dev/null 2>&1
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
notif "Cannot unmount root filesystem"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
for file in /mnt/FunKey-*.swu; do
|
||||||
|
version=$(basename "${file}" .swu | cut -d '-' -f 2)
|
||||||
|
notif "6/7 Setting rootfs version to ${version}"
|
||||||
|
sed -i '/^rootfs/d' /etc/sw-versions
|
||||||
|
notif "7/7 Erase update file"
|
||||||
|
echo -e "rootfs\t${version}" >> /etc/sw-versions
|
||||||
|
rm -f "${file}"
|
||||||
|
done
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
echo $0 $1
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
preinst)
|
||||||
|
notif "call do_preinst"
|
||||||
|
do_preinst
|
||||||
|
;;
|
||||||
|
postinst)
|
||||||
|
notif "call do_postinst"
|
||||||
|
do_postinst
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
notif "default"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
14
Makefile
14
Makefile
|
@ -33,7 +33,7 @@ TERM_RESET := $(shell tput rmso 2>/dev/null)
|
||||||
|
|
||||||
.IGNORE: _Makefile_
|
.IGNORE: _Makefile_
|
||||||
|
|
||||||
all: update
|
all: image update
|
||||||
@:
|
@:
|
||||||
|
|
||||||
_Makefile_:
|
_Makefile_:
|
||||||
|
@ -42,10 +42,10 @@ _Makefile_:
|
||||||
%/Makefile:
|
%/Makefile:
|
||||||
@:
|
@:
|
||||||
|
|
||||||
buildroot: buildroot/README
|
buildroot: buildroot/.git
|
||||||
@:
|
@:
|
||||||
|
|
||||||
buildroot/README:
|
buildroot/.git:
|
||||||
@$(call MESSAGE,"Getting buildroot")
|
@$(call MESSAGE,"Getting buildroot")
|
||||||
@git submodule init
|
@git submodule init
|
||||||
@git submodule update
|
@git submodule update
|
||||||
|
@ -86,9 +86,13 @@ update: fun
|
||||||
@rm -rf tmp
|
@rm -rf tmp
|
||||||
@mkdir -p tmp
|
@mkdir -p tmp
|
||||||
@cp FunKey/board/funkey/sw-description tmp/
|
@cp FunKey/board/funkey/sw-description tmp/
|
||||||
@tar -C FunKey/output/images -zcf tmp/rootfs.ext2.tar.gz rootfs.ext2
|
@cp FunKey/board/funkey/update_partition tmp/
|
||||||
|
@cd FunKey/output/images && \
|
||||||
|
rm -f rootfs.ext2.gz && \
|
||||||
|
gzip -k rootfs.ext2 &&\
|
||||||
|
mv rootfs.ext2.gz ../../../tmp/
|
||||||
@cd tmp && \
|
@cd tmp && \
|
||||||
echo sw-description rootfs.ext2.tar.gz | \
|
echo sw-description rootfs.ext2.gz update_partition | \
|
||||||
tr " " "\n" | \
|
tr " " "\n" | \
|
||||||
cpio -o -H crc --quiet > ../images/FunKey-$(shell cat FunKey/board/funkey/rootfs-overlay/etc/sw-versions | cut -f 2).swu
|
cpio -o -H crc --quiet > ../images/FunKey-$(shell cat FunKey/board/funkey/rootfs-overlay/etc/sw-versions | cut -f 2).swu
|
||||||
@rm -rf tmp
|
@rm -rf tmp
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
THIS=$(basename $0)
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
start)
|
||||||
|
for file in /mnt/FunKey-*.swu; do
|
||||||
|
swupdate -v -i "${file}"
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
share start
|
||||||
|
mkdir -p /run/network
|
||||||
|
/sbin/ifup -a
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
normal_mode
|
||||||
|
;;
|
||||||
|
stop)
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Usage: $0 {start|stop}" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
Loading…
Reference in New Issue