Fennec OS 0.3.2: one app at a time, Raspberry Pi shell packages
- sf-core: only one app runs. Home, another app or a cast closes the app
on screen (after the switch animation) instead of freezing it in the
background. A frozen app that held a sound stream stalled PipeWire, so
the next app could not play at all ("Failed to connect stream: No such
entity" in Netflex after YouTube was sent home mid-video). The
background limit and the low-memory watcher go with the freezing.
- Raspberry Pi: image/pi (installer on Raspberry Pi OS), aarch64 shell
packages (sf-shell-<v>-aarch64, arch in pkg.toml, sf-update installs only
its own architecture), CI builds the aarch64 shell too.
- sf-compositor: volume OSD, screencopy for remote view, blank cursor.
- SDK v0.1.2.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -149,8 +149,7 @@ fn app_entry(agent: &ureq::Agent, repo: &Repo) -> Result<Option<CatalogApp>> {
|
||||
let app: AppManifest = toml::from_str(&forge::asset_text(agent, manifest_asset)?).context("app.toml")?;
|
||||
app.check_store_rules()?;
|
||||
anyhow::ensure!(crate::registry::is_release(&app.version), "version {} is not a release version (1.2.3)", app.version);
|
||||
let file = format!("{}-{}.tar.zst", app.id, app.version);
|
||||
let package = release.asset(&file).with_context(|| format!("release {} has no {file}", release.tag))?;
|
||||
let package = package_asset(&release, &app)?;
|
||||
Ok(Some(CatalogApp {
|
||||
id: app.id.clone(),
|
||||
name: app.name.clone(),
|
||||
@@ -171,6 +170,24 @@ fn app_entry(agent: &ureq::Agent, repo: &Repo) -> Result<Option<CatalogApp>> {
|
||||
}))
|
||||
}
|
||||
|
||||
/// The release's package for this TV (docs/store.md): `<id>-<version>.tar.zst`
|
||||
/// on x86-64, `<id>-<version>-aarch64.tar.zst` on ARM. A web app is the same
|
||||
/// everywhere, so its plain package is fine on any architecture; an exec app's
|
||||
/// plain package is an x86-64 build.
|
||||
fn package_asset<'a>(release: &'a forge::Release, app: &AppManifest) -> Result<&'a forge::Asset> {
|
||||
let plain = format!("{}-{}.tar.zst", app.id, app.version);
|
||||
let native = crate::arch::file_name(&app.id, &app.version);
|
||||
if let Some(a) = release.asset(&native) {
|
||||
return Ok(a);
|
||||
}
|
||||
if !crate::arch::IS_DEFAULT && app.kind == sf_ipc::manifest::AppKind::Web {
|
||||
if let Some(a) = release.asset(&plain) {
|
||||
return Ok(a);
|
||||
}
|
||||
}
|
||||
anyhow::bail!("release {} has no {native}", release.tag)
|
||||
}
|
||||
|
||||
/// Marks what's installed and what's held back, and returns the store
|
||||
/// packages to download (new installs and updates).
|
||||
pub fn plan(store: &Store, wanted: &Wanted, catalog: &mut Catalog) -> BTreeMap<String, (String, StoreDownload)> {
|
||||
|
||||
45
crates/sf-update/src/arch.rs
Normal file
45
crates/sf-update/src/arch.rs
Normal file
@@ -0,0 +1,45 @@
|
||||
//! The CPU architecture of this TV, and how packages built for it are named
|
||||
//! (docs/updates.md, "Architektúrák").
|
||||
//!
|
||||
//! Fennec OS started on x86-64: its package files carry no architecture
|
||||
//! (`sf-shell-1.2.0.tar.zst`). Packages for any other architecture have a
|
||||
//! suffix (`sf-shell-1.2.0-aarch64.tar.zst`).
|
||||
|
||||
/// This build's architecture, as in Rust's `std::env::consts::ARCH`.
|
||||
pub const NAME: &str = std::env::consts::ARCH;
|
||||
|
||||
/// Whether this is the original architecture (unsuffixed package files).
|
||||
pub const IS_DEFAULT: bool = cfg!(target_arch = "x86_64");
|
||||
|
||||
/// `name-version.tar.zst` for this architecture.
|
||||
pub fn file_name(name: &str, version: &str) -> String {
|
||||
if IS_DEFAULT { format!("{name}-{version}.tar.zst") } else { format!("{name}-{version}-{NAME}.tar.zst") }
|
||||
}
|
||||
|
||||
/// Whether a package that says it was built for `arch` (pkg.toml; missing =
|
||||
/// an old package, built for x86-64) runs here.
|
||||
pub fn runs_here(arch: Option<&str>) -> bool {
|
||||
match arch {
|
||||
Some(a) => a == NAME,
|
||||
None => IS_DEFAULT,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn names() {
|
||||
if IS_DEFAULT {
|
||||
assert_eq!(file_name("sf-shell", "1.2.0"), "sf-shell-1.2.0.tar.zst");
|
||||
assert!(runs_here(None));
|
||||
assert!(!runs_here(Some("aarch64")));
|
||||
} else {
|
||||
assert_eq!(file_name("sf-shell", "1.2.0"), format!("sf-shell-1.2.0-{NAME}.tar.zst"));
|
||||
assert!(!runs_here(None));
|
||||
assert!(!runs_here(Some("x86_64")));
|
||||
}
|
||||
assert!(runs_here(Some(NAME)));
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@
|
||||
//! sf-update status print status.json
|
||||
|
||||
mod appstore;
|
||||
mod arch;
|
||||
mod config;
|
||||
mod forge;
|
||||
mod migrate;
|
||||
|
||||
@@ -2,6 +2,11 @@
|
||||
//!
|
||||
//! list: GET {server}/api/v1/packages/{owner}?type=generic&q=sf-
|
||||
//! download: GET {server}/api/packages/{owner}/generic/{name}/{version}/{name}-{version}.tar.zst (+ .sig)
|
||||
//! files: GET {server}/api/v1/packages/{owner}/generic/{name}/{version}/files
|
||||
//!
|
||||
//! The shell is native code: on any architecture but x86-64 its file has a
|
||||
//! suffix (`sf-shell-1.2.0-aarch64.tar.zst`, crate::arch). App packages are
|
||||
//! manifests only and are the same everywhere.
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
use std::io::Read;
|
||||
@@ -73,10 +78,12 @@ struct PackageVersion {
|
||||
version: String,
|
||||
}
|
||||
|
||||
/// Newest release version of every package on the server.
|
||||
/// Newest release version of every package on the server. A shell version
|
||||
/// without a file for this architecture doesn't count.
|
||||
pub fn latest_versions(cfg: &Config) -> Result<BTreeMap<String, String>> {
|
||||
let agent = agent();
|
||||
let mut latest: BTreeMap<String, String> = BTreeMap::new();
|
||||
let mut shells: Vec<String> = Vec::new();
|
||||
for page in 1..=100 {
|
||||
let url = format!("{}/api/v1/packages/{}?type=generic&q=sf-&limit=50&page={page}", cfg.server, cfg.owner);
|
||||
let text = get(cfg, &agent, &url)?.body_mut().read_to_string()?;
|
||||
@@ -88,6 +95,10 @@ pub fn latest_versions(cfg: &Config) -> Result<BTreeMap<String, String>> {
|
||||
if !is_official(&p.name) || !is_release(&p.version) {
|
||||
continue;
|
||||
}
|
||||
if p.name == SHELL && !crate::arch::IS_DEFAULT {
|
||||
shells.push(p.version);
|
||||
continue;
|
||||
}
|
||||
match latest.get(&p.name) {
|
||||
Some(v) if version_cmp(v, &p.version).is_ge() => {}
|
||||
_ => {
|
||||
@@ -96,12 +107,46 @@ pub fn latest_versions(cfg: &Config) -> Result<BTreeMap<String, String>> {
|
||||
}
|
||||
}
|
||||
}
|
||||
if !shells.is_empty() {
|
||||
shells.sort_by(|a, b| version_cmp(b, a));
|
||||
shells.dedup();
|
||||
// Newest first; a few tries are enough (CI builds every architecture together).
|
||||
for v in shells.iter().take(5) {
|
||||
match has_file(cfg, &agent, SHELL, v) {
|
||||
Ok(true) => {
|
||||
latest.insert(SHELL.into(), v.clone());
|
||||
break;
|
||||
}
|
||||
Ok(false) => log::info!("{SHELL} {v}: no {} build", crate::arch::NAME),
|
||||
Err(e) => {
|
||||
log::warn!("{SHELL} {v}: {e:#}");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(latest)
|
||||
}
|
||||
|
||||
const SHELL: &str = "sf-shell";
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct PackageFile {
|
||||
name: String,
|
||||
}
|
||||
|
||||
/// Whether a package version has its file for this architecture.
|
||||
fn has_file(cfg: &Config, agent: &ureq::Agent, name: &str, version: &str) -> Result<bool> {
|
||||
let url = format!("{}/api/v1/packages/{}/generic/{name}/{version}/files", cfg.server, cfg.owner);
|
||||
let text = get(cfg, agent, &url)?.body_mut().read_to_string()?;
|
||||
let files: Vec<PackageFile> = serde_json::from_str(&text).context("package files")?;
|
||||
let want = file_name(name, version);
|
||||
Ok(files.iter().any(|f| f.name == want))
|
||||
}
|
||||
|
||||
/// File name of a package in the registry.
|
||||
pub fn file_name(name: &str, version: &str) -> String {
|
||||
format!("{name}-{version}.tar.zst")
|
||||
if name == SHELL { crate::arch::file_name(name, version) } else { format!("{name}-{version}.tar.zst") }
|
||||
}
|
||||
|
||||
/// Downloads a package and its signature into `dir`.
|
||||
|
||||
@@ -81,6 +81,9 @@ const MAX_STORE_FILES: usize = 200_000;
|
||||
struct PkgInfo {
|
||||
name: String,
|
||||
version: String,
|
||||
/// Native packages (the shell): the architecture they were built for.
|
||||
#[serde(default)]
|
||||
arch: Option<String>,
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
@@ -263,6 +266,9 @@ impl Store {
|
||||
if info.name != expected_name || info.version != version {
|
||||
bail!("package says it is {} {}, expected {expected_name} {version}", info.name, info.version);
|
||||
}
|
||||
if name == "sf-shell" && !crate::arch::runs_here(info.arch.as_deref()) {
|
||||
bail!("{name} {version} is built for {}, this TV is {}", info.arch.as_deref().unwrap_or("x86_64"), crate::arch::NAME);
|
||||
}
|
||||
if let Expect::Store { id, approved, .. } = expect {
|
||||
check_store_manifest(&tmp, id, version, approved)?;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user