Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/actions/assemble-release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ inputs:
image:
description: attach the SD image (it is always built, as a check that the packages install)
default: 'true'
offline:
description: include the offline update archive in public releases
default: 'true'
runs:
using: composite
steps:
Expand All @@ -34,6 +37,8 @@ runs:
env:
OUT: ${{ inputs.out }}
KEYS: ${{ inputs.keys }}
BUILD_OFFLINE_UPDATE: ${{ inputs.offline }}
GH_TOKEN: ${{ github.token }}
run: |
python3 scripts/release_build_tar.py "$RUNNER_TEMP/release-build.tar" "$OUT"
# The key options are words: -e FILE, or -d.
Expand All @@ -45,6 +50,7 @@ runs:
env:
OUT: ${{ inputs.out }}
IMAGE: ${{ inputs.image }}
OFFLINE: ${{ inputs.offline }}
run: |
a=$OUT/assets
rm -rf "$a"
Expand All @@ -61,6 +67,9 @@ runs:
if [ -d "$OUT/release/stock-installer" ]; then
cp "$OUT"/release/stock-installer/nanokvm_*.tar.gz "$a/"
fi
if [ "$OFFLINE" = true ] && [ ! -f "$OUT/offline-no-baseline" ]; then
cp "$OUT/release/NanoKVM-OS-$NANOKVM_VERSION-offline.tar" "$a/"
fi
python3 scripts/release_assets.py "$a"
ls -la "$a/public" "$a/packages"
cat "$a/public/SHA256SUMS" "$a/packages/SHA256SUMS"
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
echo "rustdesk=$(changed '^addons/rustdesk/')"
echo "assembly=$(changed '^firmware/(cpu/go-crypto-c906|crypto/openssl-c906)/|^addons/rustdesk/src/(poly1305|salsa20)_c906[.]S$|^platform/kernel/[0-9]+-crypto-')"
echo "openssl=$(changed '^firmware/crypto/openssl-c906/|^platform/sources[.]lock$|^tests/test-openssl-source[.]py$')"
echo "signing=$(changed '^firmware/alpine/(packages/|release[.]env$)|^scripts/(build-alpine-packages|check-ec-key)[.]sh$|^scripts/package-versions[.]py$|^platform/sources[.]lock$|^tests/test-ecdsa-packages[.]py$')"
echo "signing=$(changed '^firmware/alpine/(packages/|release[.]env$)|^scripts/(build-alpine-packages|check-ec-key|build-offline-repository)[.]sh$|^scripts/(package-versions|offline_delta)[.]py$|^platform/sources[.]lock$|^tests/test-(ecdsa-packages|offline-delta)[.]py$')"
echo "safe_update=$(changed '^firmware/alpine/safe-update/')"
echo "server=$(changed '^server-cpp/|^platform/sources[.]lock$')"
} | tee -a "$GITHUB_OUTPUT"
Expand Down Expand Up @@ -203,7 +203,8 @@ jobs:
run: |
docker run --rm -v "$PWD:/src:ro" -w /src alpine:3.24 sh -ec '
apk add --no-cache alpine-sdk alpine-keys python3 openssl coreutils > /dev/null
python3 tests/test-ecdsa-packages.py'
python3 tests/test-ecdsa-packages.py
python3 tests/test-offline-delta.py apk'
- name: Script tests
run: |
set -e
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ name: Release
# environment, so the signing keys are used only after a maintainer approves
# the run. It signs the packages that changed and both indexes, then
# stages them as temporary Actions artifacts for Pages. Public OS releases
# contain corresponding source and checksums; SD image releases also include
# contain the offline update, corresponding source and checksums. SD image releases also include
# the stock Sipeed migration package.
# A patch release is published at once, which publishes its packages (apk-repository.yml); a minor release and a pushed tag
# stay drafts for their notes.
Expand Down Expand Up @@ -59,9 +59,13 @@ on:
- scripts/release_assets.py
- scripts/release_build_tar.py
- scripts/sign-release.sh
- scripts/build-offline-repository.sh
- scripts/offline_delta.py
- firmware/alpine/offline-minimums.json
- scripts/apk_resign.py
- scripts/check-release-key.sh
- scripts/alpine-signer.sh
- tests/test-offline-delta.py
- tests/test-apk-resign.py
- tests/test-release-build-tar.py
- scripts/build-stock-installer.py
Expand Down Expand Up @@ -332,6 +336,7 @@ jobs:
out: ${{ env.OUT }}
keys: -e ${{ runner.temp }}/keys/${{ env.EC_KEY_NAME }}.key
image: ${{ needs.build.outputs.image }}
offline: ${{ inputs.packages_only != true && !contains(needs.build.outputs.version, '-beta') }}

- name: Remove the keys
if: always()
Expand Down Expand Up @@ -410,6 +415,7 @@ jobs:
out: ${{ env.OUT }}
keys: -d
image: ${{ needs.build.outputs.image }}
offline: ${{ inputs.packages_only != true && !contains(needs.build.outputs.version, '-beta') }}

- uses: actions/upload-artifact@v7
with:
Expand Down
12 changes: 12 additions & 0 deletions docs/RELEASE-NAMING.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ full tag so you can keep several release manifests in one directory. GitHub
releases also include an identical `SHA256SUMS` for older stock installers.
Older releases may only provide `SHA256SUMS`.

Public stable releases with offline-update support include `NanoKVM-OS-<tag>-offline.tar`.
It carries changed NanoKVM components and required dependencies for the signed
range `minimum-version <= installed nanokvm-release < target`. By default the
minimum is the previous public stable release on the same major. To support a
wider range, add an entry such as `"v6.0.0": "v5.3.0"` to
`firmware/alpine/offline-minimums.json` before building the target. The minimum
must be a published stable release from 5.x or later. With no eligible baseline
the build skips the archive. Build-time APK simulations cover every public stable
baseline in the range, and the device checks its own installed packages before
applying the update. The signed `installed-db` records the resulting package state.
Beta releases and Pages-only OTA publications omit this download.

Releases that include an SD image also include the
[stock migration package](STOCK-INSTALL.md). Its numeric `nanokvm_X.Y.Z.tar.gz`
filename is required by the Sipeed offline updater; do not rename it. The
Expand Down
58 changes: 57 additions & 1 deletion docs/UPDATES.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,62 @@ Completed component transactions refresh affected services through
separate apply command is required. `nanokvm-bootloader` also updates the bootloader on the SD card. It verifies the written file and
keeps `/boot/fip.prev` for recovery; see [bootloader updates](BOOT.md#updating-fipbin).

## Updating a Stable device without internet access

1. On a connected computer, download `NanoKVM-OS-<tag>-offline.tar` from the
target stable OS release. The signed `minimum-version` file gives the oldest
supported `nanokvm-release`. An archive for 6.0.0 with a minimum of 5.3.0
can upgrade 5.3.0 or 5.4.0 directly. On 5.1.2, first install a compatible
intermediate release. Beta devices use the online updater.
2. Open **Settings → System → Updates → Install update from file** on the
NanoKVM. Choose the intact tar file and confirm its name. The upload
progress is followed by the usual package installation log.
3. Reboot if the update page requests it.

The archive targets new or changed NanoKVM OS components and bundled modules.
It includes an Alpine package only when the base installation needs it to meet
the dependencies of those components or their libraries. APK reuses installed
libraries that already meet the requirements. Before installation the updater
verifies the archive signature, supported version range, channel and APK transaction.
It reports missing dependencies or conflicting local packages in
the update log. Allow space on the system partition for the upload, unpacking
and installation. Package-only hotfixes on Pages have no GitHub release archive.

### First offline upgrade from a 5.x version without the file picker

NanoKVM OS 5.0.1 predates the file picker. The first upgrade on an isolated
device can use the same archive as a local APK repository. On a trusted
computer, verify the archive against the SHA-256 published with the release,
extract it into an empty directory, and copy the directory to private system
storage on the NanoKVM (for example `/root/offline-update`). Use a newer
stable release on the Stable channel. In an SSH session on the NanoKVM,
check the supported version range, then preview the transaction:

```sh
cd /root/offline-update || exit 1
minimum=$(cat minimum-version) || exit 1
installed=$(apk --no-network --repositories-file=/dev/null query --from=installed --fields=version --format=default nanokvm-release)
installed=${installed#Version: }
set -- nanokvm-release-*.apk
[ "$#" -eq 1 ] && [ -f "$1" ] || exit 1
target=${1#nanokvm-release-}
target=${target%.apk}
case "$installed" in *'_'*|'') exit 1 ;; esac
case "$(apk version -t "$installed" "$minimum")" in '='|'>') ;; *) echo "Requires NanoKVM OS $minimum or newer"; exit 1 ;; esac
[ "$(apk version -t "$installed" "$target")" = '<' ] || exit 1
# Use the already installed NanoKVM packages as the upgrade targets.
set -- $(apk --no-network --repositories-file=/dev/null query --from=installed --fields=name --format=default 'nanokvm' 'nanokvm-*' | sed -n 's/^Name: //p')
[ "$#" -gt 0 ] || exit 1
repo=$PWD/Packages.adb
apk --no-network --no-cache --repositories-file=/dev/null --repository="$repo" upgrade --no-self-upgrade --simulate "$@"
```

Check that the plan upgrades `nanokvm-release` to the expected version
and preserves the packages you want to keep. Once satisfied, run the same
command without `--simulate`. The installed trust keys are used, and the
device's repository configuration stays in place. After a successful
upgrade you can delete the copied directory and reboot if requested.

## Update notices and component versions

**Settings → System → Updates** lists the installed NanoKVM OS packages, the
Expand Down Expand Up @@ -166,7 +222,7 @@ removed.

## Package publication and retention

New GitHub Releases contain OS releases only: corresponding source, checksums,
Public stable releases with offline-update support include the signed offline bundle, corresponding source, checksums,
and, when built, the SD image and stock migration archive. APKs, indexes and
the downloads of packages released on their own live on GitHub Pages. Their
version tags reserve package revisions without creating GitHub Releases. The
Expand Down
1 change: 1 addition & 0 deletions firmware/alpine/offline-minimums.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions platform/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Every upstream input is pinned in `sources.lock` and checked when it is download
| `release/apk/` | the signed APK repository of the OS packages: `recipes/riscv64/` with the packages, `APKINDEX.tar.gz` and `Packages.adb`, and the public keys |
| `release/alpine-rootfs.tar.gz`, `release/installed-packages.txt`, `release/installed-licenses.txt` | the root file system, its package versions and their declared licenses |
| `release/image/NanoKVM-OS-<version>.img.zip`, `SHA256SUMS` | the SD card image |
| `release/NanoKVM-OS-<tag>-offline.tar` | a signed Stable-channel offline delta with a signed minimum installed OS version |
| `release/stock-installer/nanokvm_X.Y.Z.tar.gz`, `SHA256SUMS` | stock Sipeed migration package (`stock-installer` step; included with SD image releases) |

## Release and installation versions
Expand Down
56 changes: 56 additions & 0 deletions scripts/build-offline-repository.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/sh
# Plan against the public base's installed packages. No APK payload, maintainer
# script or transaction hook ever runs in the signer.
set -eu
export LC_ALL=C
root=/work/offline-root
apk_target() {
apk --arch riscv64 --root "$root" --keys-dir /work/offline-keys \
--repositories-file /work/offline-repositories "$@"
}
if [ "$1" = plan ]; then
mkdir -p /work/offline /work/fetched /work/offline-keys "$root/lib/apk/db" "$root/etc/apk" "$root/var/cache/apk"
cp /usr/share/apk/keys/riscv64/*.pub /work/published/*.pub /work/release/*.pub /work/offline-keys/
printf '%s\n' /work/repo/Packages.adb "$(cat /work/addons.list)" \
https://dl-cdn.alpinelinux.org/alpine/v3.24/main \
https://dl-cdn.alpinelinux.org/alpine/v3.24/community > /work/offline-repositories
# No global upgrade: already installed providers are eligible, including
# those no longer present in Alpine's rolling stable package indexes.
for base in /work/delta/bases/*; do
cp "$base/world" "$root/etc/apk/world"
cp "$base/installed" "$root/lib/apk/db/installed"
if [ "$base" = /work/delta/bases/0 ]; then apk_target update; fi
# shellcheck disable=SC2046
apk_target add --simulate $(cat "$base/roots") > "$base/plan"
done
exit
fi

# Only solver-selected coordinates reach the repository. Fetch uses the
# authenticated source indexes, including the index-only-signed add-ons.
cd /work/offline
while IFS='=' read -r name revision; do
file=$name-$revision.apk
if [ -f "/work/repo/$file" ]; then
cp "/work/repo/$file" .
else
apk_target fetch --all-matches --output /work/fetched "$name"
cp "/work/fetched/$file" .
fi
done < /work/delta/fetch
apk --sign-key /work/keys/release.key --allow-untrusted mkndx \
--description "NanoKVM OS $2 offline" --output Packages.adb ./*.apk
apk --keys-dir /work/release verify Packages.adb
apk --keys-dir /work/release adbdump --format=json Packages.adb > /work/delta/selected.json
# Exercise the device transaction using its installed NanoKVM targets and only the staged files.
for base in /work/delta/bases/*; do
cp "$base/world" "$root/etc/apk/world"
cp "$base/installed" "$root/lib/apk/db/installed"
# shellcheck disable=SC2046
set -- $(awk -F: '$1 == "P" && ($2 == "nanokvm" || $2 ~ /^nanokvm-/) {print $2}' "$base/installed")
[ "$#" -gt 0 ] || exit 1
apk --root "$root" --arch riscv64 --keys-dir /work/release --no-network --no-cache \
--repositories-file=/dev/null --repository=/work/offline/Packages.adb \
upgrade --no-self-upgrade --simulate "$@" > "$base/offline-plan"
done
cp /work/delta/minimum-version .
Loading