Package-based updates: sf-update, signed shell and app packages
- sf-update (root): lists sf-shell / sf-app-* in the Gitea generic registry, downloads, checks the Ed25519 signature and unpacks to /var/lib/sf-pkg, switches via current/previous/staged symlinks; the factory copies on the read-only root stay as fallback. A new shell is on trial and rolls back after 3 failed starts. - Launcher: apps from factory + installed packages (newer version wins), Settings > System > Updates (check, install now), shell trial confirm. - Image: sf-update units (boot apply, 6-hourly download, launcher requests), sf-shell-exec wrapper for sf-remote, factory versions, registry token. - CI: .gitea/workflows/packages.yml builds, signs and uploads packages whose version isn't published yet (tools/pkg/packages.sh). - docs/updates.md: protocol and layout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -23,6 +23,10 @@ pub struct AppManifest {
|
||||
pub id: String,
|
||||
pub name: String,
|
||||
pub kind: AppKind,
|
||||
/// Package version (semver). Published as `sf-app-<id>` when it changes;
|
||||
/// the newer of a factory and an installed copy wins.
|
||||
#[serde(default = "default_version")]
|
||||
pub version: String,
|
||||
/// Short label above the title in the hero ("Saját app", "Castolás"...).
|
||||
#[serde(default)]
|
||||
pub category: String,
|
||||
@@ -50,6 +54,11 @@ pub struct AppManifest {
|
||||
pub web: WebOptions,
|
||||
#[serde(default)]
|
||||
pub dial: Option<DialOptions>,
|
||||
/// Background receiver (AirPlay, Miracast): sf-core keeps it running all
|
||||
/// the time and it shows its own window when something connects. The
|
||||
/// launcher tile only opens the details sheet.
|
||||
#[serde(default)]
|
||||
pub service: bool,
|
||||
/// Folder the manifest was loaded from (not serialized).
|
||||
#[serde(skip)]
|
||||
pub dir: PathBuf,
|
||||
@@ -74,6 +83,10 @@ pub struct DialOptions {
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
fn default_version() -> String {
|
||||
"0.0.0".into()
|
||||
}
|
||||
|
||||
fn default_accent() -> String {
|
||||
"#ffffff".into()
|
||||
}
|
||||
@@ -99,10 +112,46 @@ pub fn load_apps(dir: &Path) -> Result<Vec<AppManifest>> {
|
||||
Err(e) => log::warn!("skipping {}: {e:#}", path.display()),
|
||||
}
|
||||
}
|
||||
apps.sort_by(|a, b| a.order.cmp(&b.order).then_with(|| a.name.cmp(&b.name)));
|
||||
sort_apps(&mut apps);
|
||||
Ok(apps)
|
||||
}
|
||||
|
||||
/// Loads apps from several folders (factory apps, then installed packages).
|
||||
/// Missing folders are skipped; of two apps with the same id the higher
|
||||
/// `version` wins, on a tie the later folder.
|
||||
pub fn load_apps_from(dirs: &[PathBuf]) -> Result<Vec<AppManifest>> {
|
||||
let mut apps: Vec<AppManifest> = Vec::new();
|
||||
let mut found = false;
|
||||
for dir in dirs {
|
||||
if !dir.is_dir() {
|
||||
continue;
|
||||
}
|
||||
found = true;
|
||||
for app in load_apps(dir)? {
|
||||
match apps.iter_mut().find(|a| a.id == app.id) {
|
||||
Some(old) if version_cmp(&app.version, &old.version).is_ge() => *old = app,
|
||||
Some(_) => {}
|
||||
None => apps.push(app),
|
||||
}
|
||||
}
|
||||
}
|
||||
anyhow::ensure!(found, "none of the app folders exist: {dirs:?}");
|
||||
sort_apps(&mut apps);
|
||||
Ok(apps)
|
||||
}
|
||||
|
||||
fn sort_apps(apps: &mut [AppManifest]) {
|
||||
apps.sort_by(|a, b| a.order.cmp(&b.order).then_with(|| a.name.cmp(&b.name)));
|
||||
}
|
||||
|
||||
/// Compares dotted numeric versions ("1.10.0" > "1.9.2"); anything that
|
||||
/// isn't a number compares as 0.
|
||||
pub fn version_cmp(a: &str, b: &str) -> std::cmp::Ordering {
|
||||
let parts = |v: &str| -> Vec<u64> { v.split(['.', '-', '+']).take(3).map(|p| p.parse().unwrap_or(0)).collect() };
|
||||
let (a, b) = (parts(a), parts(b));
|
||||
(0..3).map(|i| a.get(i).unwrap_or(&0).cmp(b.get(i).unwrap_or(&0))).find(|o| o.is_ne()).unwrap_or(std::cmp::Ordering::Equal)
|
||||
}
|
||||
|
||||
fn load_one(path: &Path) -> Result<AppManifest> {
|
||||
let text = std::fs::read_to_string(path)?;
|
||||
let mut app: AppManifest = toml::from_str(&text)?;
|
||||
@@ -133,5 +182,14 @@ mod tests {
|
||||
let mut s = Settings::default();
|
||||
s.values.insert("netflex_server".into(), "http://10.0.0.5:7880".into());
|
||||
assert_eq!(app.resolved_url(&s).unwrap(), "http://10.0.0.5:7880/");
|
||||
assert_eq!(app.version, "0.0.0");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn compares_versions() {
|
||||
use std::cmp::Ordering::*;
|
||||
assert_eq!(version_cmp("1.10.0", "1.9.2"), Greater);
|
||||
assert_eq!(version_cmp("0.2", "0.2.0"), Equal);
|
||||
assert_eq!(version_cmp("0.1.9", "0.2.0"), Less);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user