Skip to content
Snippets Groups Projects
Commit c71c8b53 authored by Denis Pynkin's avatar Denis Pynkin
Browse files

OTA ROLLBACK: test rollback and blacklist


Add the test for checking non-successful update during OTA update.

Signed-off-by: default avatarDenis Pynkin <denis.pynkin@collabora.com>
parent 88676e92
No related branches found
No related tags found
2 merge requests!10v2020: add OTA update tests,!9Add OTA tests
#!/bin/sh
set -ex
. ./update-manager-common.sh
phase_boot()
{
# Prepare the skiplist
# Rationale: https://phabricator.apertis.org/T5881
# In additon: remove updatectl to prevent from marking update as successful
ls -1d /usr/share/locale /usr/share/man /usr/share/zoneinfo /usr/bin/updatectl > /tmp/skip
ostree admin status
# Set the couner to rollback situation
# Use old format to be compatible with the first implementation of the counter
# echo "bc 00" | xxd -r -p /boot/uboot.cnt
# New format (depending on U-Boot installed):
echo "bd 01 00 01" | xxd -r -p /boot/uboot.cnt
# Create a new commit based on current deployment, but older and without files from a skip list
BRANCHNAME="apertis/${RELEASE}/${ARCH}-${BOARD}/${IMGTYPE}"
CURREV=$(ostree rev-parse origin:$BRANCHNAME)
ostree commit -b $BRANCHNAME --tree=ref=$CURREV --timestamp="1 year ago" --skip-list=/tmp/skip
OLDREV=$(ostree rev-parse $BRANCHNAME)
ostree admin upgrade --allow-downgrade --deploy-only --override-commit=$OLDREV
# Store the current revision for use in tests later
echo $CURREV > $(get_phase_data_path)
}
phase_check_update()
{
ostree admin status
local PHASE_DATA=$(get_phase_data_path)
local COMMIT_BEFORE=$(cat $PHASE_DATA)
# The current commit after the update
local COMMIT_AFTER="$(ostree admin status | sed -n -e 's/^\* apertis \([0-9a-f]*\)\.[0-9]$/\1/p')"
# Ensure to have \xbc\x0[12345] in the bootcount
od -tx1 /boot/uboot.cnt
if [ "$COMMIT_BEFORE" = "$COMMIT_AFTER" ] ; then
echo "The update did not apply, the current commit is the same as the initial commit"
exit 1
fi
# Wait long enough so that we are sure the bootcount has not been reset
sleep 30
}
phase_check_rollback()
{
ostree admin status
local PHASE_DATA=$(get_phase_data_path)
local COMMIT_BEFORE=$(cat $PHASE_DATA)
# The current commit after the update
local COMMIT_AFTER="$(ostree admin status | sed -n -e 's/^\* apertis \([0-9a-f]*\)\.[0-9]$/\1/p')"
# after the rollback, the apertis update manager resets the bootcount
# Ensure to have \xbc\x00 in the bootcount
od -tx1 /boot/uboot.cnt
if [ "$COMMIT_BEFORE" != "$COMMIT_AFTER" ] ; then
echo "The update did not rollback, the current commit is the same"
exit 1
fi
# Must exists and contain "failed" upgrade
cat /var/aum_blacklist.conf
# Create a new commit with the same content as the current deployment, but older
BRANCHNAME="apertis/${RELEASE}/${ARCH}-${BOARD}/${IMGTYPE}"
ostree commit -b $BRANCHNAME --tree=ref=$COMMIT_BEFORE --timestamp="1 year ago"
OLDREV=$(ostree rev-parse $BRANCHNAME)
ostree admin upgrade --os=apertis --allow-downgrade --deploy-only --override-commit=$OLDREV
# Add the newest commit on server side into blacklist to prevent upgrading
# Usually it should be the same as installed
ostree pull --commit-metadata-only --depth=1 origin "$BRANCHNAME"
BLACKLISTREV=$(ostree rev-parse origin:$BRANCHNAME)
echo "$BLACKLISTREV=true" >> /var/aum_blacklist.conf
sync
}
phase_clean_previous_install()
{
ostree admin status
# Remove the origin branch
BRANCHNAME="apertis/${RELEASE}/${ARCH}-${BOARD}/${IMGTYPE}"
ostree admin undeploy 1
ostree refs --delete master
}
phase_check_blacklist()
{
ostree admin status
cat /var/aum_blacklist.conf
# OTA update is blacklisted
if apply_update_sync -o ; then
exit 1
fi
}
update_manager_phases\
phase_boot\
phase_check_update\
phase_check_rollback\
phase_clean_previous_install\
phase_check_blacklist
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment