Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 6 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,12 @@ on:
- scripts/release_assets.py
- scripts/release_build_tar.py
- scripts/sign-release.sh
- scripts/build-offline-repository.sh
- scripts/offline_delta.py
- 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 +335,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 }}

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

- uses: actions/upload-artifact@v7
with:
Expand Down
8 changes: 8 additions & 0 deletions docs/RELEASE-NAMING.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ 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 releases with offline-update support include `NanoKVM-OS-<tag>-offline.tar`.
It carries changed NanoKVM components and the dependencies APK must install or
upgrade from the preceding compatible public release. Its signed `base-version`
names the required `nanokvm-release` APK version. The signed `installed-db`
records the resulting package state for the next offline update. The first
public release on a major has no delta.
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
50 changes: 49 additions & 1 deletion docs/UPDATES.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,54 @@ 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 5.x device without internet access

1. On a connected computer, download `NanoKVM-OS-<tag>-offline.tar` from the
target OS release. Each archive updates one specific base version on the
selected Stable or Beta channel. The signed `base-version` file inside
the archive names the required version of the installed `nanokvm-release`
package. Apply successive deltas in order if you are several releases behind.
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, base version, target 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
5.x release matching the selected channel. In an SSH session on the NanoKVM,
check that the archive starts at the installed release, then preview the transaction:

```sh
cd /root/offline-update || exit 1
base=$(cat base-version) || exit 1
installed=$(apk --no-network --repositories-file=/dev/null query --from=installed --fields=version --format=default nanokvm-release)
[ "$installed" = "Version: $base" ] || { echo "This archive requires nanokvm-release $base"; 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 +214,7 @@ removed.

## Package publication and retention

New GitHub Releases contain OS releases only: corresponding source, checksums,
Public 5.x 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 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 offline delta from the preceding public 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
52 changes: 52 additions & 0 deletions scripts/build-offline-repository.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/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/
cp /work/delta/world "$root/etc/apk/world"
cp /work/delta/installed "$root/lib/apk/db/installed"
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
apk_target update
# No global upgrade: already installed providers are eligible, including
# those no longer present in Alpine's rolling stable package indexes.
set -f
# shellcheck disable=SC2046
apk_target add --simulate $(cat /work/delta/roots) > /work/delta/plan
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"
mv "/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.
set -f
# shellcheck disable=SC2046
set -- $(awk -F: '$1 == "P" && ($2 == "nanokvm" || $2 ~ /^nanokvm-/) {print $2}' /work/delta/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 "$@" > /work/delta/offline-plan
cp /work/delta/base-version .
Loading
Loading