diff options
author | Sven Gothel <[email protected]> | 2021-07-01 07:38:52 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2021-07-01 07:38:52 +0200 |
commit | f4940a8b73e8a3ec50354c62a00460dc74690d9a (patch) | |
tree | 22350079aeb95dc45d680156d478eee3fb4fdf16 /stage2 | |
parent | 447dd404b4d78e3821bd16e66c00c1d5dff81ebc (diff) |
Stateless Multiboot System: Using initrd loop_rootfs scripts
Implementation follows 'doc/filesystem-layout.md':
Elevator update writes the testing new OS_PREFIX into `/boot/config.txt`
and writes the previous into `/boot/sys_last` as a fallback.
* If 'ROOT' != 'file', perform normal boot operations (the 'root' cmdline.txt argument)
* If `/boot/sys_last` exists, loop_rootfs will
** If '/boot/sys_cntr' doesn't exist, create it with value '1': Boot the new update.
** If '/boot/sys_cntr' exist and holds value <= 0, increment it: Boot the new update.
** Otherwise: Fallback to `/boot/sys_last`
The fallback has been simplified to:
* copy '/boot/config.txt' -> '/boot/config.bak'
* copy '/boot/<sys_fallback>/config.txt' -> '/boot/config.txt'
In any case where the `rootfs.img` check fails,
a fallback escalation will be used:
* `/boot/sys_last` if exists, i.e. pre-update system
* `sys_arm64_000` factory default, i.e. the last resort
The following 'rootfs.img' checks are performed:
* file exists
* filesystem type known
* 'fsck -V -t fstype rootfs.img'
The following '/boot' partition check is performed
```
while ! fsck -f -y -V -t vfat "${BOOT_PART}"; do
panic "The vfat filesystem on ${BOOT_PART} requires a manual fsck"
done
```
Whenever a system has been booted,
it shall determine whether it is working.
If working, it shall remove the files (if exists):
* `/boot/sys_last`
* '/boot/sys_cntr'
Now the new system has been accepted.
Otherwise the system shall reboot.
In case the system is frozen and broken,
the user shall reset the system
which will cause aforementioned fallback procedure.
Manual testing on developer machine performed with 'stage2/01-sys-tweaks/files/initramfs/test/loop_rootfs_test'.
Diffstat (limited to 'stage2')
13 files changed, 1163 insertions, 11 deletions
diff --git a/stage2/01-sys-tweaks/01-run.sh b/stage2/01-sys-tweaks/01-run.sh index 139154a..a8d088f 100755 --- a/stage2/01-sys-tweaks/01-run.sh +++ b/stage2/01-sys-tweaks/01-run.sh @@ -37,19 +37,48 @@ else fi systemctl enable regenerate_ssh_host_keys -mkdir -p /data/overlay_a -cd /data/overlay_a -mkdir -p etc/upper etc/work home/upper home/work srv/upper srv/work tmp/upper tmp/work var/upper var/work +#mkdir -p /data/overlay_a +#cd /data/overlay_a +#mkdir -p etc/upper etc/work home/upper home/work srv/upper srv/work tmp/upper tmp/work var/upper var/work +# +#mkdir -p /data/overlay_b +#cd /data/overlay_b +#mkdir -p etc/upper etc/work home/upper home/work srv/upper srv/work tmp/upper tmp/work var/upper var/work +# +#cd /data +#ln -s overlay_a overlay +# +#systemctl enable overlay_mount + +systemctl disable overlay_mount +systemctl mask overlay_mount + +# Setup unique system folder /boot/sys_arm64_000 +mkdir -p /boot/sys_arm64_000 +mv /boot/*.dtb /boot/COPYING.linux /boot/LICENCE.broadcom /boot/initrd.img /boot/sys_arm64_000/ +mv /boot/issue.txt /boot/kernel8.img /boot/overlays /boot/rootfs.img /boot/sys_arm64_000/ + +mv /boot/config.txt /boot/config.txt.orig +mv /boot/cmdline.txt /boot/sys_arm64_000/cmdline.txt.orig +if [ -f /boot/initrd.img ]; then + mv /boot/initrd.img /boot/sys_arm64_000/initrd.img.orig +fi + +EOF -mkdir -p /data/overlay_b -cd /data/overlay_b -mkdir -p etc/upper etc/work home/upper home/work srv/upper srv/work tmp/upper tmp/work var/upper var/work +install -m 644 files/boot/sys_arm64_000/cmdline.txt "${ROOTFS_DIR}/boot/sys_arm64_000/" -cd /data -ln -s overlay_a overlay +install -m 644 files/boot/config.txt "${ROOTFS_DIR}/boot/" -systemctl enable overlay_mount +install -m 755 files/initramfs/loop_rootfs "${ROOTFS_DIR}/etc/initramfs-tools/scripts/init-premount/" +# echo "squashfs" >> "${ROOTFS_DIR}/etc/modules" +echo "squashfs" >> "${ROOTFS_DIR}/etc/initramfs-tools/modules" + +sed -i -e 's/MODULES=most/MODULES=dep/g' -e 's/BUSYBOX=auto/BUSYBOX=y/g' "${ROOTFS_DIR}/etc/initramfs-tools/initramfs.conf" + +on_chroot << EOF +mkinitramfs -o /boot/sys_arm64_000/initrd.img EOF if [ "${USE_QEMU}" = "1" ]; then @@ -57,14 +86,12 @@ if [ "${USE_QEMU}" = "1" ]; then install -m 644 files/90-qemu.rules "${ROOTFS_DIR}/etc/udev/rules.d/" on_chroot << EOF systemctl disable resize2fs_once -systemctl enable overlay_mount EOF echo "leaving QEMU mode" else on_chroot << EOF #systemctl enable resize2fs_once systemctl disable resize2fs_once -systemctl enable overlay_mount EOF echo "leaving normal mode" fi diff --git a/stage2/01-sys-tweaks/files/boot/config.txt b/stage2/01-sys-tweaks/files/boot/config.txt new file mode 100755 index 0000000..6ff2339 --- /dev/null +++ b/stage2/01-sys-tweaks/files/boot/config.txt @@ -0,0 +1,120 @@ +# For more options and information see +# http://rpf.io/configtxt +# Some settings may impact device functionality. See link above for details + +[all] +#disable_splash=0 + +# Prepended to the name of any operating system files loaded by the firmware: +# kernels, initramfs, cmdline.txt, .dtbs and overlays. +os_prefix=sys_arm64_000/ + +initramfs initrd.img followkernel + +#[pi3] +#start_file=system_rpi_arm64_a/start_x.elf +#fixup_file=system_rpi_arm64_a/fixup_x.dat +# +#[pi4] +#start_file=system_rpi_arm64_a/start4x.elf +#fixup_file=system_rpi_arm64_a/fixup4x.dat + +[all] +# uncomment if you get no picture on HDMI for a default "safe" mode +#hdmi_safe=1 + +# uncomment this if your display has a black border of unused pixels visible +# and your display can output without overscan +disable_overscan=1 + +# uncomment the following to adjust overscan. Use positive numbers if console +# goes off screen, and negative if there is too much border +#overscan_left=16 +#overscan_right=16 +#overscan_top=16 +#overscan_bottom=16 + +# uncomment to force a console size. By default it will be display's size minus +# overscan. +#framebuffer_width=1280 +#framebuffer_height=720 + +# uncomment if hdmi display is not detected and composite is being output +#hdmi_force_hotplug=1 + +# uncomment to force a specific HDMI mode (this will force VGA) +#hdmi_group=1 +#hdmi_mode=1 + +# uncomment to force a HDMI mode rather than DVI. This can make audio work in +# DMT (computer monitor) modes +#hdmi_drive=2 + +# uncomment to increase signal to HDMI, if you have interference, blanking, or +# no display +#config_hdmi_boost=4 + +# uncomment for composite PAL +#sdtv_mode=2 + +#uncomment to overclock the arm. 700 MHz is the default. +#arm_freq=800 + +# Uncomment some or all of these to enable the optional hardware interfaces +#dtparam=i2c_arm=on +#dtparam=i2s=on +#dtparam=spi=on + +# Uncomment this to enable infrared communication. +#dtoverlay=gpio-ir,gpio_pin=17 +#dtoverlay=gpio-ir-tx,gpio_pin=18 + +# Additional overlays and parameters are documented /boot/overlays/README + +# Enable audio (loads snd_bcm2835) +#dtparam=audio=on + +# Merged Zafena settings (old pi-gen, newer zaf502 machine and my current raspi3/4 machines) + +# Tunes the bcm2835-sdhost SD/MMC DMA driver +# Also available kernel cmdline: +# 'bcm2835_mmc.mmc_debug=0x1000' -> Forcing PIO mode +# 'bcm2835_mmc.mmc_debug=0x2000' -> DMA channels allocated +# See https://github.com/raspberrypi/firmware/issues/397#issuecomment-94574578 + +# Turns off the bcm2835-sdhost SD/MMC DMA mode, enforces PIO mode +dtoverlay=sdtweak,force_pio=1 +#dtparam=sd_force_pio=on + +#dtparam=i2s=on +#dtparam=spi=on +#dtoverlay=zafena-rpi +#dtoverlay=rpi-dac + +## Zafena config 2 +#enable_uart=1 +#core_freq=250 +#dtoverlay=miniuart-bt,krnbt=on + +## Zafena config 0 (hciattach on) +#enable_uart=1 +#dtoverlay=pi3-miniuart-bt +#core_freq=250 + +# Zafena config 3 (hciattach on) +enable_uart=1 +core_freq=250 + +arm_64bit=1 + +#gpu_mem=128 +gpu_mem=64 + +[all] +# Enable DRM VC4 V3D driver on top of the dispmanx display stack +dtoverlay=vc4-fkms-v3d + +[pi4] +# Also have two framebuffer +max_framebuffers=2 + diff --git a/stage2/01-sys-tweaks/files/boot/sys_arm64_000/cmdline.txt b/stage2/01-sys-tweaks/files/boot/sys_arm64_000/cmdline.txt new file mode 100755 index 0000000..65ca2e9 --- /dev/null +++ b/stage2/01-sys-tweaks/files/boot/sys_arm64_000/cmdline.txt @@ -0,0 +1 @@ +dwc_otg.lpm_enable=0 console=tty3 root=file rootfstype=ext4 elevator=deadline fsck.repair=no rootwait diff --git a/stage2/01-sys-tweaks/files/initramfs/loop_rootfs b/stage2/01-sys-tweaks/files/initramfs/loop_rootfs new file mode 100755 index 0000000..381666e --- /dev/null +++ b/stage2/01-sys-tweaks/files/initramfs/loop_rootfs @@ -0,0 +1,237 @@ +#!/bin/sh + +PREREQ="udev" + +prereqs() +{ + echo "${PREREQ}" +} + +case ${1} in + prereqs) + prereqs + exit 0 + ;; +esac + +. /scripts/functions + +readonly BOOT_PART="/dev/mmcblk0p1" +readonly BOOT_DIR="/mnt/boot" + +# Current config.txt with current OS_PREFIX +readonly CONFIG_FILE="${BOOT_DIR}/config.txt" +readonly CONFIG_FILE_OLD="${BOOT_DIR}/config.bak" + +# Optional fallback OS_PREFIX +readonly OS_PREFIX_FILE_LAST="${BOOT_DIR}/sys_last" +# Optional boot counter. +readonly BOOT_COUNTER_FILE="${BOOT_DIR}/sys_cntr" + +# +# To guarantee factory default fallback, have immutable: +# - Folder '/boot/sys_arm64_000/' folder (OS_PREFIX_DEFAULT), which includes +# - File '/boot/sys_arm64_000/config.txt' (CONFIG_FILE_DEFAULT). +# +# Notable: Every system folder contains its own immutable config.txt copy! +# + +# Default OS_PREFIX -> ${BOOT_DIR}/${OS_PREFIX_DEFAULT} +readonly OS_PREFIX_DEFAULT="sys_arm64_000" + +# Default config.txt with factory default OS_PREFIX_DEFAULT +readonly CONFIG_FILE_DEFAULT="${BOOT_DIR}/${OS_PREFIX_DEFAULT}/config.txt" + +OS_PREFIX="" +OS_PREFIX_LAST="" +BOOT_COUNTER="" + +IMAGE_FILE="" +FILE_FSTYPE="" + +check_fsfile() { + local fsfile=$1 + + if [ ! -f "${fsfile}" ]; then + log_failure_msg "loop_rootfs image file ${fsfile} doesn't exist." + return 1 + fi + + FILE_FSTYPE=$(get_fstype "${fsfile}") + if [ -z "${FILE_FSTYPE}" -o "${FILE_FSTYPE}" = "unknown" ]; then + log_failure_msg "loop_rootfs image file ${fsfile} unknown fstype." + return 1 + fi + + if ! fsck -V -t "${FILE_FSTYPE}" "${fsfile}"; then + log_failure_msg "loop_rootfs image file ${fsfile} fsck failed." + return 1 + fi + + return 0; +} + +attach_rootfs() { + local fsfile=$1 + + if ! check_fsfile "${fsfile}"; then + return 1 + fi + + # Using losetup from initrd + local rootdev="/dev/loop0" + if ! losetup ${rootdev} ${fsfile}; then + log_failure_msg "loop_rootfs could not attached ${fsfile} to loop-device ${rootdev}." + return 1 + fi + + # Latest losetup + #local rootdev=$(losetup --find --show ${fsfile}) + #if [ -z "${rootdev}" ]; then + # panic "loop_rootfs could not attached ${fsfile} to loop-device." + # return 1 + #fi + + # Propagate new local ROOT device and its ROOTFSTYPE + ROOTFSTYPE="${FILE_FSTYPE}" + ROOT="${rootdev}" + echo "ROOT=${ROOT}" >> /conf/param.conf + echo "ROOTFSTYPE=${ROOTFSTYPE}" >> /conf/param.conf + return 0; +} + +# 1 old file, 2 new file, 3 expected old_prefix, 4 expected new prefix +compare_files() { + local change=$(diff $1 $2) + #echo "change ${change}" + local old_prefix=$(echo "${change}" | sed -e '1d;3,4d' | awk -F = ' { print substr($2,0, length($2)-1) }') + local new_prefix=$(echo "${change}" | sed -e '1,3d' | awk -F = ' { print substr($2,0, length($2)-1) }') + #echo "old_prefix has '${old_prefix}', expected '${3}'" + #echo "new_prefix has '${new_prefix}', expected '${4}'" + [ "${3}" = "${old_prefix}" -a "${4}" = "${new_prefix}" ] + return $? +} + + +fallback_rootfs() { + local os_prefix_current="$1" + local os_prefix_fallback="$2" + # Cleanup + rm -f "${OS_PREFIX_FILE_LAST}" + rm -f "${BOOT_COUNTER_FILE}" + if [ "${os_prefix_fallback}" = "${OS_PREFIX_DEFAULT}" ]; then + # Factory reset fast path + log_success_msg "loop_rootfs fallback to factory default: ${OS_PREFIX} -> ${os_prefix_fallback}." + mv "${CONFIG_FILE}" "${CONFIG_FILE_OLD}" + cp "${CONFIG_FILE_DEFAULT}" "${CONFIG_FILE}" + else + # Setup config.txt + + #sed "s/os_prefix=${os_prefix_current}/os_prefix=${os_prefix_fallback}/g" "${CONFIG_FILE}" > "${CONFIG_FILE}.new" + #if ! compare_files "${CONFIG_FILE}" "${CONFIG_FILE}.new" "${os_prefix_current}" "${os_prefix_fallback}"; then + # log_failure_msg "loop_rootfs failed fallback setting in new ${CONFIG_FILE}, fallback to factory reset ${CONFIG_FILE_DEFAULT}." + # mv "${CONFIG_FILE}" "${CONFIG_FILE_OLD}" + # cp "${CONFIG_FILE_DEFAULT}" "${CONFIG_FILE}" + #else + # mv "${CONFIG_FILE}" "${CONFIG_FILE_OLD}" + # mv "${CONFIG_FILE}.new" "${CONFIG_FILE}" + #fi + + log_success_msg "loop_rootfs fallback to previous: ${OS_PREFIX} -> ${os_prefix_fallback}." + mv "${CONFIG_FILE}" "${CONFIG_FILE_OLD}" + cp "${BOOT_DIR}/${os_prefix_fallback}/config.txt" "${CONFIG_FILE}" + fi + sync + umount ${BOOT_DIR} + reboot + exit 1 +} + +if [ "${ROOT}" != "file" ]; then + log_begin_msg "loop_rootfs skip non file ROOT ${ROOT}" + log_end_msg + exit 0 +fi + +log_begin_msg "loop_rootfs" +mkdir -p ${BOOT_DIR} + +# force fix verbose fseek, using undocumented options '-f', '-y' +while ! fsck -f -y -V -t vfat "${BOOT_PART}"; do + panic "The vfat filesystem on ${BOOT_PART} requires a manual fsck" +done + +if ! mount ${BOOT_PART} ${BOOT_DIR}; then + panic "loop_rootfs could not mount /boot." + exit 1 +fi + +if [ ! -f "${CONFIG_FILE}" ]; then + panic "loop_rootfs could not find ${CONFIG_FILE}." + exit 1 +fi + +OS_PREFIX=$(grep os_prefix ${CONFIG_FILE} | awk -F = ' { print substr($2,0, length($2)-1) }') +if [ -z "${OS_PREFIX}" ]; then + panic "loop_rootfs no os_prefix defined in ${CONFIG_FILE}." + exit 1 +fi + +if [ -f "${OS_PREFIX_FILE_LAST}" ]; then + BOOT_COUNTER=$(cat "${BOOT_COUNTER_FILE}") + if [ -n "$BOOT_COUNTER" -a $BOOT_COUNTER -eq $BOOT_COUNTER 2> /dev/null ]; then + # BOOT_COUNTER is a number + if [ $BOOT_COUNTER -gt 0 ]; then + # Fallback to OS_PREFIX_LAST, booted once already without being cleared! + OS_PREFIX_LAST=$(cat "${OS_PREFIX_FILE_LAST}") + IMAGE_FILE="${BOOT_DIR}/${OS_PREFIX_LAST}/rootfs.img" + if ! check_fsfile "${IMAGE_FILE}"; then + # IMAGE_FILE not existing for OS_PREFIX_FILE_LAST or its fstype unknown + # Next: factory default OS_PREFIX_DEFAULT + log_failure_msg "loop_rootfs fallback ${OS_PREFIX_LAST} image file ${IMAGE_FILE} non existent or corrupt. Next factory default ${OS_PREFIX_DEFAULT}. Reboot..." + fallback_rootfs "${OS_PREFIX}" "${OS_PREFIX_DEFAULT}" + else + # Next: factory default OS_PREFIX_LAST + log_success_msg "loop_rootfs fallback ${OS_PREFIX} -> previous ${OS_PREFIX_LAST}, counter ${BOOT_COUNTER}. Reboot..." + fallback_rootfs "${OS_PREFIX}" "${OS_PREFIX_LAST}" + fi + exit 1 + else + # Testing new OS_PREFIX 1st boot: BOOT_COUNTER -> 1 + let BOOT_COUNTER=${BOOT_COUNTER} + 1 + echo ${BOOT_COUNTER} > "${BOOT_COUNTER_FILE}" + log_success_msg "loop_rootfs testing new ${OS_PREFIX} (counter -> ${BOOT_COUNTER} (1))." + fi + else + # Create BOOT_COUNTER, 1st boot: BOOT_COUNTER -> 1 + BOOT_COUNTER=1 + echo ${BOOT_COUNTER} > "${BOOT_COUNTER_FILE}" + log_success_msg "loop_rootfs testing new ${OS_PREFIX} (counter -> ${BOOT_COUNTER} (2))." + fi +elif [ -f "${BOOT_COUNTER_FILE}" ]; then + # cleanup BOOT_COUNTER_FILE, no OS_PREFIX_FILE_LAST + rm -f "${BOOT_COUNTER_FILE}" +fi + +IMAGE_FILE="${BOOT_DIR}/${OS_PREFIX}/rootfs.img" + +if ! attach_rootfs "${IMAGE_FILE}"; then + log_failure_msg "loop_rootfs could not attach to ${OS_PREFIX}, file ${IMAGE_FILE}." + if [ -n "${OS_PREFIX_LAST}" -a "${OS_PREFIX}" != "${OS_PREFIX_LAST}" ]; then + log_success_msg "loop_rootfs fallback ${OS_PREFIX} -> previous ${OS_PREFIX_LAST}. Reboot..." + fallback_rootfs "${OS_PREFIX}" "${OS_PREFIX_LAST}" + elif [ "${OS_PREFIX}" != "${OS_PREFIX_DEFAULT}" ]; then + log_success_msg "loop_rootfs fallback ${OS_PREFIX} -> factory default ${OS_PREFIX_DEFAULT}. Reboot..." + fallback_rootfs "${OS_PREFIX}" "${OS_PREFIX_DEFAULT}" + else + panic "loop_rootfs could not attach to factory default ${OS_PREFIX}, file ${IMAGE_FILE}. No fallback!" + fi + exit 1 +fi + +log_success_msg "loop_rootfs attached ${OS_PREFIX}, ${ROOTFSTYPE} file ${IMAGE_FILE} to loop-device ${ROOT}." + +log_end_msg + +exit 0 + diff --git a/stage2/01-sys-tweaks/files/initramfs/test/boot/config.txt b/stage2/01-sys-tweaks/files/initramfs/test/boot/config.txt new file mode 100755 index 0000000..9cc4660 --- /dev/null +++ b/stage2/01-sys-tweaks/files/initramfs/test/boot/config.txt @@ -0,0 +1,120 @@ +# For more options and information see +# http://rpf.io/configtxt +# Some settings may impact device functionality. See link above for details + +[all] +#disable_splash=0 + +# Prepended to the name of any operating system files loaded by the firmware: +# kernels, initramfs, cmdline.txt, .dtbs and overlays. +os_prefix=sys_arm64_000/ + +initramfs initrd.img followkernel + +#[pi3] +#start_file=sys_arm64_000/start_x.elf +#fixup_file=sys_arm64_000/fixup_x.dat +# +#[pi4] +#start_file=sys_arm64_000/start4x.elf +#fixup_file=sys_arm64_000/fixup4x.dat + +[all] +# uncomment if you get no picture on HDMI for a default "safe" mode +#hdmi_safe=1 + +# uncomment this if your display has a black border of unused pixels visible +# and your display can output without overscan +disable_overscan=1 + +# uncomment the following to adjust overscan. Use positive numbers if console +# goes off screen, and negative if there is too much border +#overscan_left=16 +#overscan_right=16 +#overscan_top=16 +#overscan_bottom=16 + +# uncomment to force a console size. By default it will be display's size minus +# overscan. +#framebuffer_width=1280 +#framebuffer_height=720 + +# uncomment if hdmi display is not detected and composite is being output +#hdmi_force_hotplug=1 + +# uncomment to force a specific HDMI mode (this will force VGA) +#hdmi_group=1 +#hdmi_mode=1 + +# uncomment to force a HDMI mode rather than DVI. This can make audio work in +# DMT (computer monitor) modes +#hdmi_drive=2 + +# uncomment to increase signal to HDMI, if you have interference, blanking, or +# no display +#config_hdmi_boost=4 + +# uncomment for composite PAL +#sdtv_mode=2 + +#uncomment to overclock the arm. 700 MHz is the default. +#arm_freq=800 + +# Uncomment some or all of these to enable the optional hardware interfaces +#dtparam=i2c_arm=on +#dtparam=i2s=on +#dtparam=spi=on + +# Uncomment this to enable infrared communication. +#dtoverlay=gpio-ir,gpio_pin=17 +#dtoverlay=gpio-ir-tx,gpio_pin=18 + +# Additional overlays and parameters are documented /boot/overlays/README + +# Enable audio (loads snd_bcm2835) +#dtparam=audio=on + +# Merged Zafena settings (old pi-gen, newer zaf502 machine and my current raspi3/4 machines) + +# Tunes the bcm2835-sdhost SD/MMC DMA driver +# Also available kernel cmdline: +# 'bcm2835_mmc.mmc_debug=0x1000' -> Forcing PIO mode +# 'bcm2835_mmc.mmc_debug=0x2000' -> DMA channels allocated +# See https://github.com/raspberrypi/firmware/issues/397#issuecomment-94574578 + +# Turns off the bcm2835-sdhost SD/MMC DMA mode, enforces PIO mode +dtoverlay=sdtweak,force_pio=1 +#dtparam=sd_force_pio=on + +#dtparam=i2s=on +#dtparam=spi=on +#dtoverlay=zafena-rpi +#dtoverlay=rpi-dac + +## Zafena config 2 +#enable_uart=1 +#core_freq=250 +#dtoverlay=miniuart-bt,krnbt=on + +## Zafena config 0 (hciattach on) +#enable_uart=1 +#dtoverlay=pi3-miniuart-bt +#core_freq=250 + +# Zafena config 3 (hciattach on) +enable_uart=1 +core_freq=250 + +arm_64bit=1 + +#gpu_mem=128 +gpu_mem=64 + +[all] +# Enable DRM VC4 V3D driver on top of the dispmanx display stack +dtoverlay=vc4-fkms-v3d + +[pi4] +# Also have two framebuffer +max_framebuffers=2 + diff --git a/stage2/01-sys-tweaks/files/initramfs/test/boot/sys_arm64_000/config.txt b/stage2/01-sys-tweaks/files/initramfs/test/boot/sys_arm64_000/config.txt new file mode 100755 index 0000000..9cc4660 --- /dev/null +++ b/stage2/01-sys-tweaks/files/initramfs/test/boot/sys_arm64_000/config.txt @@ -0,0 +1,120 @@ +# For more options and information see +# http://rpf.io/configtxt +# Some settings may impact device functionality. See link above for details + +[all] +#disable_splash=0 + +# Prepended to the name of any operating system files loaded by the firmware: +# kernels, initramfs, cmdline.txt, .dtbs and overlays. +os_prefix=sys_arm64_000/ + +initramfs initrd.img followkernel + +#[pi3] +#start_file=sys_arm64_000/start_x.elf +#fixup_file=sys_arm64_000/fixup_x.dat +# +#[pi4] +#start_file=sys_arm64_000/start4x.elf +#fixup_file=sys_arm64_000/fixup4x.dat + +[all] +# uncomment if you get no picture on HDMI for a default "safe" mode +#hdmi_safe=1 + +# uncomment this if your display has a black border of unused pixels visible +# and your display can output without overscan +disable_overscan=1 + +# uncomment the following to adjust overscan. Use positive numbers if console +# goes off screen, and negative if there is too much border +#overscan_left=16 +#overscan_right=16 +#overscan_top=16 +#overscan_bottom=16 + +# uncomment to force a console size. By default it will be display's size minus +# overscan. +#framebuffer_width=1280 +#framebuffer_height=720 + +# uncomment if hdmi display is not detected and composite is being output +#hdmi_force_hotplug=1 + +# uncomment to force a specific HDMI mode (this will force VGA) +#hdmi_group=1 +#hdmi_mode=1 + +# uncomment to force a HDMI mode rather than DVI. This can make audio work in +# DMT (computer monitor) modes +#hdmi_drive=2 + +# uncomment to increase signal to HDMI, if you have interference, blanking, or +# no display +#config_hdmi_boost=4 + +# uncomment for composite PAL +#sdtv_mode=2 + +#uncomment to overclock the arm. 700 MHz is the default. +#arm_freq=800 + +# Uncomment some or all of these to enable the optional hardware interfaces +#dtparam=i2c_arm=on +#dtparam=i2s=on +#dtparam=spi=on + +# Uncomment this to enable infrared communication. +#dtoverlay=gpio-ir,gpio_pin=17 +#dtoverlay=gpio-ir-tx,gpio_pin=18 + +# Additional overlays and parameters are documented /boot/overlays/README + +# Enable audio (loads snd_bcm2835) +#dtparam=audio=on + +# Merged Zafena settings (old pi-gen, newer zaf502 machine and my current raspi3/4 machines) + +# Tunes the bcm2835-sdhost SD/MMC DMA driver +# Also available kernel cmdline: +# 'bcm2835_mmc.mmc_debug=0x1000' -> Forcing PIO mode +# 'bcm2835_mmc.mmc_debug=0x2000' -> DMA channels allocated +# See https://github.com/raspberrypi/firmware/issues/397#issuecomment-94574578 + +# Turns off the bcm2835-sdhost SD/MMC DMA mode, enforces PIO mode +dtoverlay=sdtweak,force_pio=1 +#dtparam=sd_force_pio=on + +#dtparam=i2s=on +#dtparam=spi=on +#dtoverlay=zafena-rpi +#dtoverlay=rpi-dac + +## Zafena config 2 +#enable_uart=1 +#core_freq=250 +#dtoverlay=miniuart-bt,krnbt=on + +## Zafena config 0 (hciattach on) +#enable_uart=1 +#dtoverlay=pi3-miniuart-bt +#core_freq=250 + +# Zafena config 3 (hciattach on) +enable_uart=1 +core_freq=250 + +arm_64bit=1 + +#gpu_mem=128 +gpu_mem=64 + +[all] +# Enable DRM VC4 V3D driver on top of the dispmanx display stack +dtoverlay=vc4-fkms-v3d + +[pi4] +# Also have two framebuffer +max_framebuffers=2 + diff --git a/stage2/01-sys-tweaks/files/initramfs/test/boot/sys_arm64_000/rootfs.img b/stage2/01-sys-tweaks/files/initramfs/test/boot/sys_arm64_000/rootfs.img new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/stage2/01-sys-tweaks/files/initramfs/test/boot/sys_arm64_000/rootfs.img diff --git a/stage2/01-sys-tweaks/files/initramfs/test/boot/sys_arm64_001/config.txt b/stage2/01-sys-tweaks/files/initramfs/test/boot/sys_arm64_001/config.txt new file mode 100755 index 0000000..bbe55a1 --- /dev/null +++ b/stage2/01-sys-tweaks/files/initramfs/test/boot/sys_arm64_001/config.txt @@ -0,0 +1,120 @@ +# For more options and information see +# http://rpf.io/configtxt +# Some settings may impact device functionality. See link above for details + +[all] +#disable_splash=0 + +# Prepended to the name of any operating system files loaded by the firmware: +# kernels, initramfs, cmdline.txt, .dtbs and overlays. +os_prefix=sys_arm64_001/ + +initramfs initrd.img followkernel + +#[pi3] +#start_file=sys_arm64_000/start_x.elf +#fixup_file=sys_arm64_000/fixup_x.dat +# +#[pi4] +#start_file=sys_arm64_000/start4x.elf +#fixup_file=sys_arm64_000/fixup4x.dat + +[all] +# uncomment if you get no picture on HDMI for a default "safe" mode +#hdmi_safe=1 + +# uncomment this if your display has a black border of unused pixels visible +# and your display can output without overscan +disable_overscan=1 + +# uncomment the following to adjust overscan. Use positive numbers if console +# goes off screen, and negative if there is too much border +#overscan_left=16 +#overscan_right=16 +#overscan_top=16 +#overscan_bottom=16 + +# uncomment to force a console size. By default it will be display's size minus +# overscan. +#framebuffer_width=1280 +#framebuffer_height=720 + +# uncomment if hdmi display is not detected and composite is being output +#hdmi_force_hotplug=1 + +# uncomment to force a specific HDMI mode (this will force VGA) +#hdmi_group=1 +#hdmi_mode=1 + +# uncomment to force a HDMI mode rather than DVI. This can make audio work in +# DMT (computer monitor) modes +#hdmi_drive=2 + +# uncomment to increase signal to HDMI, if you have interference, blanking, or +# no display +#config_hdmi_boost=4 + +# uncomment for composite PAL +#sdtv_mode=2 + +#uncomment to overclock the arm. 700 MHz is the default. +#arm_freq=800 + +# Uncomment some or all of these to enable the optional hardware interfaces +#dtparam=i2c_arm=on +#dtparam=i2s=on +#dtparam=spi=on + +# Uncomment this to enable infrared communication. +#dtoverlay=gpio-ir,gpio_pin=17 +#dtoverlay=gpio-ir-tx,gpio_pin=18 + +# Additional overlays and parameters are documented /boot/overlays/README + +# Enable audio (loads snd_bcm2835) +#dtparam=audio=on + +# Merged Zafena settings (old pi-gen, newer zaf502 machine and my current raspi3/4 machines) + +# Tunes the bcm2835-sdhost SD/MMC DMA driver +# Also available kernel cmdline: +# 'bcm2835_mmc.mmc_debug=0x1000' -> Forcing PIO mode +# 'bcm2835_mmc.mmc_debug=0x2000' -> DMA channels allocated +# See https://github.com/raspberrypi/firmware/issues/397#issuecomment-94574578 + +# Turns off the bcm2835-sdhost SD/MMC DMA mode, enforces PIO mode +dtoverlay=sdtweak,force_pio=1 +#dtparam=sd_force_pio=on + +#dtparam=i2s=on +#dtparam=spi=on +#dtoverlay=zafena-rpi +#dtoverlay=rpi-dac + +## Zafena config 2 +#enable_uart=1 +#core_freq=250 +#dtoverlay=miniuart-bt,krnbt=on + +## Zafena config 0 (hciattach on) +#enable_uart=1 +#dtoverlay=pi3-miniuart-bt +#core_freq=250 + +# Zafena config 3 (hciattach on) +enable_uart=1 +core_freq=250 + +arm_64bit=1 + +#gpu_mem=128 +gpu_mem=64 + +[all] +# Enable DRM VC4 V3D driver on top of the dispmanx display stack +dtoverlay=vc4-fkms-v3d + +[pi4] +# Also have two framebuffer +max_framebuffers=2 + diff --git a/stage2/01-sys-tweaks/files/initramfs/test/boot/sys_arm64_001/rootfs.img b/stage2/01-sys-tweaks/files/initramfs/test/boot/sys_arm64_001/rootfs.img new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/stage2/01-sys-tweaks/files/initramfs/test/boot/sys_arm64_001/rootfs.img diff --git a/stage2/01-sys-tweaks/files/initramfs/test/boot/sys_arm64_002/config.txt b/stage2/01-sys-tweaks/files/initramfs/test/boot/sys_arm64_002/config.txt new file mode 100755 index 0000000..25e78c2 --- /dev/null +++ b/stage2/01-sys-tweaks/files/initramfs/test/boot/sys_arm64_002/config.txt @@ -0,0 +1,120 @@ +# For more options and information see +# http://rpf.io/configtxt +# Some settings may impact device functionality. See link above for details + +[all] +#disable_splash=0 + +# Prepended to the name of any operating system files loaded by the firmware: +# kernels, initramfs, cmdline.txt, .dtbs and overlays. +os_prefix=sys_arm64_002/ + +initramfs initrd.img followkernel + +#[pi3] +#start_file=sys_arm64_000/start_x.elf +#fixup_file=sys_arm64_000/fixup_x.dat +# +#[pi4] +#start_file=sys_arm64_000/start4x.elf +#fixup_file=sys_arm64_000/fixup4x.dat + +[all] +# uncomment if you get no picture on HDMI for a default "safe" mode +#hdmi_safe=1 + +# uncomment this if your display has a black border of unused pixels visible +# and your display can output without overscan +disable_overscan=1 + +# uncomment the following to adjust overscan. Use positive numbers if console +# goes off screen, and negative if there is too much border +#overscan_left=16 +#overscan_right=16 +#overscan_top=16 +#overscan_bottom=16 + +# uncomment to force a console size. By default it will be display's size minus +# overscan. +#framebuffer_width=1280 +#framebuffer_height=720 + +# uncomment if hdmi display is not detected and composite is being output +#hdmi_force_hotplug=1 + +# uncomment to force a specific HDMI mode (this will force VGA) +#hdmi_group=1 +#hdmi_mode=1 + +# uncomment to force a HDMI mode rather than DVI. This can make audio work in +# DMT (computer monitor) modes +#hdmi_drive=2 + +# uncomment to increase signal to HDMI, if you have interference, blanking, or +# no display +#config_hdmi_boost=4 + +# uncomment for composite PAL +#sdtv_mode=2 + +#uncomment to overclock the arm. 700 MHz is the default. +#arm_freq=800 + +# Uncomment some or all of these to enable the optional hardware interfaces +#dtparam=i2c_arm=on +#dtparam=i2s=on +#dtparam=spi=on + +# Uncomment this to enable infrared communication. +#dtoverlay=gpio-ir,gpio_pin=17 +#dtoverlay=gpio-ir-tx,gpio_pin=18 + +# Additional overlays and parameters are documented /boot/overlays/README + +# Enable audio (loads snd_bcm2835) +#dtparam=audio=on + +# Merged Zafena settings (old pi-gen, newer zaf502 machine and my current raspi3/4 machines) + +# Tunes the bcm2835-sdhost SD/MMC DMA driver +# Also available kernel cmdline: +# 'bcm2835_mmc.mmc_debug=0x1000' -> Forcing PIO mode +# 'bcm2835_mmc.mmc_debug=0x2000' -> DMA channels allocated +# See https://github.com/raspberrypi/firmware/issues/397#issuecomment-94574578 + +# Turns off the bcm2835-sdhost SD/MMC DMA mode, enforces PIO mode +dtoverlay=sdtweak,force_pio=1 +#dtparam=sd_force_pio=on + +#dtparam=i2s=on +#dtparam=spi=on +#dtoverlay=zafena-rpi +#dtoverlay=rpi-dac + +## Zafena config 2 +#enable_uart=1 +#core_freq=250 +#dtoverlay=miniuart-bt,krnbt=on + +## Zafena config 0 (hciattach on) +#enable_uart=1 +#dtoverlay=pi3-miniuart-bt +#core_freq=250 + +# Zafena config 3 (hciattach on) +enable_uart=1 +core_freq=250 + +arm_64bit=1 + +#gpu_mem=128 +gpu_mem=64 + +[all] +# Enable DRM VC4 V3D driver on top of the dispmanx display stack +dtoverlay=vc4-fkms-v3d + +[pi4] +# Also have two framebuffer +max_framebuffers=2 + diff --git a/stage2/01-sys-tweaks/files/initramfs/test/boot/sys_arm64_002/rootfs.img b/stage2/01-sys-tweaks/files/initramfs/test/boot/sys_arm64_002/rootfs.img new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/stage2/01-sys-tweaks/files/initramfs/test/boot/sys_arm64_002/rootfs.img diff --git a/stage2/01-sys-tweaks/files/initramfs/test/loop_rootfs_test b/stage2/01-sys-tweaks/files/initramfs/test/loop_rootfs_test new file mode 100755 index 0000000..9fd5dad --- /dev/null +++ b/stage2/01-sys-tweaks/files/initramfs/test/loop_rootfs_test @@ -0,0 +1,239 @@ +#!/bin/sh + +ROOT="file" + +PREREQ="udev" + +prereqs() +{ + echo "${PREREQ}" +} + +case ${1} in + prereqs) + prereqs + exit 0 + ;; +esac + +. scripts/functions + +readonly BOOT_PART="/dev/mmcblk0p1" +readonly BOOT_DIR="boot" + +# Current config.txt with current OS_PREFIX +readonly CONFIG_FILE="${BOOT_DIR}/config.txt" +readonly CONFIG_FILE_OLD="${BOOT_DIR}/config.bak" + +# Optional fallback OS_PREFIX +readonly OS_PREFIX_FILE_LAST="${BOOT_DIR}/sys_last" +# Optional boot counter. +readonly BOOT_COUNTER_FILE="${BOOT_DIR}/sys_cntr" + +# +# To guarantee factory default fallback, have immutable: +# - Folder '/boot/sys_arm64_000/' folder (OS_PREFIX_DEFAULT), which includes +# - File '/boot/sys_arm64_000/config.txt' (CONFIG_FILE_DEFAULT). +# +# Notable: Every system folder contains its own immutable config.txt copy! +# + +# Default OS_PREFIX -> ${BOOT_DIR}/${OS_PREFIX_DEFAULT} +readonly OS_PREFIX_DEFAULT="sys_arm64_000" + +# Default config.txt with factory default OS_PREFIX_DEFAULT +readonly CONFIG_FILE_DEFAULT="${BOOT_DIR}/${OS_PREFIX_DEFAULT}/config.txt" + +OS_PREFIX="" +OS_PREFIX_LAST="" +BOOT_COUNTER="" + +IMAGE_FILE="" +FILE_FSTYPE="" + +check_fsfile() { + local fsfile=$1 + + if [ ! -f "${fsfile}" ]; then + log_failure_msg "loop_rootfs image file ${fsfile} doesn't exist." + return 1 + fi + + FILE_FSTYPE=$(get_fstype "${fsfile}") + if [ -z "${FILE_FSTYPE}" -o "${FILE_FSTYPE}" = "unknown" ]; then + log_failure_msg "loop_rootfs image file ${fsfile} unknown fstype." + return 1 + fi + + #if ! fsck -V -t "${FILE_FSTYPE}" "${fsfile}"; then + # log_failure_msg "loop_rootfs image file ${fsfile} fsck failed." + # return 1 + #fi + + return 0; +} + +attach_rootfs() { + local fsfile=$1 + + if ! check_fsfile "${fsfile}"; then + return 1 + fi + + # Using losetup from initrd + local rootdev="/dev/loop0" + #if ! losetup ${rootdev} ${fsfile}; then + # log_failure_msg "loop_rootfs could not attached ${fsfile} to loop-device ${rootdev}." + # return 1 + #fi + + # Latest losetup + #local rootdev=$(losetup --find --show ${fsfile}) + #if [ -z "${rootdev}" ]; then + # panic "loop_rootfs could not attached ${fsfile} to loop-device." + # return 1 + #fi + + # Propagate new local ROOT device and its ROOTFSTYPE + ROOTFSTYPE="${FILE_FSTYPE}" + ROOT="${rootdev}" + echo "ROOT=${ROOT}" >> conf/param.conf + echo "ROOTFSTYPE=${ROOTFSTYPE}" >> conf/param.conf + return 0; +} + +# 1 old file, 2 new file, 3 expected old_prefix, 4 expected new prefix +compare_files() { + local change=$(diff $1 $2) + #echo "change ${change}" + local old_prefix=$(echo "${change}" | sed -e '1d;3,4d' | awk -F = ' { print substr($2,0, length($2)-1) }') + local new_prefix=$(echo "${change}" | sed -e '1,3d' | awk -F = ' { print substr($2,0, length($2)-1) }') + #echo "old_prefix has '${old_prefix}', expected '${3}'" + #echo "new_prefix has '${new_prefix}', expected '${4}'" + [ "${3}" = "${old_prefix}" -a "${4}" = "${new_prefix}" ] + return $? +} + + +fallback_rootfs() { + local os_prefix_current="$1" + local os_prefix_fallback="$2" + # Cleanup + rm -f "${OS_PREFIX_FILE_LAST}" + rm -f "${BOOT_COUNTER_FILE}" + if [ "${os_prefix_fallback}" = "${OS_PREFIX_DEFAULT}" ]; then + # Factory reset fast path + log_success_msg "loop_rootfs fallback to factory default: ${OS_PREFIX} -> ${os_prefix_fallback}." + mv "${CONFIG_FILE}" "${CONFIG_FILE_OLD}" + cp "${CONFIG_FILE_DEFAULT}" "${CONFIG_FILE}" + else + # Setup config.txt + + #sed "s/os_prefix=${os_prefix_current}/os_prefix=${os_prefix_fallback}/g" "${CONFIG_FILE}" > "${CONFIG_FILE}.new" + #if ! compare_files "${CONFIG_FILE}" "${CONFIG_FILE}.new" "${os_prefix_current}" "${os_prefix_fallback}"; then + # log_failure_msg "loop_rootfs failed fallback setting in new ${CONFIG_FILE}, fallback to factory reset ${CONFIG_FILE_DEFAULT}." + # mv "${CONFIG_FILE}" "${CONFIG_FILE_OLD}" + # cp "${CONFIG_FILE_DEFAULT}" "${CONFIG_FILE}" + #else + # mv "${CONFIG_FILE}" "${CONFIG_FILE_OLD}" + # mv "${CONFIG_FILE}.new" "${CONFIG_FILE}" + #fi + + log_success_msg "loop_rootfs fallback to previous: ${OS_PREFIX} -> ${os_prefix_fallback}." + mv "${CONFIG_FILE}" "${CONFIG_FILE_OLD}" + cp "${BOOT_DIR}/${os_prefix_fallback}/config.txt" "${CONFIG_FILE}" + fi + sync + #umount ${BOOT_DIR} + #reboot + exit 1 +} + +if [ "${ROOT}" != "file" ]; then + log_begin_msg "loop_rootfs skip non file ROOT ${ROOT}" + log_end_msg + exit 0 +fi + +log_begin_msg "loop_rootfs" +mkdir -p ${BOOT_DIR} + +# force fix verbose fseek, using undocumented options '-f', '-y' +#while ! fsck -f -y -V -t vfat "${BOOT_PART}"; do +# panic "The vfat filesystem on ${BOOT_PART} requires a manual fsck" +#done + +#if ! mount ${BOOT_PART} ${BOOT_DIR}; then +# panic "loop_rootfs could not mount /boot." +# exit 1 +#fi + +if [ ! -f "${CONFIG_FILE}" ]; then + panic "loop_rootfs could not find ${CONFIG_FILE}." + exit 1 +fi + +OS_PREFIX=$(grep os_prefix ${CONFIG_FILE} | awk -F = ' { print substr($2,0, length($2)-1) }') +if [ -z "${OS_PREFIX}" ]; then + panic "loop_rootfs no os_prefix defined in ${CONFIG_FILE}." + exit 1 +fi + +if [ -f "${OS_PREFIX_FILE_LAST}" ]; then + BOOT_COUNTER=$(cat "${BOOT_COUNTER_FILE}") + if [ -n "$BOOT_COUNTER" -a $BOOT_COUNTER -eq $BOOT_COUNTER 2> /dev/null ]; then + # BOOT_COUNTER is a number + if [ $BOOT_COUNTER -gt 0 ]; then + # Fallback to OS_PREFIX_LAST, booted once already without being cleared! + OS_PREFIX_LAST=$(cat "${OS_PREFIX_FILE_LAST}") + IMAGE_FILE="${BOOT_DIR}/${OS_PREFIX_LAST}/rootfs.img" + if ! check_fsfile "${IMAGE_FILE}"; then + # IMAGE_FILE not existing for OS_PREFIX_FILE_LAST or its fstype unknown + # Next: factory default OS_PREFIX_DEFAULT + log_failure_msg "loop_rootfs fallback ${OS_PREFIX_LAST} image file ${IMAGE_FILE} non existent or corrupt. Next factory default ${OS_PREFIX_DEFAULT}. Reboot..." + fallback_rootfs "${OS_PREFIX}" "${OS_PREFIX_DEFAULT}" + else + # Next: factory default OS_PREFIX_LAST + log_success_msg "loop_rootfs fallback ${OS_PREFIX} -> previous ${OS_PREFIX_LAST}, counter ${BOOT_COUNTER}. Reboot..." + fallback_rootfs "${OS_PREFIX}" "${OS_PREFIX_LAST}" + fi + exit 1 + else + # Testing new OS_PREFIX 1st boot: BOOT_COUNTER -> 1 + let BOOT_COUNTER=${BOOT_COUNTER} + 1 + echo ${BOOT_COUNTER} > "${BOOT_COUNTER_FILE}" + log_success_msg "loop_rootfs testing new ${OS_PREFIX} (counter -> ${BOOT_COUNTER} (1))." + fi + else + # Create BOOT_COUNTER, 1st boot: BOOT_COUNTER -> 1 + BOOT_COUNTER=1 + echo ${BOOT_COUNTER} > "${BOOT_COUNTER_FILE}" + log_success_msg "loop_rootfs testing new ${OS_PREFIX} (counter -> ${BOOT_COUNTER} (2))." + fi +elif [ -f "${BOOT_COUNTER_FILE}" ]; then + # cleanup BOOT_COUNTER_FILE, no OS_PREFIX_FILE_LAST + rm -f "${BOOT_COUNTER_FILE}" +fi + +IMAGE_FILE="${BOOT_DIR}/${OS_PREFIX}/rootfs.img" + +if ! attach_rootfs "${IMAGE_FILE}"; then + log_failure_msg "loop_rootfs could not attach to ${OS_PREFIX}, file ${IMAGE_FILE}." + if [ -n "${OS_PREFIX_LAST}" -a "${OS_PREFIX}" != "${OS_PREFIX_LAST}" ]; then + log_success_msg "loop_rootfs fallback ${OS_PREFIX} -> previous ${OS_PREFIX_LAST}. Reboot..." + fallback_rootfs "${OS_PREFIX}" "${OS_PREFIX_LAST}" + elif [ "${OS_PREFIX}" != "${OS_PREFIX_DEFAULT}" ]; then + log_success_msg "loop_rootfs fallback ${OS_PREFIX} -> factory default ${OS_PREFIX_DEFAULT}. Reboot..." + fallback_rootfs "${OS_PREFIX}" "${OS_PREFIX_DEFAULT}" + else + panic "loop_rootfs could not attach to factory default ${OS_PREFIX}, file ${IMAGE_FILE}. No fallback!" + fi + exit 1 +fi + +log_success_msg "loop_rootfs attached ${OS_PREFIX}, ${ROOTFSTYPE} file ${IMAGE_FILE} to loop-device ${ROOT}." + +log_end_msg + +exit 0 + diff --git a/stage2/01-sys-tweaks/files/initramfs/test/scripts/functions b/stage2/01-sys-tweaks/files/initramfs/test/scripts/functions new file mode 100644 index 0000000..0af3bfd --- /dev/null +++ b/stage2/01-sys-tweaks/files/initramfs/test/scripts/functions @@ -0,0 +1,48 @@ +# -*- shell-script -*- + +_log_msg() +{ + printf "$@" +} + +log_success_msg() +{ + _log_msg "Success: %s\\n" "$*" +} + +log_failure_msg() +{ + _log_msg "Failure: %s\\n" "$*" +} + +log_warning_msg() +{ + _log_msg "Warning: %s\\n" "$*" +} + +log_begin_msg() +{ + _log_msg "Begin: %s ... " "$*" +} + +log_end_msg() +{ + _log_msg "done.\\n" +} + +panic() +{ + echo "$@" + + exit 1 +} + +# Parameter: device node to check +# Echos fstype to stdout +# Return value: indicates if an fs could be recognized +get_fstype () +{ + echo "ext4" + return 0 +} + |