initramfs-rauc-slot: support restoring the backup archive
This change adds an initramfs module to mount the data partition and restore the backup to the overlay. It is enabled by adding it to the image-rauc-slot-initramfs recipe. Signed-off-by: Jan Luebbe <jluebbe@debian.org> [hfreyther: keep udev out of the dependencies]
This commit is contained in:
parent
4d66b042e4
commit
5fa7032384
|
@ -1,6 +1,6 @@
|
|||
DESCRIPTION = "slot initramfs"
|
||||
|
||||
PACKAGE_INSTALL = "initramfs-framework-base initramfs-module-debug initramfs-module-rauc-overlay busybox base-passwd ${ROOTFS_BOOTSTRAP_INSTALL}"
|
||||
PACKAGE_INSTALL = "initramfs-framework-base initramfs-module-debug initramfs-module-rauc-overlay initramfs-module-rauc-backup busybox base-passwd ${ROOTFS_BOOTSTRAP_INSTALL}"
|
||||
|
||||
# Do not pollute the initrd image with rootfs features
|
||||
#IMAGE_FEATURES = ""
|
||||
|
|
|
@ -2,12 +2,14 @@ SUMMARY = "Modular initramfs system components for RAUC"
|
|||
LICENSE = "MIT"
|
||||
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
|
||||
|
||||
PR = "r1"
|
||||
PR = "r2"
|
||||
|
||||
inherit allarch
|
||||
|
||||
SRC_URI = "file://overlay \
|
||||
file://rescue"
|
||||
file://rescue \
|
||||
file://mount_data \
|
||||
file://restore_backup"
|
||||
|
||||
do_install() {
|
||||
install -d ${D}/init.d
|
||||
|
@ -17,10 +19,15 @@ do_install() {
|
|||
|
||||
# rescue
|
||||
install -m 0755 ${WORKDIR}/rescue ${D}/init.d/10-rescue
|
||||
|
||||
# backup
|
||||
install -m 0755 ${WORKDIR}/mount_data ${D}/init.d/25-mount_data
|
||||
install -m 0755 ${WORKDIR}/restore_backup ${D}/init.d/26-restore_backup
|
||||
}
|
||||
|
||||
PACKAGES = "initramfs-module-rauc-overlay \
|
||||
initramfs-module-rauc-rescue"
|
||||
initramfs-module-rauc-rescue \
|
||||
initramfs-module-rauc-backup"
|
||||
|
||||
SUMMARY_initramfs-module-rauc-overlay = "initramfs support for overlayfs (ubifs&squashfs)"
|
||||
RDEPENDS_initramfs-module-rauc-overlay = "initramfs-framework-base"
|
||||
|
@ -29,3 +36,7 @@ FILES_initramfs-module-rauc-overlay = "/init.d/20-overlay"
|
|||
SUMMARY_initramfs-module-rauc-rescue = "initramfs rescue mode support"
|
||||
RDEPENDS_initramfs-module-rauc-rescue = "initramfs-framework-base"
|
||||
FILES_initramfs-module-rauc-rescue = "/init.d/10-rescue"
|
||||
|
||||
SUMMARY_initramfs-module-rauc-backup = "initramfs backup restore support"
|
||||
RDEPENDS_initramfs-module-rauc-backup = "initramfs-module-rauc-overlay"
|
||||
FILES_initramfs-module-rauc-backup = "/init.d/25-mount_data /init.d/26-restore_backup"
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
#!/bin/sh
|
||||
|
||||
BACKUP_FILE=/rootfs/data/sysmocom-backup.tar
|
||||
|
||||
restore_backup_enabled() {
|
||||
if [ ! -e "$BACKUP_FILE" ] ; then
|
||||
info "The backup file '$BACKUP_FILE' does not exist, skipping restore..."
|
||||
return 1
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
restore_backup_extract() {
|
||||
# List the files and check if grep hits something
|
||||
SEARCH=`tar -tvf $1 | grep $2`
|
||||
RES=$?
|
||||
if [ $RES = 0 ]; then
|
||||
tar -C /rootfs/tmp/ -xvf $1 $2
|
||||
cp -a /rootfs/tmp/content/* /rootfs/
|
||||
rm -rf /rootfs/tmp/content
|
||||
else
|
||||
echo "Directory '$2' is not in backup '$1'."
|
||||
fi
|
||||
}
|
||||
|
||||
restore_backup_run() {
|
||||
info "Extracting files from the backup '$BACKUP_FILE'"
|
||||
restore_backup_extract $BACKUP_FILE content/etc || fatal "Failed!"
|
||||
restore_backup_extract $BACKUP_FILE content/var/lib/osmocom || fatal "Failed!"
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
#!/bin/sh
|
||||
|
||||
mount_data_enabled() {
|
||||
return 0
|
||||
}
|
||||
|
||||
mount_data_run() {
|
||||
info "Mounting data..."
|
||||
mkdir -p /rootfs/data
|
||||
mount -t ubifs ubi0:data /rootfs/data
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
#!/bin/sh
|
||||
|
||||
mount_data_enabled() {
|
||||
return 0
|
||||
}
|
||||
|
||||
mount_data_run() {
|
||||
info "Mounting data..."
|
||||
mkdir -p /rootfs/data
|
||||
mount -t ext4 /dev/sda4 /rootfs/data
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
#!/bin/sh
|
||||
|
||||
mount_data_enabled() {
|
||||
return 0
|
||||
}
|
||||
|
||||
mount_data_run() {
|
||||
info "Mounting data..."
|
||||
mkdir -p /rootfs/data
|
||||
mount -t ubifs ubi0:data /rootfs/data
|
||||
}
|
Loading…
Reference in New Issue