mirror of
https://github.com/storytold/lightcraft.git
synced 2026-12-05 16:31:16 -05:00
LightCraft Nightly: fix the batch-1 review findings
- The app's argument loop takes the launch profile's `-- files…` hand-off, so a Nightly launch starts instead of printing "unknown option `--`" and exiting 2. The loop is a pure function now, with a test for the hand-off. - Restore `pub` on window_gpu::relaunch_after_failure (its test passes the closure), give the three App literals in tests.rs a NightlyExit, spell thiserror 2.0.21 in Cargo.lock, and drop the match clippy rewrites to `?`. - Stable keeps "<channel> — <collection>" titles and no "Nightly build" line in About. Nightly's manual update check, its result dialog and a pending install are off, its Help item is hidden, and its crash log lives in the profile. - Fence stable's default library folder, and pass the Launcher's profile form through every Linux wrapper (tar, deb/rpm, AppImage, Arch, Flatpak). The deb/rpm keep their Nightly names, the Flatpak consumes the Nightly tar, and the shared version query creates no profile. - New recorder test for the tar and FHS launchers, run in packaging-lint beside the Arch handoff test; sonar.test.inclusions names the real icon suite.
This commit is contained in:
@@ -86,6 +86,10 @@ jobs:
|
||||
persist-credentials: false
|
||||
- name: Enforce nightly caller and synthetic packaging contracts
|
||||
run: python3 packaging/nightly-tests.py
|
||||
- name: Nightly Linux launchers and the Arch handoff (recorded argv)
|
||||
run: |
|
||||
bash packaging/linux/nightly-launcher-test.sh
|
||||
bash packaging/linux/nightly-arch-tar-test.sh
|
||||
|
||||
nightly-windows-synthetic:
|
||||
name: Nightly Windows packaging contracts (no app build)
|
||||
|
||||
Generated
+1
-1
@@ -3944,7 +3944,7 @@ dependencies = [
|
||||
"raw-window-handle",
|
||||
"rfd",
|
||||
"serde_json",
|
||||
"thiserror",
|
||||
"thiserror 2.0.21",
|
||||
"winit",
|
||||
"winresource",
|
||||
"winsafe",
|
||||
|
||||
@@ -105,9 +105,18 @@ pub(crate) fn control_port_from(what: &str, value: Option<String>) -> Option<u16
|
||||
port
|
||||
}
|
||||
|
||||
/// An isolated profile keeps the emergency crash log with its other app data. With no
|
||||
/// override (or an empty override), retain the historical system-temp location.
|
||||
pub(crate) fn panic_log_path_with(env: impl Fn(&str) -> Option<std::ffi::OsString>, temp: std::path::PathBuf) -> std::path::PathBuf {
|
||||
/// An isolated profile keeps the emergency crash log with its other app data: the Nightly profile's
|
||||
/// settings folder, else `LIGHTCRAFT_CONFIG_DIR`, else (no override, or an empty one) the historical
|
||||
/// system-temp location. The profile wins because Nightly refuses `LIGHTCRAFT_CONFIG_DIR`, and a
|
||||
/// shared temp file would put a Nightly crash in Stable's log.
|
||||
pub(crate) fn panic_log_path_with(
|
||||
env: impl Fn(&str) -> Option<std::ffi::OsString>,
|
||||
temp: std::path::PathBuf,
|
||||
profile: Option<std::path::PathBuf>,
|
||||
) -> std::path::PathBuf {
|
||||
if let Some(root) = profile.filter(|root| !root.as_os_str().is_empty()) {
|
||||
return root.join("Settings").join("lightcraft-panics.log");
|
||||
}
|
||||
env("LIGHTCRAFT_CONFIG_DIR").filter(|value| !value.is_empty()).map(std::path::PathBuf::from).unwrap_or(temp).join("lightcraft-panics.log")
|
||||
}
|
||||
|
||||
@@ -163,8 +172,25 @@ mod config_path_tests {
|
||||
#[test]
|
||||
fn config_override_keeps_panic_log_in_isolated_profile() {
|
||||
let temp = std::path::PathBuf::from("temp");
|
||||
assert_eq!(panic_log_path_with(|_| Some("isolated".into()), temp.clone()), std::path::PathBuf::from("isolated/lightcraft-panics.log"));
|
||||
assert_eq!(panic_log_path_with(|_| None, temp.clone()), temp.join("lightcraft-panics.log"));
|
||||
assert_eq!(panic_log_path_with(|_| Some("".into()), temp.clone()), temp.join("lightcraft-panics.log"));
|
||||
assert_eq!(
|
||||
panic_log_path_with(|_| Some("isolated".into()), temp.clone(), None),
|
||||
std::path::PathBuf::from("isolated/lightcraft-panics.log")
|
||||
);
|
||||
assert_eq!(panic_log_path_with(|_| None, temp.clone(), None), temp.join("lightcraft-panics.log"));
|
||||
assert_eq!(panic_log_path_with(|_| Some("".into()), temp.clone(), None), temp.join("lightcraft-panics.log"));
|
||||
}
|
||||
|
||||
/// Nightly's crash log lives in its own profile's settings folder, never in Stable's temp file,
|
||||
/// and an inherited LIGHTCRAFT_CONFIG_DIR cannot move it out again.
|
||||
#[test]
|
||||
fn nightly_profile_owns_the_panic_log() {
|
||||
let temp = std::path::PathBuf::from("temp");
|
||||
let profile = std::path::PathBuf::from("/launcher/profiles/lightcraft");
|
||||
assert_eq!(
|
||||
panic_log_path_with(|_| Some("stable settings".into()), temp.clone(), Some(profile.clone())),
|
||||
profile.join("Settings/lightcraft-panics.log")
|
||||
);
|
||||
assert_eq!(panic_log_path_with(|_| None, temp.clone(), Some(profile.clone())), profile.join("Settings/lightcraft-panics.log"));
|
||||
assert_eq!(panic_log_path_with(|_| None, temp.clone(), Some("".into())), temp.join("lightcraft-panics.log"));
|
||||
}
|
||||
}
|
||||
|
||||
+91
-31
@@ -103,6 +103,16 @@ struct NightlyExit {
|
||||
}
|
||||
|
||||
impl NightlyExit {
|
||||
/// A window with no Nightly session to finish: Stable, a `--memory` session, and the tests that
|
||||
/// build an `App` without one.
|
||||
#[cfg(test)]
|
||||
fn none() -> Self {
|
||||
Self {
|
||||
session: std::sync::Arc::new(std::sync::Mutex::new(None)),
|
||||
notice_shown: std::sync::Arc::new(std::sync::atomic::AtomicBool::new(false)),
|
||||
}
|
||||
}
|
||||
|
||||
fn finish(&self) {
|
||||
nightly_session::finish_once(&self.session, self.notice_shown.load(std::sync::atomic::Ordering::Relaxed));
|
||||
}
|
||||
@@ -285,7 +295,7 @@ fn prepare_launch() -> Option<Vec<std::ffi::OsString>> {
|
||||
let argv: Vec<_> = std::env::args_os().skip(1).collect();
|
||||
if nightly_build && (build_flavor::version_query(&argv) || launch_profile::version_query(&argv)) {
|
||||
use std::io::Write as _;
|
||||
let _ = writeln!(std::io::stdout(), "LightCraft {} (nightly-v1)", env!("LIGHTCRAFT_BUILT_VERSION"));
|
||||
let _ = writeln!(std::io::stdout(), "LightCraft {}", build_flavor::version(build_flavor::COMPILED, env!("LIGHTCRAFT_BUILT_VERSION")));
|
||||
return None;
|
||||
}
|
||||
let early = launch_profile::parse(argv)
|
||||
@@ -309,7 +319,12 @@ fn prepare_launch() -> Option<Vec<std::ffi::OsString>> {
|
||||
.and_then(|()| lightcraft_ui_egui::channel::select_identity(identity))
|
||||
// The feed version and commit are what About and System Info report for this build.
|
||||
.and_then(|()| {
|
||||
lightcraft_ui_egui::channel::select_version(env!("LIGHTCRAFT_BUILT_VERSION").to_owned(), Some(env!("LIGHTCRAFT_BUILD_COMMIT").to_owned()))
|
||||
// The source commit is Nightly's (Stable's packagers export a SHA too, and About must not
|
||||
// call a release a nightly build).
|
||||
lightcraft_ui_egui::channel::select_version(
|
||||
env!("LIGHTCRAFT_BUILT_VERSION").to_owned(),
|
||||
nightly.then(|| env!("LIGHTCRAFT_BUILD_COMMIT").to_owned()),
|
||||
)
|
||||
});
|
||||
// The settings folder, models, logs and the default library must all answer from the profile.
|
||||
let finish = finish.and_then(|()| match launch_profile::current().root() {
|
||||
@@ -323,6 +338,55 @@ fn prepare_launch() -> Option<Vec<std::ffi::OsString>> {
|
||||
Some(early.args)
|
||||
}
|
||||
|
||||
/// What the app's own arguments ask for, once the launch profile's tokens are gone.
|
||||
#[derive(Debug, Default, PartialEq)]
|
||||
struct AppOptions {
|
||||
files: Vec<String>,
|
||||
/// The raw `--control` value; Stable only (Nightly consumes and ignores it).
|
||||
control: Option<String>,
|
||||
library: Option<std::path::PathBuf>,
|
||||
seed_demo: bool,
|
||||
in_memory: bool,
|
||||
}
|
||||
|
||||
/// The app's own arguments: start with these options, or answer one of the two queries.
|
||||
#[derive(Debug, PartialEq)]
|
||||
enum AppCommand {
|
||||
Start(AppOptions),
|
||||
Version,
|
||||
Help,
|
||||
}
|
||||
|
||||
/// Parse the app's own arguments. Pure (no printing, no exit, no environment) so the loop — and the
|
||||
/// launch profile's `--` hand-off — is testable. Nightly's arguments arrive as `-- files…`, so the
|
||||
/// first `--` ends the options and every later word is a file, even one spelled like an option.
|
||||
fn app_command(args: &[String], nightly: bool) -> Result<AppCommand, String> {
|
||||
let mut options = AppOptions { seed_demo: true, ..AppOptions::default() };
|
||||
let mut args = args.iter();
|
||||
while let Some(argument) = args.next() {
|
||||
match argument.as_str() {
|
||||
"--control" => {
|
||||
let value = args.next().cloned().unwrap_or_default();
|
||||
if !nightly {
|
||||
options.control = Some(value);
|
||||
}
|
||||
}
|
||||
"--library" => options.library = args.next().map(std::path::PathBuf::from),
|
||||
"--no-demo" => options.seed_demo = false,
|
||||
"--memory" | "--demo" => options.in_memory = true,
|
||||
"--" => {
|
||||
options.files.extend(args.by_ref().cloned());
|
||||
break;
|
||||
}
|
||||
"--version" => return Ok(AppCommand::Version),
|
||||
"-h" | "--help" => return Ok(AppCommand::Help),
|
||||
option if option.starts_with("--") => return Err(format!("unknown option `{option}`")),
|
||||
_ => options.files.push(argument.clone()),
|
||||
}
|
||||
}
|
||||
Ok(AppCommand::Start(options))
|
||||
}
|
||||
|
||||
fn main() -> eframe::Result {
|
||||
let Some(arguments) = prepare_launch() else { return Ok(()) };
|
||||
// Windows: the update helper is a copy of this program started with `--finish-update`.
|
||||
@@ -334,7 +398,13 @@ fn main() -> eframe::Result {
|
||||
}
|
||||
// First, so every start-up record is kept for the log file (`logging`).
|
||||
let logger = logging::install();
|
||||
lightcraft_engine::guard::install_hook(panic_log_path_with(|name| std::env::var_os(name), std::env::temp_dir()));
|
||||
// The crash log follows the profile: Nightly keeps it in <profile>/Settings, never in the shared
|
||||
// system-temp file Stable writes.
|
||||
lightcraft_engine::guard::install_hook(panic_log_path_with(
|
||||
|name| std::env::var_os(name),
|
||||
std::env::temp_dir(),
|
||||
lightcraft_engine::config::profile_root().map(std::path::Path::to_path_buf),
|
||||
));
|
||||
if let Some(logger) = logger {
|
||||
logging::record_panics(logger);
|
||||
}
|
||||
@@ -347,36 +417,26 @@ fn main() -> eframe::Result {
|
||||
} else {
|
||||
control_port_from("LIGHTCRAFT_CONTROL_PORT", std::env::var("LIGHTCRAFT_CONTROL_PORT").ok().filter(|v| !v.is_empty()))
|
||||
};
|
||||
let mut files = Vec::new();
|
||||
let mut seed_demo = true;
|
||||
let mut in_memory = false;
|
||||
let mut library_dir: Option<std::path::PathBuf> = None;
|
||||
// The selected profile's arguments (Stable's are the same ones the process was started with).
|
||||
let mut args = arguments.into_iter().map(|a| a.to_string_lossy().into_owned()).collect::<Vec<_>>().into_iter();
|
||||
while let Some(a) = args.next() {
|
||||
match a.as_str() {
|
||||
"--control" => {
|
||||
if !nightly {
|
||||
control_port = control_port_from("--control", Some(args.next().unwrap_or_default()));
|
||||
}
|
||||
}
|
||||
"--library" => library_dir = args.next().map(std::path::PathBuf::from),
|
||||
"--no-demo" => seed_demo = false,
|
||||
"--memory" | "--demo" => in_memory = true,
|
||||
"--version" => {
|
||||
println!("lightcraft {}", env!("CARGO_PKG_VERSION"));
|
||||
return Ok(());
|
||||
}
|
||||
"-h" | "--help" => {
|
||||
print!("{HELP}");
|
||||
return Ok(());
|
||||
}
|
||||
o if o.starts_with("--") => {
|
||||
eprintln!("lightcraft: unknown option `{o}`\n\n{HELP}");
|
||||
std::process::exit(2);
|
||||
}
|
||||
_ => files.push(a),
|
||||
let args = arguments.into_iter().map(|a| a.to_string_lossy().into_owned()).collect::<Vec<_>>();
|
||||
let (files, control, library_dir, seed_demo, in_memory) = match app_command(&args, nightly) {
|
||||
Ok(AppCommand::Start(options)) => (options.files, options.control, options.library, options.seed_demo, options.in_memory),
|
||||
Ok(AppCommand::Version) => {
|
||||
println!("lightcraft {}", env!("CARGO_PKG_VERSION"));
|
||||
return Ok(());
|
||||
}
|
||||
Ok(AppCommand::Help) => {
|
||||
print!("{HELP}");
|
||||
return Ok(());
|
||||
}
|
||||
Err(problem) => {
|
||||
eprintln!("lightcraft: {problem}\n\n{HELP}");
|
||||
std::process::exit(2);
|
||||
}
|
||||
};
|
||||
// Nightly has no control server: the option and its port are still consumed, and ignored.
|
||||
if !nightly && let Some(value) = control {
|
||||
control_port = control_port_from("--control", Some(value));
|
||||
}
|
||||
// The log file: opened after the arguments, so `--version`, `--help` and a usage error leave
|
||||
// no file behind. Records logged until now are written to it first.
|
||||
|
||||
@@ -35,11 +35,7 @@ fn write_no_follow(path: &Path, data: &[u8]) -> io::Result<()> {
|
||||
let name = path.file_name().ok_or_else(|| io::Error::other("the session record has no name"))?;
|
||||
let mut staging = folder.join(name);
|
||||
staging.set_file_name(format!(".{}.{}.tmp", name.to_string_lossy(), std::process::id()));
|
||||
let staged = OpenOptions::new().write(true).create_new(true).open(&staging);
|
||||
let mut staged = match staged {
|
||||
Ok(file) => file,
|
||||
Err(error) => return Err(error),
|
||||
};
|
||||
let mut staged = OpenOptions::new().write(true).create_new(true).open(&staging)?;
|
||||
let result = staged.write_all(data).and_then(|()| staged.sync_all());
|
||||
drop(staged);
|
||||
if let Err(error) = result {
|
||||
|
||||
@@ -141,6 +141,13 @@ fn forbidden_roots(platform: Platform, env: &impl Fn(&str) -> Option<OsString>,
|
||||
]
|
||||
}
|
||||
};
|
||||
// Stable's default library (`lightcraft_engine::library::default_dir`): its catalog, lock,
|
||||
// presets and thumbnails. A Nightly profile inside it would write its own Library, Settings and
|
||||
// session files into the folder Stable opens. A host with no home variable has no such library.
|
||||
let home_key = if platform == Platform::Windows { "USERPROFILE" } else { "HOME" };
|
||||
if let Some(home) = env(home_key).filter(|value| !value.is_empty()) {
|
||||
roots.push(absolute(PathBuf::from(home), home_key)?.join("Pictures").join("LightCraft Library"));
|
||||
}
|
||||
roots.push(installation_boundary(platform, exe)?);
|
||||
roots.into_iter().map(|p| canonical_future(&p)).collect()
|
||||
}
|
||||
@@ -471,6 +478,23 @@ mod tests {
|
||||
assert_eq!(fixture.check(Platform::Mac, &valid).unwrap(), valid);
|
||||
}
|
||||
|
||||
/// Stable's default library holds the user's photos and its catalog: a profile inside it would
|
||||
/// write Nightly's Library and Settings there. Windows resolves the home folder as USERPROFILE.
|
||||
#[test]
|
||||
fn stable_default_library_folder_is_fenced_on_every_os() {
|
||||
let mut fixture = Fixture::new();
|
||||
let linux_library = fixture.home().join("Pictures/LightCraft Library");
|
||||
assert!(fixture.check(Platform::Linux, &linux_library.join("nightly")).unwrap_err().contains("overlap"));
|
||||
assert!(fixture.check(Platform::Mac, &linux_library.join("nightly")).unwrap_err().contains("overlap"));
|
||||
assert!(!linux_library.exists(), "the fence is decided before anything is created");
|
||||
fixture.env.insert("USERPROFILE".into(), fixture.root.join("users/skylar").into_os_string());
|
||||
let windows_library = fixture.root.join("users/skylar/Pictures/LightCraft Library");
|
||||
assert!(fixture.check(Platform::Windows, &windows_library.join("nightly")).unwrap_err().contains("overlap"));
|
||||
assert!(fixture.check(Platform::Windows, &windows_library).is_err(), "the library folder itself is Stable's too");
|
||||
// A merely similar folder next door stays available.
|
||||
assert!(fixture.check(Platform::Linux, &fixture.home().join("Pictures/ArtCraftLauncher/nightly")).is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn windows_roaming_local_and_install_fences_remain_active() {
|
||||
let fixture = Fixture::new();
|
||||
|
||||
@@ -6,6 +6,7 @@ fn desktop_clear_color_stays_opaque_with_a_modal_open() {
|
||||
LightcraftApp::new(Session::new(), Services::default()),
|
||||
PrefsWriter::default(),
|
||||
None,
|
||||
NightlyExit::none(),
|
||||
#[cfg(target_os = "macos")]
|
||||
None,
|
||||
);
|
||||
@@ -16,6 +17,34 @@ fn desktop_clear_color_stays_opaque_with_a_modal_open() {
|
||||
}
|
||||
}
|
||||
|
||||
/// The launch profile hands the files over after `--` (launch_profile::parse): a file named like
|
||||
/// an option stays a file, and nothing after `--` is read as an option again.
|
||||
#[test]
|
||||
fn the_launch_profile_hands_files_over_after_a_double_dash() {
|
||||
let args = ["--", "--version", "--library", "--control", "-h", "photo with spaces.dng"].map(String::from);
|
||||
assert_eq!(
|
||||
app_command(&args, true).unwrap(),
|
||||
AppCommand::Start(AppOptions {
|
||||
files: ["--version", "--library", "--control", "-h", "photo with spaces.dng"].map(String::from).to_vec(),
|
||||
seed_demo: true,
|
||||
..AppOptions::default()
|
||||
})
|
||||
);
|
||||
// Stable and Nightly share the parser: Nightly consumes and ignores --control with its port.
|
||||
assert_eq!(
|
||||
app_command(&["--control".to_string(), "7000".to_string()], true).unwrap(),
|
||||
AppCommand::Start(AppOptions { seed_demo: true, ..AppOptions::default() })
|
||||
);
|
||||
assert_eq!(
|
||||
app_command(&["--control".to_string(), "7000".to_string()], false).unwrap(),
|
||||
AppCommand::Start(AppOptions { control: Some("7000".into()), seed_demo: true, ..AppOptions::default() })
|
||||
);
|
||||
// The queries stay queries, and an unknown option stays a usage error.
|
||||
assert_eq!(app_command(&["--version".to_string()], true).unwrap(), AppCommand::Version);
|
||||
assert_eq!(app_command(&["-h".to_string()], true).unwrap(), AppCommand::Help);
|
||||
assert!(app_command(&["--bogus".to_string()], true).unwrap_err().contains("unknown option `--bogus`"));
|
||||
}
|
||||
|
||||
fn dir(tag: &str) -> std::path::PathBuf {
|
||||
let d = std::env::temp_dir().join(format!("lc-app-prefs-{tag}-{}", std::process::id()));
|
||||
let _ = std::fs::remove_dir_all(&d);
|
||||
@@ -604,6 +633,7 @@ fn on_exit_ends_the_process_on_macos() {
|
||||
app,
|
||||
PrefsWriter::default(),
|
||||
None,
|
||||
NightlyExit::none(),
|
||||
#[cfg(target_os = "macos")]
|
||||
None,
|
||||
);
|
||||
@@ -637,6 +667,7 @@ fn on_exit_removes_the_lock_owner_note() {
|
||||
LightcraftApp::new(session, Services::default()),
|
||||
PrefsWriter::default(),
|
||||
None,
|
||||
NightlyExit::none(),
|
||||
#[cfg(target_os = "macos")]
|
||||
None,
|
||||
);
|
||||
|
||||
@@ -256,7 +256,7 @@ pub fn check_pipeline(device: &wgpu::Device, build: impl FnOnce(&wgpu::Device))
|
||||
/// disk, or the retries are used up). `before_spawn` runs once the decision to retry is made and
|
||||
/// before the new process exists, so a resource the new process must own (the Nightly session
|
||||
/// lease) is released first.
|
||||
fn relaunch_after_failure(files: &Files, before_spawn: impl FnOnce()) -> bool {
|
||||
pub fn relaunch_after_failure(files: &Files, before_spawn: impl FnOnce()) -> bool {
|
||||
if !files.armed() {
|
||||
return false;
|
||||
}
|
||||
@@ -321,7 +321,7 @@ mod tests {
|
||||
// nothing written without a settings folder
|
||||
let none = Files::new(None);
|
||||
none.arm(dx);
|
||||
assert!(!none.armed() && !relaunch_after_failure(&none));
|
||||
assert!(!none.armed() && !relaunch_after_failure(&none, || {}));
|
||||
let _ = std::fs::remove_dir_all(&d);
|
||||
}
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ pub fn display_version() -> String {
|
||||
/// The title-bar caption: the channel name, then the open collection when one is named.
|
||||
pub fn window_title(collection: Option<&str>) -> String {
|
||||
match collection.filter(|name| !name.is_empty()) {
|
||||
Some(name) => format!("{} \u{2014} {}", name, name_owned()),
|
||||
Some(name) => format!("{} \u{2014} {}", name_owned(), name),
|
||||
None => name_owned(),
|
||||
}
|
||||
}
|
||||
@@ -127,7 +127,7 @@ mod tests {
|
||||
assert_eq!(name(), APP_NAME);
|
||||
assert_eq!(window_title(None), "LightCraft");
|
||||
assert_eq!(window_title(Some("")), "LightCraft");
|
||||
assert_eq!(window_title(Some("Wedding")), "Wedding \u{2014} LightCraft");
|
||||
assert_eq!(window_title(Some("Wedding")), "LightCraft \u{2014} Wedding");
|
||||
assert_eq!(display_version(), env!("CARGO_PKG_VERSION"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
//! Software updates, background check at startup, and startup prompt modal.
|
||||
//!
|
||||
//! Nightly is updated by the ArtCraft Launcher, never by this app's stable release feed: every entry
|
||||
//! point below returns early on [`crate::channel::is_nightly`], so no check runs, no result dialog
|
||||
//! opens and a ready stable update is never installed under a Nightly build.
|
||||
|
||||
use serde_json::Value;
|
||||
|
||||
@@ -57,6 +61,9 @@ impl LightcraftApp {
|
||||
/// in `on_exit` when the process ends there without dropping the app.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub fn start_pending_update(&mut self) {
|
||||
if crate::channel::is_nightly() {
|
||||
return;
|
||||
}
|
||||
self.updates_rt.updater.start_pending_update();
|
||||
}
|
||||
}
|
||||
@@ -65,7 +72,7 @@ impl LightcraftApp {
|
||||
pub(crate) fn blocks_input(app: &LightcraftApp) -> bool {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
{
|
||||
app.updates_rt.updater.prompt_open()
|
||||
!crate::channel::is_nightly() && app.updates_rt.updater.prompt_open()
|
||||
}
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
{
|
||||
@@ -77,6 +84,10 @@ pub(crate) fn blocks_input(app: &LightcraftApp) -> bool {
|
||||
pub(crate) fn check(app: &mut LightcraftApp) -> Result<Value, String> {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
{
|
||||
if crate::channel::is_nightly() {
|
||||
// Also keeps a command-palette or shortcut invocation from asking the stable feed.
|
||||
return Err("LightCraft Nightly is updated by the ArtCraft Launcher".into());
|
||||
}
|
||||
app.updates_rt.check_requested = true;
|
||||
if let Some(ctx) = &app.updates_rt.repaint {
|
||||
ctx.request_repaint();
|
||||
@@ -94,6 +105,9 @@ pub(crate) fn check(app: &mut LightcraftApp) -> Result<Value, String> {
|
||||
pub(crate) fn tick(app: &mut LightcraftApp, ctx: &egui::Context) {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
{
|
||||
if crate::channel::is_nightly() {
|
||||
return;
|
||||
}
|
||||
let rt = &mut app.updates_rt;
|
||||
rt.repaint = Some(ctx.clone());
|
||||
if std::mem::take(&mut rt.check_requested) {
|
||||
@@ -118,6 +132,9 @@ fn result_window_shows(status: &Status, prompt_open: bool) -> bool {
|
||||
pub(crate) fn show(app: &mut LightcraftApp, ctx: &egui::Context) {
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
{
|
||||
if crate::channel::is_nightly() {
|
||||
return;
|
||||
}
|
||||
// The close for a ready update waits until nothing is unsaved.
|
||||
let clean = app.session.unsaved().is_none();
|
||||
match app.updates_rt.updater.show_if(ctx, clean) {
|
||||
|
||||
@@ -363,6 +363,8 @@ pub(crate) fn selection_deleted(app: &LightcraftApp) -> bool {
|
||||
/// Restore and Delete Permanently replace Delete for photos in Recently Deleted.
|
||||
fn host_supports(app: &LightcraftApp, id: &str) -> bool {
|
||||
match id {
|
||||
// Nightly is updated by the ArtCraft Launcher: the Help item would query the stable feed.
|
||||
"app.checkForUpdates" => !crate::channel::is_nightly(),
|
||||
"file.backupLibrary" => app.services.backup_library.is_some(),
|
||||
"file.restoreLibrary" => app.services.restore_library.is_some(),
|
||||
"photo.restore" | "photo.deletePermanently" => selection_deleted(app),
|
||||
|
||||
@@ -57,55 +57,71 @@ WORK="$CARGO_TARGET_DIR/flatpak-bundle"
|
||||
rm -rf "$WORK"
|
||||
mkdir -p "$WORK/stage"
|
||||
tar -xzf "$TARBALL" -C "$WORK/stage" --strip-components=1
|
||||
[[ -x "$WORK/stage/bin/lightcraft" ]] || { echo "error: $TARBALL has no bin/lightcraft" >&2; exit 1; }
|
||||
# Stable ships bin/lightcraft; a Nightly tar ships its launchers in bin/ and the real binaries in
|
||||
# lib/lightcraft-nightly (packaging/linux/package.sh stage_nightly).
|
||||
[[ -x "$WORK/stage/bin/lightcraft" || -x "$WORK/stage/lib/lightcraft-nightly/lightcraft" ]] \
|
||||
|| { echo "error: $TARBALL has no LightCraft binary" >&2; exit 1; }
|
||||
if [[ "$FLATPAK_ID" != "$APP_ID" ]]; then
|
||||
mv "$WORK/stage/bin/lightcraft" "$WORK/stage/bin/lightcraft-bin"
|
||||
gui="$WORK/stage/lib/lightcraft-nightly/lightcraft"
|
||||
cli="$WORK/stage/lib/lightcraft-nightly/lightcraft-cli"
|
||||
[[ -x "$gui" && -x "$cli" ]] \
|
||||
|| { echo "error: $TARBALL is not a Nightly tar (no lib/lightcraft-nightly binaries); pass the -nightly- tarball from package.sh" >&2; exit 1; }
|
||||
# The bundle installs the real binaries in /app/libexec and its own wrappers in /app/bin: inside
|
||||
# the sandbox the Nightly Flatpak id isolates the data, and the profile keeps it explicit.
|
||||
mv "$gui" "$WORK/stage/bin/lightcraft-bin"
|
||||
mv "$cli" "$WORK/stage/bin/lightcraft-cli-bin"
|
||||
rm -rf "$WORK/stage/lib" "$WORK/stage/bin/lightcraft-nightly" "$WORK/stage/bin/lightcraft-nightly-cli"
|
||||
cat >"$WORK/stage/bin/lightcraft" <<'WRAPPER'
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
# Inside the sandbox the Nightly Flatpak ID already isolates the data, and the profile keeps it
|
||||
# explicit: one folder for settings, models, logs and the default library.
|
||||
if [ "${1:-}" = "--version" ] || [ "${1:-}" = "-V" ] || [ "${1:-}" = "--help" ] || [ "${1:-}" = "-h" ]; then
|
||||
exec /app/libexec/lightcraft "$@"
|
||||
fi
|
||||
case "${1:-}" in
|
||||
--launch-profile | --profile-root | --version | -V | --help | -h) exec /app/libexec/lightcraft "$@" ;;
|
||||
esac
|
||||
profile="${XDG_DATA_HOME:-${HOME:?HOME is required}/.var/app/ai.storyteller.lightcraft.nightly/data}/lightcraft-nightly"
|
||||
exec /app/libexec/lightcraft --launch-profile nightly-v1 --profile-root "$profile" -- "$@"
|
||||
WRAPPER
|
||||
chmod 755 "$WORK/stage/bin/lightcraft"
|
||||
mv "$WORK/stage/bin/lightcraft-cli" "$WORK/stage/bin/lightcraft-cli-bin"
|
||||
cat >"$WORK/stage/bin/lightcraft-cli" <<'WRAPPER'
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
if [ "${1:-}" = "--version" ] || [ "${1:-}" = "-V" ] || [ "${1:-}" = "--help" ] || [ "${1:-}" = "-h" ]; then
|
||||
exec /app/libexec/lightcraft-cli "$@"
|
||||
fi
|
||||
case "${1:-}" in
|
||||
--version | -V | --help | -h) exec /app/libexec/lightcraft-cli "$@" ;;
|
||||
esac
|
||||
profile="${XDG_DATA_HOME:-${HOME:?HOME is required}/.var/app/ai.storyteller.lightcraft.nightly/data}/lightcraft-nightly"
|
||||
if [ -z "${LIGHTCRAFT_CONFIG_DIR+x}" ]; then export LIGHTCRAFT_CONFIG_DIR="$profile/Settings"; fi
|
||||
if [ -z "${LIGHTCRAFT_LIBRARY+x}" ]; then export LIGHTCRAFT_LIBRARY="$profile/Library"; fi
|
||||
exec /app/libexec/lightcraft-cli "$@"
|
||||
WRAPPER
|
||||
chmod 755 "$WORK/stage/bin/lightcraft-cli"
|
||||
sed -e "s|^Icon=$APP_ID$|Icon=$FLATPAK_ID|" \
|
||||
-e "s|^Name=LightCraft$|Name=LightCraft Nightly|" \
|
||||
-e 's|^StartupWMClass=.*|StartupWMClass=ai.storyteller.lightcraft.nightly-v1|' \
|
||||
-e '/^MimeType=/d' \
|
||||
"$WORK/stage/share/applications/$APP_ID.desktop" >"$WORK/stage/share/applications/$FLATPAK_ID.desktop"
|
||||
rm -f "$WORK/stage/share/applications/$APP_ID.desktop"
|
||||
sed -e "s|<id>$APP_ID</id>|<id>$FLATPAK_ID</id>|g" \
|
||||
-e "s|<name>LightCraft</name>|<name>LightCraft Nightly</name>|g" \
|
||||
-e "s|<launchable type=\"desktop-id\">$APP_ID.desktop</launchable>|<launchable type=\"desktop-id\">$FLATPAK_ID.desktop</launchable>|g" \
|
||||
-e "s|<icon type=\"stock\">$APP_ID</icon>|<icon type=\"stock\">$FLATPAK_ID</icon>|g" \
|
||||
"$WORK/stage/share/metainfo/$APP_ID.metainfo.xml" >"$WORK/stage/share/metainfo/$FLATPAK_ID.metainfo.xml"
|
||||
rm -f "$WORK/stage/share/metainfo/$APP_ID.metainfo.xml"
|
||||
mv "$WORK/stage/share/mime/packages/$APP_ID.xml" "$WORK/stage/share/mime/packages/$FLATPAK_ID.xml"
|
||||
rm -rf "$WORK/stage/share/icons/hicolor"
|
||||
NIGHTLY_ICON="$ROOT/assets/app-icon/lightcraft-nightly.png"
|
||||
[[ -f "$NIGHTLY_ICON" ]] || NIGHTLY_ICON="$ROOT/assets/app-icon/hicolor/256x256/apps/$APP_ID.png"
|
||||
install -Dm644 "$NIGHTLY_ICON" \
|
||||
"$WORK/stage/share/icons/hicolor/256x256/apps/$FLATPAK_ID.png"
|
||||
chmod 755 "$WORK/stage/bin/lightcraft" "$WORK/stage/bin/lightcraft-cli"
|
||||
# The tar names the desktop entry, the metainfo, the icon and the doc folder for the *window* id
|
||||
# (…nightly-v1). The Flatpak id (…nightly) is the artifact id and owns them inside the sandbox;
|
||||
# StartupWMClass stays on the window id the app really sets.
|
||||
nightly_id="$APP_ID.nightly-v1"
|
||||
sed -e "s#^Exec=lightcraft-nightly\([[:space:]]\|$\)#Exec=lightcraft\1#" \
|
||||
-e "s|^TryExec=lightcraft-nightly$|TryExec=lightcraft|" \
|
||||
-e "s|^Icon=.*|Icon=$FLATPAK_ID|" \
|
||||
"$WORK/stage/share/applications/$nightly_id.desktop" >"$WORK/stage/share/applications/$FLATPAK_ID.desktop"
|
||||
rm -f "$WORK/stage/share/applications/$nightly_id.desktop"
|
||||
sed -e "s|<id>$nightly_id</id>|<id>$FLATPAK_ID</id>|g" \
|
||||
-e "s|<launchable type=\"desktop-id\">$nightly_id.desktop</launchable>|<launchable type=\"desktop-id\">$FLATPAK_ID.desktop</launchable>|g" \
|
||||
-e "s|<icon type=\"stock\">$nightly_id</icon>|<icon type=\"stock\">$FLATPAK_ID</icon>|g" \
|
||||
"$WORK/stage/share/metainfo/$nightly_id.metainfo.xml" >"$WORK/stage/share/metainfo/$FLATPAK_ID.metainfo.xml"
|
||||
rm -f "$WORK/stage/share/metainfo/$nightly_id.metainfo.xml"
|
||||
# Nightly opens no files from the file manager: no MIME database, as in the tar.
|
||||
rm -rf "$WORK/stage/share/mime"
|
||||
nightly_icon="$WORK/stage/share/icons/hicolor/256x256/apps/$nightly_id.png"
|
||||
[[ -f "$nightly_icon" ]] || nightly_icon="$ROOT/assets/app-icon/lightcraft-nightly.png"
|
||||
[[ -f "$nightly_icon" ]] || nightly_icon="$ROOT/assets/app-icon/hicolor/256x256/apps/$APP_ID.png"
|
||||
install -Dm644 "$nightly_icon" "$WORK/stage/share/icons/hicolor/256x256/apps/$FLATPAK_ID.png"
|
||||
rm -f "$WORK/stage/share/icons/hicolor/256x256/apps/$nightly_id.png"
|
||||
if [[ -d "$WORK/stage/share/doc/lightcraft-nightly" ]]; then
|
||||
# The manifest copies share/doc/lightcraft (the stable name).
|
||||
mv "$WORK/stage/share/doc/lightcraft-nightly" "$WORK/stage/share/doc/lightcraft"
|
||||
fi
|
||||
sed -e "s|ai\.storyteller\.lightcraft|$FLATPAK_ID|g" \
|
||||
-e 's|- install -Dm755 bin/lightcraft /app/bin/lightcraft|- install -Dm755 bin/lightcraft-bin /app/libexec/lightcraft\n - install -Dm755 bin/lightcraft /app/bin/lightcraft|' \
|
||||
-e 's|- install -Dm755 bin/lightcraft-cli /app/bin/lightcraft-cli|- install -Dm755 bin/lightcraft-cli-bin /app/libexec/lightcraft-cli\n - install -Dm755 bin/lightcraft-cli /app/bin/lightcraft-cli|' \
|
||||
-e '/# The same MIME definitions the deb\/rpm install\./d' \
|
||||
-e '/share\/mime\/packages/d' \
|
||||
"$HERE/flatpak/$APP_ID.bundle.yml" >"$WORK/$FLATPAK_ID.yml"
|
||||
else
|
||||
cp "$HERE/flatpak/$APP_ID.bundle.yml" "$WORK/$FLATPAK_ID.yml"
|
||||
@@ -131,7 +147,12 @@ if [[ "$TEST" = 1 ]]; then
|
||||
flatpak install --user -y --noninteractive --reinstall "$OUT"
|
||||
flatpak info --user "$FLATPAK_ID"
|
||||
flatpak run --command=lightcraft-cli "$FLATPAK_ID" --version
|
||||
flatpak run --command=sh "$FLATPAK_ID" -c 'ls /app/share/applications /app/share/metainfo /app/share/mime/packages /app/share/icons/hicolor/*/apps'
|
||||
if [[ "$FLATPAK_ID" = "$APP_ID" ]]; then
|
||||
flatpak run --command=sh "$FLATPAK_ID" -c 'ls /app/share/applications /app/share/metainfo /app/share/mime/packages /app/share/icons/hicolor/*/apps'
|
||||
else
|
||||
# Nightly installs no MIME database; the GUI lives in /app/libexec behind its /app/bin wrapper.
|
||||
flatpak run --command=sh "$FLATPAK_ID" -c 'ls /app/share/applications /app/share/metainfo /app/share/icons/hicolor/*/apps /app/libexec'
|
||||
fi
|
||||
fi
|
||||
echo "==> done"
|
||||
ls -lh "$OUT"
|
||||
|
||||
@@ -3,21 +3,27 @@ set -eu
|
||||
|
||||
# The Arch packager copies this file over bin/lightcraft (and bin/lightcraft-cli) and moves the
|
||||
# real binaries into bin/.lightcraft-nightly/. Neither writes outside the Nightly profile.
|
||||
self="$(readlink -f "$0")"
|
||||
here="$(dirname "$self")"
|
||||
# Never fall back to a relative path: an unresolvable $0 is a broken install, not a guess.
|
||||
[ -n "$self" ] && [ "${here#/}" != "$here" ] || { echo "error: cannot resolve $0" >&2; exit 2; }
|
||||
profile="${XDG_DATA_HOME:-${HOME:?HOME is required}/.local/share}/lightcraft-nightly"
|
||||
case "$(basename "$0")" in
|
||||
*-cli)
|
||||
real_bin="$(dirname "$0")/.lightcraft-nightly/lightcraft-cli"
|
||||
if [ "${1:-}" = "--version" ] || [ "${1:-}" = "-V" ] || [ "${1:-}" = "--help" ] || [ "${1:-}" = "-h" ]; then
|
||||
exec "$real_bin" "$@"
|
||||
fi
|
||||
real_bin="$here/.lightcraft-nightly/lightcraft-cli"
|
||||
case "${1:-}" in
|
||||
--version | -V | --help | -h) exec "$real_bin" "$@" ;;
|
||||
esac
|
||||
# The headless CLI has no Launcher protocol: the same profile through its two host variables.
|
||||
if [ -z "${LIGHTCRAFT_CONFIG_DIR+x}" ]; then export LIGHTCRAFT_CONFIG_DIR="$profile/Settings"; fi
|
||||
if [ -z "${LIGHTCRAFT_LIBRARY+x}" ]; then export LIGHTCRAFT_LIBRARY="$profile/Library"; fi
|
||||
exec "$real_bin" "$@"
|
||||
;;
|
||||
esac
|
||||
real_bin="$(dirname "$0")/.lightcraft-nightly/lightcraft"
|
||||
if [ "${1:-}" = "--version" ] || [ "${1:-}" = "-V" ] || [ "${1:-}" = "--help" ] || [ "${1:-}" = "-h" ]; then
|
||||
exec "$real_bin" "$@"
|
||||
fi
|
||||
real_bin="$here/.lightcraft-nightly/lightcraft"
|
||||
case "${1:-}" in
|
||||
# The Launcher's own profile form is passed on untouched (its root wins over this default), and
|
||||
# the queries are answered without any profile.
|
||||
--launch-profile | --profile-root | --version | -V | --help | -h) exec "$real_bin" "$@" ;;
|
||||
esac
|
||||
exec "$real_bin" --launch-profile nightly-v1 --profile-root "$profile" -- "$@"
|
||||
|
||||
@@ -91,6 +91,9 @@ expect "$(printf 'CONFIG=<<unset>>\nLIBRARY=<<unset>>\n<--launch-profile>\n<nigh
|
||||
# A bare query is answered by the binary as usual, with no profile tokens and no env written.
|
||||
expect "$(printf 'CONFIG=<<unset>>\nLIBRARY=<<unset>>\n<--version>\n')" --version
|
||||
expect "$(printf 'CONFIG=<<unset>>\nLIBRARY=<<unset>>\n<-V>\n')" -V
|
||||
# The Launcher's own form arrives already shaped: its profile root wins and nothing is added.
|
||||
expect "$(printf 'CONFIG=<<unset>>\nLIBRARY=<<unset>>\n<--launch-profile>\n<nightly-v1>\n<--profile-root>\n</launcher/profiles/lightcraft>\n<--version>\n')" \
|
||||
--launch-profile nightly-v1 --profile-root /launcher/profiles/lightcraft --version
|
||||
# An inherited stable variable is passed through untouched (the nightly build refuses it), never
|
||||
# silently reinterpreted as the profile.
|
||||
LIGHTCRAFT_CONFIG_DIR="$work/explicit with space" expect \
|
||||
|
||||
Executable
+17
@@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
# The headless Nightly CLI (`usr/bin/lightcraft-nightly-cli`). It is not the GUI's Launcher
|
||||
# protocol: the same profile reaches it through its two documented host variables, and an explicit
|
||||
# value still wins.
|
||||
set -eu
|
||||
self="$(readlink -f "$0")"
|
||||
here="$(dirname "$self")"
|
||||
# Never fall back to a relative path: an unresolvable $0 is a broken install, not a guess.
|
||||
[ -n "$self" ] && [ "${here#/}" != "$here" ] || { echo "error: cannot resolve $0" >&2; exit 2; }
|
||||
real="$here/../lib/lightcraft-nightly/lightcraft-cli"
|
||||
case "${1:-}" in
|
||||
--version | -V | --help | -h) exec "$real" "$@" ;;
|
||||
esac
|
||||
profile="${XDG_DATA_HOME:-${HOME:?HOME is required}/.local/share}/lightcraft-nightly"
|
||||
if [ -z "${LIGHTCRAFT_CONFIG_DIR+x}" ]; then export LIGHTCRAFT_CONFIG_DIR="$profile/Settings"; fi
|
||||
if [ -z "${LIGHTCRAFT_LIBRARY+x}" ]; then export LIGHTCRAFT_LIBRARY="$profile/Library"; fi
|
||||
exec "$real" "$@"
|
||||
Executable
+17
@@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
# The Nightly GUI of a .deb, a .rpm or an unpacked FHS tar (`usr/bin/lightcraft-nightly`). The
|
||||
# launch profile selects the profile, so settings, models, logs, the library lock and the default
|
||||
# library all sit under $profile. The real binary is resolved beside this launcher, so the same file
|
||||
# works installed in /usr and unpacked anywhere.
|
||||
set -eu
|
||||
self="$(readlink -f "$0")"
|
||||
here="$(dirname "$self")"
|
||||
# Never fall back to a relative path: an unresolvable $0 is a broken install, not a guess.
|
||||
[ -n "$self" ] && [ "${here#/}" != "$here" ] || { echo "error: cannot resolve $0" >&2; exit 2; }
|
||||
real="$here/../lib/lightcraft-nightly/lightcraft"
|
||||
case "${1:-}" in
|
||||
# The Launcher's own profile form is passed on untouched, and the queries need no profile.
|
||||
--launch-profile | --profile-root | --version | -V | --help | -h) exec "$real" "$@" ;;
|
||||
esac
|
||||
profile="${XDG_DATA_HOME:-${HOME:?HOME is required}/.local/share}/lightcraft-nightly"
|
||||
exec "$real" --launch-profile nightly-v1 --profile-root "$profile" -- "$@"
|
||||
Executable
+83
@@ -0,0 +1,83 @@
|
||||
#!/usr/bin/env bash
|
||||
# Validate the Nightly launchers without building or opening LightCraft: the unpacked tar's
|
||||
# `lightcraft` (GUI in `lightcraft-bin`) and the deb/rpm/FHS `lightcraft-nightly` (GUI in
|
||||
# lib/lightcraft-nightly). A recorder stands in for both binaries and prints its argv and env.
|
||||
set -euo pipefail
|
||||
|
||||
HERE="$(cd "$(dirname "$0")" && pwd)"
|
||||
work="$(mktemp -d)"
|
||||
trap 'rm -rf "$work"' EXIT
|
||||
|
||||
cat >"$work/recorder" <<'RECORDER'
|
||||
#!/bin/sh
|
||||
printf 'CONFIG=<%s>\n' "${LIGHTCRAFT_CONFIG_DIR-<unset>}"
|
||||
printf 'LIBRARY=<%s>\n' "${LIGHTCRAFT_LIBRARY-<unset>}"
|
||||
for arg in "$@"; do
|
||||
printf '<%s>\n' "$arg"
|
||||
done
|
||||
RECORDER
|
||||
chmod 755 "$work/recorder"
|
||||
|
||||
expect() {
|
||||
local expected="$1" actual="$2"
|
||||
if [[ "$actual" != "$expected" ]]; then
|
||||
printf 'expected:\n%s\nactual:\n%s\n' "$expected" "$actual" >&2
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
unset XDG_DATA_HOME LIGHTCRAFT_CONFIG_DIR LIGHTCRAFT_LIBRARY
|
||||
export HOME="$work/home with space"
|
||||
|
||||
# ---- the unpacked tar: lightcraft (launcher) + lightcraft-bin (the GUI) --------------------------
|
||||
tar_dir="$work/tar"
|
||||
mkdir -p "$tar_dir"
|
||||
cp "$work/recorder" "$tar_dir/lightcraft-bin"
|
||||
install -m755 "$HERE/nightly-tar-launch.sh" "$tar_dir/lightcraft"
|
||||
profile="$HOME/.local/share/lightcraft-nightly"
|
||||
|
||||
# A hand-unpacked tar opens its own Nightly profile, whatever the working directory is.
|
||||
cd "$work"
|
||||
expect "$(printf 'CONFIG=<<unset>>\nLIBRARY=<<unset>>\n<--launch-profile>\n<nightly-v1>\n<--profile-root>\n<%s>\n<-->\n<photo with spaces.dng>\n<--other-name.dng>\n' "$profile")" \
|
||||
"$("$tar_dir/lightcraft" 'photo with spaces.dng' '--other-name.dng')"
|
||||
export XDG_DATA_HOME="$work/xdg with space"
|
||||
profile="$XDG_DATA_HOME/lightcraft-nightly"
|
||||
expect "$(printf 'CONFIG=<<unset>>\nLIBRARY=<<unset>>\n<--launch-profile>\n<nightly-v1>\n<--profile-root>\n<%s>\n<-->\n<sample.dng>\n' "$profile")" \
|
||||
"$("$tar_dir/lightcraft" sample.dng)"
|
||||
unset XDG_DATA_HOME
|
||||
profile="$HOME/.local/share/lightcraft-nightly"
|
||||
|
||||
# The Launcher's own form arrives already shaped: its profile root wins and nothing is added.
|
||||
expect "$(printf 'CONFIG=<<unset>>\nLIBRARY=<<unset>>\n<--launch-profile>\n<nightly-v1>\n<--profile-root>\n</launcher/profiles/lightcraft>\n<--version>\n')" \
|
||||
"$("$tar_dir/lightcraft" --launch-profile nightly-v1 --profile-root /launcher/profiles/lightcraft --version)"
|
||||
expect "$(printf 'CONFIG=<<unset>>\nLIBRARY=<<unset>>\n<--profile-root>\n<%s>\n<-->\n<photo.dng>\n' "$work/explicit root")" \
|
||||
"$("$tar_dir/lightcraft" --profile-root "$work/explicit root" -- photo.dng)"
|
||||
# The version query is answered by the binary itself, with no profile tokens.
|
||||
expect "$(printf 'CONFIG=<<unset>>\nLIBRARY=<<unset>>\n<--version>\n')" "$("$tar_dir/lightcraft" --version)"
|
||||
|
||||
# ---- the deb/rpm and the unpacked FHS tar: bin/lightcraft-nightly + lib/lightcraft-nightly -------
|
||||
fhs="$work/fhs"
|
||||
mkdir -p "$fhs/bin" "$fhs/lib/lightcraft-nightly"
|
||||
cp "$work/recorder" "$fhs/lib/lightcraft-nightly/lightcraft"
|
||||
cp "$work/recorder" "$fhs/lib/lightcraft-nightly/lightcraft-cli"
|
||||
install -m755 "$HERE/nightly-fhs-launch.sh" "$fhs/bin/lightcraft-nightly"
|
||||
install -m755 "$HERE/nightly-fhs-cli-launch.sh" "$fhs/bin/lightcraft-nightly-cli"
|
||||
|
||||
# The real binary is resolved beside the launcher, so an unpacked tree works anywhere.
|
||||
expect "$(printf 'CONFIG=<<unset>>\nLIBRARY=<<unset>>\n<--launch-profile>\n<nightly-v1>\n<--profile-root>\n<%s>\n<-->\n<photo with spaces.dng>\n' "$profile")" \
|
||||
"$("$fhs/bin/lightcraft-nightly" 'photo with spaces.dng')"
|
||||
expect "$(printf 'CONFIG=<<unset>>\nLIBRARY=<<unset>>\n<--launch-profile>\n<nightly-v1>\n<--profile-root>\n</launcher/profiles/lightcraft>\n<--version>\n')" \
|
||||
"$("$fhs/bin/lightcraft-nightly" --launch-profile nightly-v1 --profile-root /launcher/profiles/lightcraft --version)"
|
||||
expect "$(printf 'CONFIG=<<unset>>\nLIBRARY=<<unset>>\n<--version>\n')" "$("$fhs/bin/lightcraft-nightly" --version)"
|
||||
|
||||
# The headless CLI takes the same profile through its two host variables; explicit values win.
|
||||
expect "$(printf 'CONFIG=<%s>\nLIBRARY=<%s>\n<calibrate>\n' "$profile/Settings" "$profile/Library")" \
|
||||
"$("$fhs/bin/lightcraft-nightly-cli" calibrate)"
|
||||
expect "$(printf 'CONFIG=<%s>\nLIBRARY=<%s>\n<calibrate>\n' "$work/cli settings" "$work/cli library")" \
|
||||
"$(LIGHTCRAFT_CONFIG_DIR="$work/cli settings" LIGHTCRAFT_LIBRARY="$work/cli library" "$fhs/bin/lightcraft-nightly-cli" calibrate)"
|
||||
|
||||
# Neither launcher writes anything by itself (no folder, no file).
|
||||
test ! -e "$profile"
|
||||
test ! -e "$HOME/Pictures"
|
||||
|
||||
echo "PASS: the Nightly tar and FHS launchers isolate the profile and pass the Launcher protocol through"
|
||||
@@ -5,9 +5,14 @@
|
||||
# ./lightcraft [files…] opens the Nightly library under $XDG_DATA_HOME/lightcraft-nightly
|
||||
# ./lightcraft-bin [files…] the binary itself (stable's settings folder unless given a profile)
|
||||
set -eu
|
||||
here="$(dirname "$0")"
|
||||
self="$(readlink -f "$0")"
|
||||
here="$(dirname "$self")"
|
||||
# Never fall back to a relative path: an unresolvable $0 is a broken install, not a guess.
|
||||
[ -n "$self" ] && [ "${here#/}" != "$here" ] || { echo "error: cannot resolve $0" >&2; exit 2; }
|
||||
case "${1:-}" in
|
||||
--version | -V | --help | -h) exec "$here/lightcraft-bin" "$@" ;;
|
||||
# The Launcher's own profile form is passed on untouched (its profile root wins over this
|
||||
# default), and the queries are answered without any profile.
|
||||
--launch-profile | --profile-root | --version | -V | --help | -h) exec "$here/lightcraft-bin" "$@" ;;
|
||||
esac
|
||||
profile="${XDG_DATA_HOME:-${HOME:?HOME is required}/.local/share}/lightcraft-nightly"
|
||||
exec "$here/lightcraft-bin" --launch-profile nightly-v1 --profile-root "$profile" -- "$@"
|
||||
|
||||
+15
-33
@@ -122,33 +122,10 @@ stage_nightly() {
|
||||
cp -R "$STAGE" "$stage"
|
||||
install -Dm755 "$stage/usr/bin/lightcraft" "$stage/usr/lib/lightcraft-nightly/lightcraft"
|
||||
install -Dm755 "$stage/usr/bin/lightcraft-cli" "$stage/usr/lib/lightcraft-nightly/lightcraft-cli"
|
||||
cat >"$stage/usr/bin/$NFPM_BIN" <<'WRAPPER'
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
# The Nightly GUI owns its profile: the Launcher protocol selects it, so settings, models, logs,
|
||||
# the library lock and the default library all sit under $profile. The nightly build refuses
|
||||
# LIGHTCRAFT_CONFIG_DIR, so an inherited stable variable fails closed instead of silently
|
||||
# pointing this window at the stable app's folder.
|
||||
if [ "${1:-}" = "--version" ] || [ "${1:-}" = "-V" ] || [ "${1:-}" = "--help" ] || [ "${1:-}" = "-h" ]; then
|
||||
exec /usr/lib/lightcraft-nightly/lightcraft "$@"
|
||||
fi
|
||||
profile="${XDG_DATA_HOME:-${HOME:?HOME is required}/.local/share}/lightcraft-nightly"
|
||||
exec /usr/lib/lightcraft-nightly/lightcraft --launch-profile nightly-v1 --profile-root "$profile" -- "$@"
|
||||
WRAPPER
|
||||
cat >"$stage/usr/bin/$NFPM_CLI" <<'WRAPPER'
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
# The headless CLI is not the GUI's Launcher protocol: the same profile reaches it through its two
|
||||
# documented host variables, and an explicit value still wins.
|
||||
if [ "${1:-}" = "--version" ] || [ "${1:-}" = "-V" ] || [ "${1:-}" = "--help" ] || [ "${1:-}" = "-h" ]; then
|
||||
exec /usr/lib/lightcraft-nightly/lightcraft-cli "$@"
|
||||
fi
|
||||
profile="${XDG_DATA_HOME:-${HOME:?HOME is required}/.local/share}/lightcraft-nightly"
|
||||
if [ -z "${LIGHTCRAFT_CONFIG_DIR+x}" ]; then export LIGHTCRAFT_CONFIG_DIR="$profile/Settings"; fi
|
||||
if [ -z "${LIGHTCRAFT_LIBRARY+x}" ]; then export LIGHTCRAFT_LIBRARY="$profile/Library"; fi
|
||||
exec /usr/lib/lightcraft-nightly/lightcraft-cli "$@"
|
||||
WRAPPER
|
||||
chmod 755 "$stage/usr/bin/$NFPM_BIN" "$stage/usr/bin/$NFPM_CLI"
|
||||
# The same launchers the unpacked tar runs (packaging/linux/nightly-*-launch.sh): they resolve the
|
||||
# real binary beside themselves, so /usr and an unpacked tar behave alike.
|
||||
install -Dm755 "$HERE/nightly-fhs-launch.sh" "$stage/usr/bin/$NFPM_BIN"
|
||||
install -Dm755 "$HERE/nightly-fhs-cli-launch.sh" "$stage/usr/bin/$NFPM_CLI"
|
||||
rm -f "$stage/usr/bin/lightcraft" "$stage/usr/bin/lightcraft-cli"
|
||||
mv "$stage/usr/share/doc/lightcraft" "$stage/usr/share/doc/$NFPM_NAME"
|
||||
sed -e "s#^Exec=lightcraft\([[:space:]]\|$\)#Exec=$NFPM_BIN\1#" \
|
||||
@@ -201,9 +178,14 @@ if has deb || has rpm; then
|
||||
command -v nfpm >/dev/null || { echo "error: nfpm not found (https://nfpm.goreleaser.com/install/)" >&2; exit 1; }
|
||||
export VERSION
|
||||
export NFPM_ARCH="$DEB_ARCH"
|
||||
export NFPM_NAME="lightcraft"
|
||||
export NFPM_BIN="lightcraft"
|
||||
export NFPM_CLI="lightcraft-cli"
|
||||
# stage_nightly already exported the Nightly names: re-exporting the stable ones here pointed
|
||||
# the rendered nfpm.yaml at files the Nightly stage has removed (and named the package
|
||||
# `lightcraft`, colliding with stable).
|
||||
if [[ -z "$NIGHTLY_STAGE" ]]; then
|
||||
export NFPM_NAME="lightcraft"
|
||||
export NFPM_BIN="lightcraft"
|
||||
export NFPM_CLI="lightcraft-cli"
|
||||
fi
|
||||
NFPM_STAGE="$STAGE"
|
||||
[[ -n "$NIGHTLY_STAGE" ]] && NFPM_STAGE="$NIGHTLY_STAGE"
|
||||
# nfpm expands env vars in fields like `version` and `arch`, but not in `contents[].src`.
|
||||
@@ -243,9 +225,9 @@ set -eu
|
||||
HERE="$(dirname "$(readlink -f "$0")")"
|
||||
# A real script (not the stable symlink), so an AppImage launch selects the Nightly profile even
|
||||
# when the desktop entry's Exec is bypassed; APPIMAGE/APPDIR stay untouched for the app.
|
||||
if [ "${1:-}" = "--version" ] || [ "${1:-}" = "-V" ] || [ "${1:-}" = "--help" ] || [ "${1:-}" = "-h" ]; then
|
||||
exec "$HERE/usr/bin/lightcraft" "$@"
|
||||
fi
|
||||
case "${1:-}" in
|
||||
--launch-profile | --profile-root | --version | -V | --help | -h) exec "$HERE/usr/bin/lightcraft" "$@" ;;
|
||||
esac
|
||||
profile="${XDG_DATA_HOME:-${HOME:?HOME is required}/.local/share}/lightcraft-nightly"
|
||||
exec "$HERE/usr/bin/lightcraft" --launch-profile nightly-v1 --profile-root "$profile" -- "$@"
|
||||
APPRUN
|
||||
|
||||
@@ -51,6 +51,8 @@ nightly_build_gui() {
|
||||
launcher="$("$NIGHTLY_GUI" --launch-profile nightly-v1 --profile-root "$NIGHTLY_WORK/profile-query" --version)" \
|
||||
|| nightly_die 'the Launcher profile version query failed'
|
||||
[[ "$launcher" == "$actual" ]] || nightly_die 'the Launcher profile query differs from the plain version query'
|
||||
# prepare_launch answers that query before any profile work, so it must leave nothing behind.
|
||||
[[ ! -e "$NIGHTLY_WORK/profile-query" ]] || nightly_die 'the Launcher version query created a profile'
|
||||
[[ "$(git -C "$ROOT" rev-parse HEAD)" == "$LIGHTCRAFT_BUILD_SHA" && -z "$(git -C "$ROOT" status --porcelain)" ]] || nightly_die 'source changed during the version query'
|
||||
}
|
||||
|
||||
|
||||
@@ -8,5 +8,5 @@ sonar.coverage.exclusions=**/tools/**,**/docs/**,**/examples/**,packaging/**
|
||||
# analysed as tests (outside production metrics and coverage) rather than left out.
|
||||
sonar.sources=.
|
||||
sonar.tests=.
|
||||
sonar.test.inclusions=**/tests/**,**/tests.rs,**/tests_*.rs,**/*_tests.rs,**/test_*.py,packaging/nightly-tests.py,packaging/nightly-archive-tests.py,packaging/nightly-release-tests.py,packaging/macos/nightly_plist_tests.py,packaging/macos/nightly_sign_tests.py,packaging/windows/nightly-package-tests.ps1,packaging/windows/nightly-signing-tests.ps1
|
||||
sonar.test.inclusions=**/tests/**,**/tests.rs,**/tests_*.rs,**/*_tests.rs,**/test_*.py,packaging/nightly-tests.py,packaging/nightly-icons-tests.py,packaging/nightly-release-tests.py,packaging/macos/nightly_plist_tests.py,packaging/macos/nightly_sign_tests.py,packaging/windows/nightly-package-tests.ps1,packaging/windows/nightly-signing-tests.ps1
|
||||
sonar.python.coverage.reportPaths=python-coverage.xml
|
||||
|
||||
Reference in New Issue
Block a user