mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-29 01:36:18 +01:00
storytold main 83cb1133dd (291 commits) into the integration head bab1a99b85; 47 conflicted files.
- Domain test files (metafile, prepress, pdf plates, settings store, heif, media-testkit, atomic): tests next cut stay cut; tests new on main are kept, as trials where the crate's test target runs trials.
- atomic: main's group-bits test and Faulty::set_group go to src/tests.rs. audio: main's GSM and SBC oracles join tests/main.rs. cms constructors, pdf knockout_backdrop and testing_pdf join their crates' one test binary; timeline's preflight tests become src/preflight_tests.rs trials.
- update: main's changes to detect, install (linux, macos) and the tests land in next's split modules. The app's own offer is inspected on a thread of its own, picked up by tick's polling; settle_for_tests settles offers too. Later on a ready update drops the close it asked for. updater_pin_tests.rs stays deleted; its new pin test is in tests/it/update.rs.
- craft-color: main added a different crate at crates/color (the colour tags of compositor and display frames); it is next's craft-color module `tags`, re-exported at the root.
- Old crates/ui (combo, docking, testing, README) and keymap's ui/view.rs stay deleted; main's new crates/ui/src/testing files are dropped with them.
- New crates in the craft facade: ai, control, dds, frame, ipc, media-source, palette, press-print, score, ssip. testkit and xtask are listed outside it.
- Cargo.lock: the union of both locks, resolved by cargo metadata. Workflow: main's nextest Windows leg, with next's --keep-going clippy.
84 lines
3.0 KiB
Rust
84 lines
3.0 KiB
Rust
//! How a copy of an app got onto the machine, and where it is.
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use crate::version::Version;
|
|
|
|
/// How an installed copy got onto the machine, which decides how to update and remove it.
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
|
pub enum InstallSource {
|
|
/// Installed by this launcher (it keeps a record and can update or remove it).
|
|
Launcher,
|
|
/// A macOS `.app` the user put in Applications.
|
|
MacApp,
|
|
/// A Windows Installer (MSI) install.
|
|
Msi,
|
|
/// A Debian package.
|
|
Deb,
|
|
/// An RPM package.
|
|
Rpm,
|
|
/// An Arch Linux package: the release's own (`ai.storyteller.<app>`), or `<app>`, `<app>-bin`
|
|
/// or `<app>-git` from the AUR or a repository.
|
|
Pacman,
|
|
/// A Flatpak.
|
|
Flatpak,
|
|
/// An AppImage file found on disk.
|
|
AppImage,
|
|
/// A binary found on `PATH` or in a system prefix.
|
|
Binary,
|
|
}
|
|
|
|
impl InstallSource {
|
|
/// The name shown to the user.
|
|
pub fn label(self) -> &'static str {
|
|
match self {
|
|
Self::Launcher => "ArtCraft Launcher",
|
|
Self::MacApp => "Applications folder",
|
|
Self::Msi => "Windows Installer",
|
|
Self::Deb => "Debian package",
|
|
Self::Rpm => "RPM package",
|
|
Self::Pacman => "Arch package",
|
|
Self::Flatpak => "Flatpak",
|
|
Self::AppImage => "AppImage",
|
|
Self::Binary => "System binary",
|
|
}
|
|
}
|
|
|
|
/// Whether the launcher may replace or remove this copy itself. Packages owned by a system
|
|
/// package manager (deb, rpm, Flatpak) are updated through that manager instead.
|
|
pub fn launcher_can_update(self) -> bool {
|
|
matches!(self, Self::Launcher | Self::MacApp | Self::Msi | Self::AppImage)
|
|
}
|
|
}
|
|
|
|
/// An installed copy of an app.
|
|
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
|
pub struct Installed {
|
|
/// `None` when the copy is there but its version couldn't be read.
|
|
pub version: Option<Version>,
|
|
#[allow(missing_docs)]
|
|
pub source: InstallSource,
|
|
/// Where it lives: the `.app`, the exe, the AppImage, or the binary of a package.
|
|
pub location: String,
|
|
/// The package that installed it, for package-manager installs (`photocraft-bin`).
|
|
#[serde(default)]
|
|
pub package: Option<String>,
|
|
/// Whether this copy is managed externally (such as a Flatpak from FlatPark) and
|
|
/// will not be replaced with a downloaded bundle.
|
|
#[serde(default)]
|
|
pub externally_managed: bool,
|
|
/// The remote repository or origin (`flatpark`, `<app>-origin`), when known.
|
|
#[serde(default)]
|
|
pub origin: Option<String>,
|
|
/// The installation scope or name (`user`, `system`, or a named installation), for Flatpak installs.
|
|
#[serde(default)]
|
|
pub installation: Option<String>,
|
|
}
|
|
|
|
impl Installed {
|
|
/// Whether this copy is managed externally and should not be replaced by a downloaded bundle.
|
|
pub fn is_externally_managed(&self) -> bool {
|
|
self.externally_managed
|
|
}
|
|
}
|