1
1
#! /bin/bash
2
2
# SPDX-License-Identifier: GPL-2.0-only
3
- # Copyright (C) 2021 Foundries.io Ltd.
3
+ # Copyright (C) 2021-2024 Foundries.io Ltd.
4
4
5
5
# shellcheck disable=SC1091
6
6
. ../../lib/sh-test-lib
@@ -13,7 +13,7 @@ export UBOOT_VAR_TOOL
13
13
UBOOT_VAR_SET_TOOL=fw_setenv
14
14
export UBOOT_VAR_SET_TOOL
15
15
PACMAN_TYPE=" ostree+compose_apps"
16
- UBOOT_IMAGE_NAME= " u-boot.itb"
16
+ UBOOT_IMAGE_PATH= " /sysroot/ostree/deploy/lmp/deploy/ \$ {DEPLOYMENT_HASH}/usr/lib/firmware/ u-boot.itb"
17
17
DEBUG=" false"
18
18
SOTA_CONFDIR=" /etc/sota/conf.d"
19
19
@@ -40,8 +40,15 @@ usage() {
40
40
These change the 'type' variable in 'pacman' section
41
41
of the final .toml file used by aklite. Default is
42
42
ostree+compose_apps
43
- -f u-boot image file name to corrupt. On some machines
44
- u-boot image has different name. Default is u-boot.itb
43
+ -f path to u-boot image file name to corrupt. On some machines
44
+ u-boot image has different name. Default is:
45
+ /sysroot/ostree/deploy/lmp/deploy/\$ {DEPLOYMENT_HASH}/usr/lib/firmware/u-boot.itb
46
+ DEPLOYMENT_HASH is substituted after the OTA update
47
+ is downloaded.
48
+ Additional variable FS_HASH is available to construct
49
+ the final path. FS_HASH is a string that corresponds to
50
+ DEPLOYMENT_HASH ostree commit ID and is used in the
51
+ filesystem paths.
45
52
-d <true|false> Enables more debug messages. Default: false
46
53
"
47
54
}
@@ -52,7 +59,9 @@ while getopts "t:u:s:o:f:d:h" opts; do
52
59
u) UBOOT_VAR_TOOL=" ${OPTARG} " ;;
53
60
s) UBOOT_VAR_SET_TOOL=" ${OPTARG} " ;;
54
61
o) PACMAN_TYPE=" ${OPTARG} " ;;
55
- f) UBOOT_IMAGE_NAME=" ${OPTARG} " ;;
62
+ f) IMAGE_PATH=" ${OPTARG} "
63
+ eval UBOOT_IMAGE_PATH=" ${IMAGE_PATH} "
64
+ ;;
56
65
d) DEBUG=" ${OPTARG} " ;;
57
66
h|* ) usage ; exit 1 ;;
58
67
esac
191
200
192
201
if [ " ${UPGRADE_AVAILABLE} " -eq 1 ]; then
193
202
if [ " ${TYPE} " = " uboot" ]; then
203
+ # obtain new deployment hash
204
+ DEPLOYMENT_HASH=$( ostree admin status | grep pending | awk -F' ' ' {print $2}' )
205
+ FS_HASH=" "
194
206
# add debug print to understand which file is corrupted
195
207
ostree admin status
196
208
for DIRECTORY in /ostree/boot.0/lmp/*
197
209
do
198
210
echo " $DIRECTORY /0 ->"
199
- readlink " $DIRECTORY /0"
211
+ D=$( realpath " $DIRECTORY /0" )
212
+ echo " ${D} "
213
+ if echo " ${D} " | grep " ${DEPLOYMENT_HASH} " ; then
214
+ FS_HASH=${DIRECTORY##*/ }
215
+ fi
200
216
done
217
+ echo " UBOOT_IMAGE_PATH: ${UBOOT_IMAGE_PATH} "
218
+ echo " FS_HASH: ${FS_HASH} "
219
+ echo " DEPLOYMENT_HASH: ${DEPLOYMENT_HASH} "
201
220
202
- # obtain new deployment hash
203
- DEPLOYMENT_HASH=$( ostree admin status | grep pending | awk -F' ' ' {print $2}' )
204
- echo " Corrupting u-boot.itb in /sysroot/ostree/deploy/lmp/deploy/${DEPLOYMENT_HASH} /usr/lib/firmware/${UBOOT_IMAGE_NAME} "
221
+ eval UBOOT_PATH=" ${UBOOT_IMAGE_PATH} "
222
+ echo " Corrupting u-boot.itb in ${UBOOT_PATH} "
205
223
# corrupt u-boot.itb
206
- echo bad > " /sysroot/ostree/deploy/lmp/deploy/ ${DEPLOYMENT_HASH} /usr/lib/firmware/ ${UBOOT_IMAGE_NAME }"
224
+ echo bad > " ${UBOOT_PATH }"
207
225
fi
208
226
if [ " ${TYPE} " = " kernel" ]; then
209
227
cat /etc/os-release
0 commit comments