1
0

Centralize firmware configuration for tests

This commit is contained in:
2026-03-26 12:21:05 +01:00
parent b14a66ea3d
commit f166a9ffca
7 changed files with 39 additions and 18 deletions

View File

@@ -69,7 +69,7 @@ jobs:
if: steps.check-e2e.outputs.run == 'true' && env.GITEA_ACTIONS != 'true'
run: |
mkdir -p tests/cached_assets
node -e "console.log(JSON.stringify(require('./tests/firmware-config')))" | jq -c '.[]' | while IFS= read -r entry; do
node -e "var c=require('./tests/firmware-config'); console.log(JSON.stringify([c.primary, ...c.others]))" | jq -c '.[]' | while IFS= read -r entry; do
version=$(echo "$entry" | jq -r '.version')
url=$(echo "$entry" | jq -r '.url')
file="tests/cached_assets/kobo-update-${version}.zip"

View File

@@ -14,10 +14,7 @@ if [ -x "$LOCAL_GO_DIR/bin/go" ]; then
fi
FIRMWARE_CONFIG="$(cd .. && pwd)/tests/firmware-config.js"
PRIMARY=$(node -e "
const c = require('$FIRMWARE_CONFIG')[0];
console.log(JSON.stringify(c));
")
PRIMARY=$(node -e "console.log(JSON.stringify(require('$FIRMWARE_CONFIG').primary))")
PRIMARY_VERSION=$(echo "$PRIMARY" | jq -r '.version')
PATCHES_ZIP="$(cd .. && pwd)/web/src/patches/$(echo "$PRIMARY" | jq -r '.patches')"
CHECKSUMS=$(echo "$PRIMARY" | jq -r '.checksums | to_entries | map("\(.key)=\(.value)") | join(",")')

View File

@@ -29,8 +29,8 @@ echo "Built kobopatch successfully."
# Start with an empty blacklist.
echo "{}" > "$BLACKLIST_FILE"
# Iterate over all firmware versions in the config.
CONFIGS=$(node -e "console.log(JSON.stringify(require('$FIRMWARE_CONFIG')))")
# Iterate over all firmware versions in the config (primary + others).
CONFIGS=$(node -e "var c=require('$FIRMWARE_CONFIG'); console.log(JSON.stringify([c.primary, ...c.others]))")
COUNT=$(echo "$CONFIGS" | jq 'length')
for i in $(seq 0 $((COUNT - 1))); do
@@ -39,13 +39,16 @@ for i in $(seq 0 $((COUNT - 1))); do
SHORT_VERSION=$(echo "$ENTRY" | jq -r '.shortVersion')
PATCHES=$(echo "$ENTRY" | jq -r '.patches')
URL=$(echo "$ENTRY" | jq -r '.url')
FIRMWARE_FILE="$CACHED_ASSETS/kobo-update-${VERSION}.zip"
PATCHES_ZIP="$PATCHES_DIR/$PATCHES"
if [ ! -f "$FIRMWARE_FILE" ]; then
echo ""
echo "=== Skipping $VERSION (firmware not downloaded) ==="
continue
echo "=== Downloading firmware $VERSION ==="
mkdir -p "$CACHED_ASSETS"
curl -fL --progress-bar -o "$FIRMWARE_FILE.tmp" "$URL"
mv "$FIRMWARE_FILE.tmp" "$FIRMWARE_FILE"
fi
if [ ! -f "$PATCHES_ZIP" ]; then

View File

@@ -41,7 +41,7 @@ while IFS= read -r line; do
if [ ! -f "$file" ]; then
MISSING+=("$version|$url|$file")
fi
done < <(node -e "console.log(JSON.stringify(require('$FIRMWARE_CONFIG')))" | jq -c '.[]')
done < <(node -e "var c=require('$FIRMWARE_CONFIG'); console.log(JSON.stringify([c.primary, ...c.others]))" | jq -c '.[]')
if [ ${#MISSING[@]} -gt 0 ]; then
echo "The following firmware test assets are not cached locally (~150 MB each):"
@@ -94,7 +94,7 @@ echo "=== Building WASM ==="
echo ""
echo "=== Running WASM integration test ==="
PRIMARY_FW="$CACHED_ASSETS/kobo-update-$(node -e "console.log(require('$FIRMWARE_CONFIG')[0].version)").zip"
PRIMARY_FW="$CACHED_ASSETS/kobo-update-$(node -e "console.log(require('$FIRMWARE_CONFIG').primary.version)").zip"
if [ -f "$PRIMARY_FW" ]; then
"$SCRIPT_DIR/kobopatch-wasm/test-integration.sh"
else

View File

@@ -1,12 +1,16 @@
// Firmware versions used for testing. Shell scripts read this via jq-compatible
// JSON output from: node -e "console.log(JSON.stringify(require('./tests/firmware-config')))"
module.exports = [
{
//
// The primary version is used for WASM integration tests (checksum validation)
// and E2E tests. All versions (primary + others) are used for patch testing.
module.exports = {
primary: {
version: '4.45.23646',
shortVersion: '4.45',
url: 'https://ereaderfiles.kobo.com/firmwares/kobo13/Mar2026/kobo-update-4.45.23646.zip',
patches: 'patches_4.45.zip',
checksums: {
// Modified checksums if the "hide row3" patch is applied.
'usr/local/Kobo/libnickel.so.1.0.0': 'ef64782895a47ac85f0829f06fffa4816d23512d',
'usr/local/Kobo/nickel': '80a607bac515457a6864be8be831df631a01005c',
'usr/local/Kobo/libadobe.so': '02dc99c71c4fef75401cd49ddc2e63f928a126e1',
@@ -16,4 +20,12 @@ module.exports = [
// Used to verify the "restore original firmware" flow extracts correctly.
originalTgzChecksum: 'b5c3307e8e7ec036f4601135f0b741c37b899db4',
},
];
others: [
{
version: '4.38.23648',
shortVersion: '4.38',
url: 'https://ereaderfiles.kobo.com/firmwares/kobo9/Mar2026/kobo-update-4.38.23648.zip',
patches: 'patches_4.38.zip',
},
],
};

View File

@@ -1,19 +1,16 @@
const path = require('path');
const firmwareConfig = require('../firmware-config');
const { primary } = require('../firmware-config');
const CACHED_ASSETS = path.resolve(__dirname, '..', 'cached_assets');
const WEBROOT = path.resolve(__dirname, '..', '..', 'web', 'dist');
const WEBROOT_FIRMWARE = path.join(WEBROOT, '_test_firmware.zip');
// Primary firmware entry (first in config) is used for E2E/integration tests.
const primary = firmwareConfig[0];
const FIRMWARE_PATH = path.join(CACHED_ASSETS, `kobo-update-${primary.version}.zip`);
const EXPECTED_SHA1 = primary.checksums;
const ORIGINAL_TGZ_SHA1 = primary.originalTgzChecksum;
module.exports = {
firmwareConfig,
FIRMWARE_PATH,
WEBROOT,
WEBROOT_FIRMWARE,

View File

@@ -17,5 +17,17 @@
"Default ePub sans-serif font (Gill Sans)",
"Default ePub serif font (Amasis)"
]
},
"4.38": {
"src/libadobe.so.yaml": [
"Remove PDF map widget shown during panning"
],
"src/libnickel.so.1.0.0.yaml": [
"Both page turn buttons go next",
"Customize ComfortLight settings"
],
"src/nickel.yaml": [
"Remove forgot pin button from lock screen"
]
}
}