feat(gui): post-install verify, flash-plan checklist; backend helpers
Stock->alkane re-scan flicker: after a successful install the just-installed
boards are held in a "verifying alkane..." state and a stock re-scan row is
suppressed until the board answers as alkane, with a bounded give-up window.
Fixes the board re-scanning as stock before finally showing alkane.
Flash-plan checklist: picking a local .afw in the install dialog now detects
the flash tier and shows a [x]/[ ] checklist of what it overwrites (U-Boot /
Kernel / Userspace), read from the bundle manifest. Verified end-to-end under
a virtual display: a zynq-7010 .afw shows tier 2, U-Boot preserved, kernel and
userspace written.
Backend helpers (alkane-artifacts, additive, unit-tested):
- AfwManifest::flash_plan() -> FlashPlan { tier, writes_uboot, writes_kernel,
writes_userspace }.
- ReleaseSource::for_repo(owner, repo) and ReleaseInfo::compatible_boards /
is_compatible_with, for the upcoming any-repo picker with board-compat
detection.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B1W6qKwKxq3oUPDKWicM6i
This commit is contained in:
@@ -60,6 +60,14 @@ impl ReleaseSource {
|
||||
/// The alkane-os release source, honoring `ALKANE_RELEASE_BASE` and a token
|
||||
/// from `ALKANE_RELEASE_TOKEN` or `GITEA_TOKEN`.
|
||||
pub fn alkane_os() -> Self {
|
||||
Self::for_repo("blueflare", "alkane-os")
|
||||
}
|
||||
|
||||
/// A release source for an arbitrary Gitea `owner`/`repo`. The base URL
|
||||
/// (`ALKANE_RELEASE_BASE`, else the self-hosted Gitea) and the token
|
||||
/// (`ALKANE_RELEASE_TOKEN`, else `GITEA_TOKEN`, else the build-time embedded
|
||||
/// token) are resolved exactly as for `alkane_os`.
|
||||
pub fn for_repo(owner: &str, repo: &str) -> Self {
|
||||
let base_url = std::env::var("ALKANE_RELEASE_BASE")
|
||||
.ok()
|
||||
.filter(|s| !s.is_empty())
|
||||
@@ -71,8 +79,8 @@ impl ReleaseSource {
|
||||
.or_else(|| EMBEDDED_TOKEN.map(str::to_string).filter(|t| !t.is_empty()));
|
||||
Self {
|
||||
base_url,
|
||||
owner: "blueflare".to_string(),
|
||||
repo: "alkane-os".to_string(),
|
||||
owner: owner.to_string(),
|
||||
repo: repo.to_string(),
|
||||
token,
|
||||
}
|
||||
}
|
||||
@@ -223,6 +231,18 @@ pub fn fetch_latest_afw(
|
||||
Ok(dest)
|
||||
}
|
||||
|
||||
/// Board tokens recognised in `.afw` asset names (the `-<board>-` filename
|
||||
/// segment). Used by `ReleaseInfo::compatible_boards`.
|
||||
pub const KNOWN_BOARDS: &[&str] = &[
|
||||
"zynq-7010",
|
||||
"am335x",
|
||||
"cv1835",
|
||||
"a113d",
|
||||
"allwinner-h3",
|
||||
"allwinner-h6",
|
||||
"allwinner-h616",
|
||||
];
|
||||
|
||||
/// One `.afw` asset in a release.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct AfwAsset {
|
||||
@@ -249,6 +269,30 @@ impl ReleaseInfo {
|
||||
let needle = format!("-{board}-");
|
||||
self.afw_assets.iter().find(|a| a.name.contains(&needle))
|
||||
}
|
||||
|
||||
/// The distinct board tokens (from `KNOWN_BOARDS`) this release carries an
|
||||
/// `.afw` for, detected from the asset filenames (`-<board>-` segment, e.g.
|
||||
/// `alkane-os-0.1.2-zynq-7010-armv7.afw` -> `zynq-7010`). Ordered by first
|
||||
/// appearance across the assets; a release with no recognised board yields an
|
||||
/// empty list.
|
||||
pub fn compatible_boards(&self) -> Vec<String> {
|
||||
let mut boards: Vec<String> = Vec::new();
|
||||
for asset in &self.afw_assets {
|
||||
for board in KNOWN_BOARDS {
|
||||
let needle = format!("-{board}-");
|
||||
if asset.name.contains(&needle) && !boards.iter().any(|b| b == board) {
|
||||
boards.push((*board).to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
boards
|
||||
}
|
||||
|
||||
/// Whether this release has an `.afw` for `board` (same match as
|
||||
/// `asset_for_board`).
|
||||
pub fn is_compatible_with(&self, board: &str) -> bool {
|
||||
self.asset_for_board(board).is_some()
|
||||
}
|
||||
}
|
||||
|
||||
/// Parse a Gitea releases array (newest first) into `ReleaseInfo`s, keeping only
|
||||
@@ -401,4 +445,84 @@ mod tests {
|
||||
);
|
||||
assert!(parsed[1].asset_for_board("zynq-7010").is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn for_repo_builds_the_api_url_for_a_custom_repo() {
|
||||
std::env::remove_var("ALKANE_RELEASE_BASE");
|
||||
let src = ReleaseSource::for_repo("someorg", "some-firmware");
|
||||
assert_eq!(src.owner, "someorg");
|
||||
assert_eq!(src.repo, "some-firmware");
|
||||
assert_eq!(
|
||||
src.api_list(),
|
||||
"https://gitea.bluefla.re/api/v1/repos/someorg/some-firmware/releases?limit=50"
|
||||
);
|
||||
// alkane_os() is for_repo("blueflare", "alkane-os").
|
||||
let os = ReleaseSource::alkane_os();
|
||||
assert_eq!(
|
||||
(os.owner.as_str(), os.repo.as_str()),
|
||||
("blueflare", "alkane-os")
|
||||
);
|
||||
}
|
||||
|
||||
fn release_with(names: &[&str]) -> ReleaseInfo {
|
||||
ReleaseInfo {
|
||||
tag: "v0.1.2".into(),
|
||||
name: String::new(),
|
||||
prerelease: false,
|
||||
draft: false,
|
||||
published_at: String::new(),
|
||||
afw_assets: names
|
||||
.iter()
|
||||
.map(|n| AfwAsset {
|
||||
name: (*n).to_string(),
|
||||
url: format!("https://example.invalid/{n}"),
|
||||
})
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn compatible_boards_extracts_board_tokens_from_asset_names() {
|
||||
let single = release_with(&["alkane-os-0.1.2-zynq-7010-armv7.afw"]);
|
||||
assert_eq!(single.compatible_boards(), vec!["zynq-7010"]);
|
||||
|
||||
// Multi-board release: distinct boards in first-appearance order,
|
||||
// duplicates (a second arch build of one board) collapse.
|
||||
let multi = release_with(&[
|
||||
"alkane-os-0.1.2-am335x-armv7.afw",
|
||||
"alkane-os-0.1.2-zynq-7010-armv7.afw",
|
||||
"alkane-os-0.1.2-allwinner-h616-aarch64.afw",
|
||||
"alkane-os-0.1.2-am335x-arm.afw",
|
||||
"alkane-os-0.1.2-cv1835-riscv64.afw",
|
||||
]);
|
||||
assert_eq!(
|
||||
multi.compatible_boards(),
|
||||
vec!["am335x", "zynq-7010", "allwinner-h616", "cv1835"]
|
||||
);
|
||||
|
||||
// allwinner-h6 must not match an allwinner-h616 asset (and vice versa).
|
||||
let h616 = release_with(&["alkane-os-0.1.2-allwinner-h616-aarch64.afw"]);
|
||||
assert_eq!(h616.compatible_boards(), vec!["allwinner-h616"]);
|
||||
let h6 = release_with(&["alkane-os-0.1.2-allwinner-h6-aarch64.afw"]);
|
||||
assert_eq!(h6.compatible_boards(), vec!["allwinner-h6"]);
|
||||
|
||||
// No .afw assets, or an unrecognised board, yields nothing.
|
||||
assert!(release_with(&[]).compatible_boards().is_empty());
|
||||
assert!(release_with(&["alkane-os-0.1.2-mystery-board-arm.afw"])
|
||||
.compatible_boards()
|
||||
.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn is_compatible_with_matches_asset_for_board() {
|
||||
let rel = release_with(&[
|
||||
"alkane-os-0.1.2-zynq-7010-armv7.afw",
|
||||
"alkane-os-0.1.2-a113d-aarch64.afw",
|
||||
]);
|
||||
assert!(rel.is_compatible_with("zynq-7010"));
|
||||
assert!(rel.is_compatible_with("a113d"));
|
||||
assert!(!rel.is_compatible_with("am335x"));
|
||||
assert!(!rel.is_compatible_with("allwinner-h6"));
|
||||
assert!(!release_with(&[]).is_compatible_with("zynq-7010"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user