Skip to content

Commit

Permalink
Update mender client commit support
Browse files Browse the repository at this point in the history
Move verify boot slot alignment scripts into separate files so we
can support the client commit service in non redundant bootloader
cases like t210 and cboot cases where no verification is necessary

Signed-off-by: Dan Walkes <danwalkes@boulderai.com>
  • Loading branch information
dwalkes committed Nov 7, 2020
1 parent 98e373c commit 8a559c8
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 14 deletions.
12 changes: 8 additions & 4 deletions meta-mender-tegra/recipes-mender/mender-client/files/mender
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@

echo "Starting mender wrapper"

echo $@ | grep 'install\|-install' > /dev/null
# Did the user specify standalone install mode?
echo $@ | grep ' install \| -install ' > /dev/null
if [ $? -eq 0 ]; then
install_arg=true
# Exit with failure and error message if we don't have alignment
# between boot slot and rootfs. It's not safe to update in this case
/etc/mender/verify-boot-rootfs-slot-alignment-uboot || exit 1
fi

# Call the base mender executable, renamed
mender_override $@

rc=$?
if [ $rc -eq 0 ]; then
echo $@ | grep 'install\|-install' > /dev/null
if [ $? -eq 0 ]; then
if [ "$install_arg" = true ]; then
# Add a marker to show update was successful, for auto-commit script
touch /var/lib/mender/mender-install-success
fi
fi

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

/etc/mender/verify-boot-rootfs-slot-alignment-uboot || exit 0
/etc/mender/verify-boot-rootfs-slot-alignment || exit 0

if [ -f /var/lib/mender/mender-install-success ]; then
/usr/bin/mender -commit
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh
nvbootctrl_slot=`nvbootctrl get-current-slot`
echo "Current boot slot is ${nvbootctrl_slot}"
echo "Boot slot misalignment is not possible on cboot based tegra platforms"
exit 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
echo "This tegra platform does not support redundant bootloader"
exit 0
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ else
echo "Verified"
fi

exit 0
exit 0
Original file line number Diff line number Diff line change
@@ -1,25 +1,66 @@
RDEPENDS_${PN}_append_tegra = "${@' tegra-bup-payload libubootenv-fake' if d.getVar('PREFERRED_PROVIDER_virtual/bootloader').startswith('cboot') else ''}"

FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
SRC_URI_append_mender-uboot = " \
SRC_URI_append = " \
file://mender \
file://mender-client-commit.service \
file://mender-client-commit.sh \
file://verify-boot-rootfs-slot-alignment-uboot \
file://verify-boot-rootfs-slot-alignment-cboot \
file://verify-boot-rootfs-slot-alignment-no-redundant-bootloader \
"

FILES_${PN}_append_mender-uboot = " ${systemd_system_unitdir}/mender-client-commit.service"
FILES_${PN}_append_mender-uboot = " ${sysconfdir}/mender/mender-client-commit.sh"
FILES_${PN}_append_mender-uboot = " ${bindir}/mender"
FILES_${PN}_append_mender-uboot = " ${sysconfdir}/mender/verify-boot-rootfs-slot-alignment-uboot"
FILES_${PN} += " \
${systemd_system_unitdir}/mender-client-commit.service \
${sysconfdir}/mender/mender-client-commit.sh \
${bindir}/mender_base \
${sysconfdir}/mender/verify-boot-rootfs-slot-alignment \
"

SYSTEMD_SERVICE_${PN}_append_mender-uboot = " mender-client-commit.service"
SYSTEMD_SERVICE_${PN} += "mender-client-commit.service"

do_install_append_mender-uboot() {
install_commit_service() {
# Rename the mender binary as mender_override. We'll override with a script that records how it's used
mv ${D}${bindir}/mender ${D}${bindir}/mender_override
install -m 0755 ${WORKDIR}/mender ${D}${bindir}/mender
install -d ${D}${sysconfdir}/mender/scripts
install -m 0755 ${WORKDIR}/mender-client-commit.sh ${D}${sysconfdir}/mender/mender-client-commit.sh
install -m 0644 ${WORKDIR}/mender-client-commit.service ${D}${systemd_system_unitdir}/mender-client-commit.service
install -m 0755 ${WORKDIR}/verify-boot-rootfs-slot-alignment-uboot ${D}${sysconfdir}/mender/verify-boot-rootfs-slot-alignment-uboot
}

# By default, install the cboot version of the slot alignment verify script
install_slot_align_verify() {
install -m 0755 ${WORKDIR}/verify-boot-rootfs-slot-alignment-cboot ${D}${sysconfdir}/mender/verify-boot-rootfs-slot-alignment
}


# When mender-uboot override is defined, install the u-boot version. This one is important for ensuring slots are aligned
# between uboot and the rootfs before taking actions like update
install_slot_align_verify_mender-uboot() {
install -m 0755 ${WORKDIR}/verify-boot-rootfs-slot-alignment-uboot ${D}${sysconfdir}/mender/verify-boot-rootfs-slot-alignment
}

# This verify script is a no-op, since there's nothing to do if redundant bootloader is not supported
install_slot_align_verify_no-redundant-bootloader() {
install -m 0755 ${WORKDIR}/verify-boot-rootfs-slot-alignment-no-redundant-bootloader ${D}${sysconfdir}/mender/verify-boot-rootfs-slot-alignment
}

# Tegra 210 (nano) platforms don't support redundant bootloader today
# Use the version of the slot alignment verify script which doesn't use redundant bootloader
do_install_append_tegra210() {
install_commit_service
install_slot_align_verify_no-redundant-bootloader
}

do_install_append_tegra194() {
install_commit_service
install_slot_align_verify
}

do_install_append_tegra186() {
install_commit_service
# If building the uboot build, the slot alignment verify script will be installed by override here
install_slot_align_verify
}

PACKAGE_ARCH = "${MACHINE_ARCH}"

0 comments on commit 8a559c8

Please sign in to comment.