Onboard onto bakery: bakery.toml + dev/beta/release CI, relocate content paths
Some checks failed
dev release / build (push) Failing after 1m0s
beta release / build (push) Failing after 57s

Adds bakery.toml (binaries, license_file, desktop_file, data_archive for
the guide content directory) and the standard three-track CI workflows,
mirroring the pattern used across the rest of the bread ecosystem.

Also fixes the tour/troubleshooting-symptoms loaders (tour.rs,
troubleshoot.rs) to check the bakery-writable user content root
(~/.local/share/breadhelp/content) before the system path a pacman
package would have used — the main ContentStore already did this via
user_content_root(), these two were the last holdouts still hardcoded to
/usr/share/breadhelp only.
This commit is contained in:
Breadway 2026-07-23 10:10:30 +08:00
parent 182fdc8e73
commit de382536aa
7 changed files with 270 additions and 9 deletions

View file

@ -41,7 +41,7 @@ pub struct ContentStore {
guides: Vec<Guide>,
}
fn user_content_root() -> PathBuf {
pub(crate) fn user_content_root() -> PathBuf {
if let Ok(xdg) = std::env::var("XDG_DATA_HOME") {
let p = PathBuf::from(xdg);
if p.is_absolute() {

View file

@ -86,15 +86,26 @@ struct TourFile {
}
const SYSTEM_TOUR_PATH: &str = "/usr/share/breadhelp/content/tours/onboarding.toml";
const TOUR_SUBPATH: &str = "tours/onboarding.toml";
/// Checks the user content root first (where bakery installs content —
/// see `content::user_content_root`), falling back to the system path a
/// pacman package would have used. Same "user copy wins" precedent as
/// `ContentStore::load`.
pub fn load() -> Vec<Step> {
let Ok(text) = std::fs::read_to_string(Path::new(SYSTEM_TOUR_PATH)) else {
let user_path = super::user_content_root().join(TOUR_SUBPATH);
let path = if user_path.exists() {
user_path
} else {
Path::new(SYSTEM_TOUR_PATH).to_path_buf()
};
let Ok(text) = std::fs::read_to_string(&path) else {
return Vec::new();
};
match toml::from_str::<TourFile>(&text) {
Ok(f) => f.steps,
Err(e) => {
eprintln!("breadhelp: {SYSTEM_TOUR_PATH} failed to parse: {e}");
eprintln!("breadhelp: {} failed to parse: {e}", path.display());
Vec::new()
}
}

View file

@ -36,13 +36,11 @@ struct SymptomFile {
}
const SYSTEM_SYMPTOMS_DIR: &str = "/usr/share/breadhelp/content/troubleshooting/_symptoms";
const SYMPTOMS_SUBPATH: &str = "troubleshooting/_symptoms";
/// Loads every `*.toml` file in the symptoms directory, keyed by file stem so
/// a `SymptomOption::goto` of `"no-sound:check-mute"` can be resolved.
pub fn load_all() -> std::collections::HashMap<String, Vec<SymptomNode>> {
let mut out = std::collections::HashMap::new();
let Ok(entries) = std::fs::read_dir(Path::new(SYSTEM_SYMPTOMS_DIR)) else {
return out;
fn scan_symptoms_dir(dir: &Path, out: &mut std::collections::HashMap<String, Vec<SymptomNode>>) {
let Ok(entries) = std::fs::read_dir(dir) else {
return;
};
for entry in entries.flatten() {
let path = entry.path();
@ -62,5 +60,16 @@ pub fn load_all() -> std::collections::HashMap<String, Vec<SymptomNode>> {
Err(e) => eprintln!("breadhelp: {} failed to parse: {e}", path.display()),
}
}
}
/// Loads every `*.toml` file in the symptoms directory, keyed by file stem so
/// a `SymptomOption::goto` of `"no-sound:check-mute"` can be resolved. Scans
/// the system path (a pacman package's location) then the user content root
/// (where bakery installs content — see `content::user_content_root`) —
/// same "user copy wins on collision" precedent as `ContentStore::load`.
pub fn load_all() -> std::collections::HashMap<String, Vec<SymptomNode>> {
let mut out = std::collections::HashMap::new();
scan_symptoms_dir(Path::new(SYSTEM_SYMPTOMS_DIR), &mut out);
scan_symptoms_dir(&super::user_content_root().join(SYMPTOMS_SUBPATH), &mut out);
out
}