Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions recipes-core/images/aos-image-initramfs.bb
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ AOS_INITRAMFS_SCRIPTS ?= " \
initramfs-module-vardir \
"

RRECOMMENDS:${PN} = " \
kernel-module-overlay \
kernel-module-squashfs \
"

# Don't allow the initramfs to contain a kernel
PACKAGE_EXCLUDE = "kernel-image-*"

Expand Down
71 changes: 71 additions & 0 deletions recipes-core/initrdscripts/initramfs-framework/aosoverlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/bin/sh

# This module overlays multiple sources over the rootfs:
# aosoverlay.path - specifies a directory containing squashfs image files and
# subdirectories. Each squashfs file is loop-mounted first, then
# all mounted images and subdirectories are stacked over ROOTFS_DIR
# using overlayfs (files take priority over directories).
# aosoverlay.upperdir - (optional) upperdir for the overlay mount, making ROOTFS_DIR writable.
# aosoverlay.workdir - (optional) workdir for the overlay mount; required when upperdir is set.

OVERLAY_MOUNT="/mnt/overlay"

aosoverlay_enabled() {
if [ -z "${bootparam_aosoverlay_path}" ]; then
msg "Aos overlay disabled: boot parameter aosoverlay.path is not set."
return 1
fi

if [ ! -d "${bootparam_aosoverlay_path}" ]; then
msg "Aos overlay disabled: ${bootparam_aosoverlay_path} does not exist."
return 1
fi

return 0
}

aosoverlay_run() {
msg "Aos overlay: applying ${bootparam_aosoverlay_path} over rootfs"

if [ -n "${bootparam_aosoverlay_upperdir}" ] && [ -z "${bootparam_aosoverlay_workdir}" ]; then
fatal "Aos overlay: aosoverlay.workdir is required when aosoverlay.upperdir is set"
fi

lower_dirs=""

# Mount squashfs files first
for img in "$bootparam_aosoverlay_path"/*; do
[ -f "$img" ] || continue
name=$(basename "$img")
mnt="${OVERLAY_MOUNT}/${name}"

msg "Aos overlay: mounting ${img} to ${mnt}"

mkdir -p "$mnt"
mount -t squashfs -o loop "$img" "$mnt"

lower_dirs="${lower_dirs}${lower_dirs:+:}${mnt}"
done

# Add subdirectories
for dir in "$bootparam_aosoverlay_path"/*; do
[ -d "$dir" ] || continue
lower_dirs="${lower_dirs}${lower_dirs:+:}${dir}"
done

if [ -z "$lower_dirs" ]; then
msg "Aos overlay: no squashfs files or directories found in ${bootparam_aosoverlay_path}, skipping"
return
fi

msg "Aos overlay: mounting ${lower_dirs} over ${ROOTFS_DIR}"

if [ -n "${bootparam_aosoverlay_upperdir}" ] && [ -n "${bootparam_aosoverlay_workdir}" ]; then
mkdir -p "${bootparam_aosoverlay_upperdir}" "${bootparam_aosoverlay_workdir}"
mount -t overlay overlay \
-o lowerdir="${lower_dirs}:${ROOTFS_DIR}",upperdir="${bootparam_aosoverlay_upperdir}",workdir="${bootparam_aosoverlay_workdir}" \
"$ROOTFS_DIR"
else
mount -t overlay overlay -o lowerdir="${lower_dirs}:${ROOTFS_DIR}" "$ROOTFS_DIR"
fi
}
2 changes: 1 addition & 1 deletion recipes-core/initrdscripts/initramfs-framework/aosupdate
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# This module requires the following boot parameters:
# aosupdate.device - specifies device where update artifacts are stored;
# aosupdate.path - specifies path whre update artifacts are stored;
# aosupdate.path - specifies path where update artifacts are stored;
# aosupdate.selinux_module - specifies SELinux module.

# consts
Expand Down
15 changes: 15 additions & 0 deletions recipes-core/initrdscripts/initramfs-framework_%.bbappend
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ SRC_URI += " \
file://kmsglog \
file://machineid \
file://opendisk \
file://aosoverlay \
file://rundir \
file://vardir \
"

PACKAGES += " \
initramfs-module-aosoverlay \
initramfs-module-aosupdate \
initramfs-module-kmsglog \
initramfs-module-machineid \
Expand All @@ -32,6 +34,16 @@ RRECOMMENDS:initramfs-module-aosupdate = " \
', '', d)} \
"


SUMMARY:initramfs-module-aosoverlay = "initramfs support for overlaying a source over rootfs"
RDEPENDS:initramfs-module-aosoverlay = "${PN}-base"
FILES:initramfs-module-aosoverlay = "/init.d/97-aosoverlay"
RRECOMMENDS:initramfs-module-aosoverlay = " \
kernel-module-loop \
kernel-module-overlay \
kernel-module-squashfs \
"

SUMMARY:initramfs-module-kmsglog = "redirect log messages to kmsg"
RDEPENDS:initramfs-module-kmsglog = "${PN}-base"
FILES:initramfs-module-kmsglog = "/init.d/00-kmsglog"
Expand All @@ -53,6 +65,9 @@ RDEPENDS:initramfs-module-vardir = "${PN}-base"
FILES:initramfs-module-vardir = "/init.d/02-vardir"

do_install:append() {
# aosoverlay
install -m 0755 ${WORKDIR}/aosoverlay ${D}/init.d/97-aosoverlay

# aosupdate
install -m 0755 ${WORKDIR}/aosupdate ${D}/init.d/95-aosupdate

Expand Down