BlueGit

ict rusty-teams

feat(linux): the Flatpak signs in through the host's browser and ships with releases

- In a Flatpak, browser lookup, start, listener check and stop run on the host via flatpak-spawn --host (browser/src/host.rs); host PATH files are listed once
- A binary under /app counts as packaged: no self-install or self-update
- Manifest asks for org.freedesktop.secrets (CalDAV keyring)
- build.yml bundles the Flatpak next to deb, rpm and AppImage; the step may fail without failing the release
- ADR 0021 updated; issue #61

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

metis Daniel Däschle · pushed by metis

Authored 2026-11-18 · 13 days ago

Hash
a4a56a80a51ea9b5ba39374058acffb939deb247
Parent
f2176804
11 files changed +149 −39
.github/workflows/build.yml +11 −1
@@ -73,6 +73,16 @@ jobs:
73 73 RUSTY_TEAMS_VERSION: ${{ github.ref_type == 'tag' && github.ref_name || '' }}
74 74 run: packaging/linux/package.sh --skip-build --formats "appimage deb rpm"
75 75
76 # The Flatpak repackages a tarball built only for it; the release keeps its own tarball.
77 - name: Flatpak
78 continue-on-error: true
79 env:
80 RUSTY_TEAMS_VERSION: ${{ github.ref_type == 'tag' && github.ref_name || '' }}
81 run: |
82 sudo apt-get install --no-install-recommends -y flatpak flatpak-builder
83 DIST="$RUNNER_TEMP/flatpak" packaging/linux/package.sh --skip-build --formats tar
84 packaging/linux/flatpak-bundle.sh --no-test "$RUNNER_TEMP"/flatpak/rusty-teams-*-linux-x86_64.tar.gz
85
76 86 # The runner is x86_64; the artifact name carries the architecture.
77 87 - uses: actions/upload-artifact@v7
78 88 with:
@@ -161,7 +171,7 @@ jobs:
161 171 cp dist/teams-linux-amd64/teams "release/rusty-teams-$TAG-linux-amd64"
162 172 cp dist/teams-windows-amd64/teams.exe "release/rusty-teams-$TAG-windows-amd64.exe"
163 173 cp dist/teams-macos/teams-macos.zip "release/rusty-teams-$TAG-macos-universal.zip"
164 # deb, rpm, AppImage and its .zsync, named rusty-teams-<version>-linux-x86_64.*;
174 # deb, rpm, Flatpak, AppImage and its .zsync, named rusty-teams-<version>-linux-x86_64.*;
165 175 # the AppImage's update information looks for that .zsync name.
166 176 cp dist/teams-linux-packages/* release/
167 177
@@ -73,6 +73,16 @@ jobs:
73 RUSTY_TEAMS_VERSION: ${{ github.ref_type == 'tag' && github.ref_name || '' }}
73 RUSTY_TEAMS_VERSION: ${{ github.ref_type == 'tag' && github.ref_name || '' }}
74 run: packaging/linux/package.sh --skip-build --formats "appimage deb rpm"
74 run: packaging/linux/package.sh --skip-build --formats "appimage deb rpm"
75
75
76 # The Flatpak repackages a tarball built only for it; the release keeps its own tarball.
77 - name: Flatpak
78 continue-on-error: true
79 env:
80 RUSTY_TEAMS_VERSION: ${{ github.ref_type == 'tag' && github.ref_name || '' }}
81 run: |
82 sudo apt-get install --no-install-recommends -y flatpak flatpak-builder
83 DIST="$RUNNER_TEMP/flatpak" packaging/linux/package.sh --skip-build --formats tar
84 packaging/linux/flatpak-bundle.sh --no-test "$RUNNER_TEMP"/flatpak/rusty-teams-*-linux-x86_64.tar.gz
85
76 # The runner is x86_64; the artifact name carries the architecture.
86 # The runner is x86_64; the artifact name carries the architecture.
77 - uses: actions/upload-artifact@v7
87 - uses: actions/upload-artifact@v7
78 with:
88 with:
@@ -161,7 +171,7 @@ jobs:
161 cp dist/teams-linux-amd64/teams "release/rusty-teams-$TAG-linux-amd64"
171 cp dist/teams-linux-amd64/teams "release/rusty-teams-$TAG-linux-amd64"
162 cp dist/teams-windows-amd64/teams.exe "release/rusty-teams-$TAG-windows-amd64.exe"
172 cp dist/teams-windows-amd64/teams.exe "release/rusty-teams-$TAG-windows-amd64.exe"
163 cp dist/teams-macos/teams-macos.zip "release/rusty-teams-$TAG-macos-universal.zip"
173 cp dist/teams-macos/teams-macos.zip "release/rusty-teams-$TAG-macos-universal.zip"
164 # deb, rpm, AppImage and its .zsync, named rusty-teams-<version>-linux-x86_64.*;
174 # deb, rpm, Flatpak, AppImage and its .zsync, named rusty-teams-<version>-linux-x86_64.*;
165 # the AppImage's update information looks for that .zsync name.
175 # the AppImage's update information looks for that .zsync name.
166 cp dist/teams-linux-packages/* release/
176 cp dist/teams-linux-packages/* release/
167
177
crates/app-base/src/linux_desktop.rs +4 −2
@@ -81,13 +81,14 @@ pub fn is_installed(executable: &Path, layout: &Layout) -> bool {
81 81 .is_some_and(|parent| canonical(parent) == canonical(&install_dir))
82 82 }
83 83
84 /// Installed by a deb/rpm (under `/usr` or `/opt`) or started from an AppImage, whose
85 /// runtime sets `APPIMAGE`. Those bring their own menu entry and updates, so the app
84 /// Installed by a deb/rpm (under `/usr` or `/opt`), a Flatpak (under `/app`) or started from
85 /// an AppImage, whose runtime sets `APPIMAGE`. Those bring their own menu entry and updates, so the app
86 86 /// does not offer to install itself (and, outside the install folder, never updates itself).
87 87 pub fn is_packaged(executable: &Path, appimage: Option<&std::ffi::OsStr>) -> bool {
88 88 appimage.is_some_and(|path| !path.is_empty())
89 89 || executable.starts_with("/usr")
90 90 || executable.starts_with("/opt")
91 || executable.starts_with("/app")
91 92 }
92 93
93 94 pub fn should_offer_install(executable: &Path, layout: &Layout, dont_ask: bool) -> bool {
@@ -297,6 +298,7 @@ mod tests {
297 298 use std::ffi::OsStr;
298 299 assert!(is_packaged(Path::new("/usr/bin/teams"), None));
299 300 assert!(is_packaged(Path::new("/opt/rusty-teams/teams"), None));
301 assert!(is_packaged(Path::new("/app/bin/teams"), None));
300 302 assert!(is_packaged(
301 303 Path::new("/tmp/.mount_teamsAbc/usr/bin/teams"),
302 304 Some(OsStr::new("/home/a/Apps/rusty-teams.AppImage"))
@@ -81,13 +81,14 @@ pub fn is_installed(executable: &Path, layout: &Layout) -> bool {
81 .is_some_and(|parent| canonical(parent) == canonical(&install_dir))
81 .is_some_and(|parent| canonical(parent) == canonical(&install_dir))
82}
82}
83
83
84/// Installed by a deb/rpm (under `/usr` or `/opt`) or started from an AppImage, whose
84/// Installed by a deb/rpm (under `/usr` or `/opt`), a Flatpak (under `/app`) or started from
85/// runtime sets `APPIMAGE`. Those bring their own menu entry and updates, so the app
85/// an AppImage, whose runtime sets `APPIMAGE`. Those bring their own menu entry and updates, so the app
86/// does not offer to install itself (and, outside the install folder, never updates itself).
86/// does not offer to install itself (and, outside the install folder, never updates itself).
87pub fn is_packaged(executable: &Path, appimage: Option<&std::ffi::OsStr>) -> bool {
87pub fn is_packaged(executable: &Path, appimage: Option<&std::ffi::OsStr>) -> bool {
88 appimage.is_some_and(|path| !path.is_empty())
88 appimage.is_some_and(|path| !path.is_empty())
89 || executable.starts_with("/usr")
89 || executable.starts_with("/usr")
90 || executable.starts_with("/opt")
90 || executable.starts_with("/opt")
91 || executable.starts_with("/app")
91}
92}
92
93
93pub fn should_offer_install(executable: &Path, layout: &Layout, dont_ask: bool) -> bool {
94pub fn should_offer_install(executable: &Path, layout: &Layout, dont_ask: bool) -> bool {
@@ -297,6 +298,7 @@ mod tests {
297 use std::ffi::OsStr;
298 use std::ffi::OsStr;
298 assert!(is_packaged(Path::new("/usr/bin/teams"), None));
299 assert!(is_packaged(Path::new("/usr/bin/teams"), None));
299 assert!(is_packaged(Path::new("/opt/rusty-teams/teams"), None));
300 assert!(is_packaged(Path::new("/opt/rusty-teams/teams"), None));
301 assert!(is_packaged(Path::new("/app/bin/teams"), None));
300 assert!(is_packaged(
302 assert!(is_packaged(
301 Path::new("/tmp/.mount_teamsAbc/usr/bin/teams"),
303 Path::new("/tmp/.mount_teamsAbc/usr/bin/teams"),
302 Some(OsStr::new("/home/a/Apps/rusty-teams.AppImage"))
304 Some(OsStr::new("/home/a/Apps/rusty-teams.AppImage"))
crates/browser/src/config.rs +12 −8
@@ -150,13 +150,14 @@ impl Config {
150 150 to_local: &to_local,
151 151 },
152 152 )?;
153 let path_variable = std::env::var_os("PATH").unwrap_or_default();
153 let path_variable = crate::host::path_variable();
154 154 let chosen = crate::sign_in_choice::chosen_executable(platform, home_dir.as_deref());
155 Ok(
156 config.select_browser(chosen, home_dir.as_deref(), &path_variable, &|path| {
157 path.is_file()
158 }),
159 )
155 Ok(config.select_browser(
156 chosen,
157 home_dir.as_deref(),
158 &path_variable,
159 &crate::host::is_file,
160 ))
160 161 }
161 162
162 163 /// Uses `chosen` as the sign-in browser, else the first Chromium browser, else the first
@@ -281,8 +282,11 @@ impl Config {
281 282 }
282 283
283 284 pub fn executable(&self) -> Result<PathBuf, BrowserError> {
284 let path_variable = std::env::var_os("PATH").unwrap_or_default();
285 find_browser(&self.search, &path_variable, &|path| path.is_file())
285 find_browser(
286 &self.search,
287 &crate::host::path_variable(),
288 &crate::host::is_file,
289 )
286 290 }
287 291 }
288 292
@@ -150,13 +150,14 @@ impl Config {
150 to_local: &to_local,
150 to_local: &to_local,
151 },
151 },
152 )?;
152 )?;
153 let path_variable = std::env::var_os("PATH").unwrap_or_default();
153 let path_variable = crate::host::path_variable();
154 let chosen = crate::sign_in_choice::chosen_executable(platform, home_dir.as_deref());
154 let chosen = crate::sign_in_choice::chosen_executable(platform, home_dir.as_deref());
155 Ok(
155 Ok(config.select_browser(
156 config.select_browser(chosen, home_dir.as_deref(), &path_variable, &|path| {
156 chosen,
157 path.is_file()
157 home_dir.as_deref(),
158 }),
158 &path_variable,
159 )
159 &crate::host::is_file,
160 ))
160 }
161 }
161
162
162 /// Uses `chosen` as the sign-in browser, else the first Chromium browser, else the first
163 /// Uses `chosen` as the sign-in browser, else the first Chromium browser, else the first
@@ -281,8 +282,11 @@ impl Config {
281 }
282 }
282
283
283 pub fn executable(&self) -> Result<PathBuf, BrowserError> {
284 pub fn executable(&self) -> Result<PathBuf, BrowserError> {
284 let path_variable = std::env::var_os("PATH").unwrap_or_default();
285 find_browser(
285 find_browser(&self.search, &path_variable, &|path| path.is_file())
286 &self.search,
287 &crate::host::path_variable(),
288 &crate::host::is_file,
289 )
286 }
290 }
287}
291}
288
292
crates/browser/src/host.rs added +85 −0
@@ -0,0 +1,85 @@
1 //! Inside a Flatpak the host's browsers are neither visible nor startable from the sandbox, so
2 //! lookups and processes go to the host through `flatpak-spawn --host`. The debug port and the
3 //! profile under `~/.var/app` are the same on both sides.
4
5 use std::collections::HashSet;
6 use std::ffi::{OsStr, OsString};
7 use std::path::{Path, PathBuf};
8 use std::process::Command;
9 use std::sync::OnceLock;
10
11 const FLATPAK_INFO: &str = "/.flatpak-info";
12 const LIST_DIRECTORIES: &str = r#"for directory in "$@"; do for entry in "$directory"/*; do [ -f "$entry" ] && printf '%s\n' "$entry"; done; done"#;
13
14 pub(crate) fn in_flatpak() -> bool {
15 static IN_FLATPAK: OnceLock<bool> = OnceLock::new();
16 *IN_FLATPAK.get_or_init(|| Path::new(FLATPAK_INFO).exists())
17 }
18
19 /// `program` on the host: wrapped in `flatpak-spawn --host` inside a Flatpak.
20 pub(crate) fn command(program: impl AsRef<OsStr>) -> Command {
21 if in_flatpak() {
22 let mut command = Command::new("flatpak-spawn");
23 command.arg("--host").arg(program);
24 command
25 } else {
26 Command::new(program)
27 }
28 }
29
30 /// The host's `PATH`, read once inside a Flatpak.
31 pub(crate) fn path_variable() -> OsString {
32 if !in_flatpak() {
33 return std::env::var_os("PATH").unwrap_or_default();
34 }
35 static HOST_PATH: OnceLock<OsString> = OnceLock::new();
36 HOST_PATH
37 .get_or_init(|| {
38 command("printenv")
39 .arg("PATH")
40 .output()
41 .map(|output| String::from_utf8_lossy(&output.stdout).trim().into())
42 .unwrap_or_default()
43 })
44 .clone()
45 }
46
47 /// Whether `path` is a file on the host. Files in the host's `PATH` directories are listed in
48 /// one call, so probing every browser name in every directory stays cheap.
49 pub(crate) fn is_file(path: &Path) -> bool {
50 if !in_flatpak() {
51 return path.is_file();
52 }
53 let (directories, files) = host_path_files();
54 if path
55 .parent()
56 .is_some_and(|parent| directories.contains(parent))
57 {
58 return files.contains(path);
59 }
60 command("test")
61 .arg("-f")
62 .arg(path)
63 .status()
64 .is_ok_and(|status| status.success())
65 }
66
67 fn host_path_files() -> &'static (HashSet<PathBuf>, HashSet<PathBuf>) {
68 static LISTING: OnceLock<(HashSet<PathBuf>, HashSet<PathBuf>)> = OnceLock::new();
69 LISTING.get_or_init(|| {
70 let directories: HashSet<PathBuf> = std::env::split_paths(&path_variable()).collect();
71 let output = command("sh")
72 .args(["-c", LIST_DIRECTORIES, "sh"])
73 .args(&directories)
74 .output();
75 let files = output
76 .map(|output| {
77 String::from_utf8_lossy(&output.stdout)
78 .lines()
79 .map(PathBuf::from)
80 .collect()
81 })
82 .unwrap_or_default();
83 (directories, files)
84 })
85 }
@@ -0,0 +1,85 @@
1//! Inside a Flatpak the host's browsers are neither visible nor startable from the sandbox, so
2//! lookups and processes go to the host through `flatpak-spawn --host`. The debug port and the
3//! profile under `~/.var/app` are the same on both sides.
4
5use std::collections::HashSet;
6use std::ffi::{OsStr, OsString};
7use std::path::{Path, PathBuf};
8use std::process::Command;
9use std::sync::OnceLock;
10
11const FLATPAK_INFO: &str = "/.flatpak-info";
12const LIST_DIRECTORIES: &str = r#"for directory in "$@"; do for entry in "$directory"/*; do [ -f "$entry" ] && printf '%s\n' "$entry"; done; done"#;
13
14pub(crate) fn in_flatpak() -> bool {
15 static IN_FLATPAK: OnceLock<bool> = OnceLock::new();
16 *IN_FLATPAK.get_or_init(|| Path::new(FLATPAK_INFO).exists())
17}
18
19/// `program` on the host: wrapped in `flatpak-spawn --host` inside a Flatpak.
20pub(crate) fn command(program: impl AsRef<OsStr>) -> Command {
21 if in_flatpak() {
22 let mut command = Command::new("flatpak-spawn");
23 command.arg("--host").arg(program);
24 command
25 } else {
26 Command::new(program)
27 }
28}
29
30/// The host's `PATH`, read once inside a Flatpak.
31pub(crate) fn path_variable() -> OsString {
32 if !in_flatpak() {
33 return std::env::var_os("PATH").unwrap_or_default();
34 }
35 static HOST_PATH: OnceLock<OsString> = OnceLock::new();
36 HOST_PATH
37 .get_or_init(|| {
38 command("printenv")
39 .arg("PATH")
40 .output()
41 .map(|output| String::from_utf8_lossy(&output.stdout).trim().into())
42 .unwrap_or_default()
43 })
44 .clone()
45}
46
47/// Whether `path` is a file on the host. Files in the host's `PATH` directories are listed in
48/// one call, so probing every browser name in every directory stays cheap.
49pub(crate) fn is_file(path: &Path) -> bool {
50 if !in_flatpak() {
51 return path.is_file();
52 }
53 let (directories, files) = host_path_files();
54 if path
55 .parent()
56 .is_some_and(|parent| directories.contains(parent))
57 {
58 return files.contains(path);
59 }
60 command("test")
61 .arg("-f")
62 .arg(path)
63 .status()
64 .is_ok_and(|status| status.success())
65}
66
67fn host_path_files() -> &'static (HashSet<PathBuf>, HashSet<PathBuf>) {
68 static LISTING: OnceLock<(HashSet<PathBuf>, HashSet<PathBuf>)> = OnceLock::new();
69 LISTING.get_or_init(|| {
70 let directories: HashSet<PathBuf> = std::env::split_paths(&path_variable()).collect();
71 let output = command("sh")
72 .args(["-c", LIST_DIRECTORIES, "sh"])
73 .args(&directories)
74 .output();
75 let files = output
76 .map(|output| {
77 String::from_utf8_lossy(&output.stdout)
78 .lines()
79 .map(PathBuf::from)
80 .collect()
81 })
82 .unwrap_or_default();
83 (directories, files)
84 })
85}
crates/browser/src/launch.rs +2 −2
@@ -156,7 +156,7 @@ fn app_fontconfig_keys(lookup: impl Fn(&str) -> Option<std::ffi::OsString>) -> V
156 156 fn chrome_major(platform: Platform, executable: &Path) -> u32 {
157 157 let detected = match platform {
158 158 Platform::Linux | Platform::Macos => {
159 let mut command = Command::new(executable);
159 let mut command = crate::host::command(executable);
160 160 strip_app_fontconfig(&mut command);
161 161 command.arg("--version").output().ok().and_then(|output| {
162 162 major_from_version_output(&String::from_utf8_lossy(&output.stdout))
@@ -214,7 +214,7 @@ impl Launcher for SystemLauncher {
214 214 })
215 215 }
216 216 };
217 let mut command = Command::new(&executable);
217 let mut command = crate::host::command(&executable);
218 218 strip_app_fontconfig(&mut command);
219 219 command
220 220 .args(arguments)
@@ -156,7 +156,7 @@ fn app_fontconfig_keys(lookup: impl Fn(&str) -> Option<std::ffi::OsString>) -> V
156fn chrome_major(platform: Platform, executable: &Path) -> u32 {
156fn chrome_major(platform: Platform, executable: &Path) -> u32 {
157 let detected = match platform {
157 let detected = match platform {
158 Platform::Linux | Platform::Macos => {
158 Platform::Linux | Platform::Macos => {
159 let mut command = Command::new(executable);
159 let mut command = crate::host::command(executable);
160 strip_app_fontconfig(&mut command);
160 strip_app_fontconfig(&mut command);
161 command.arg("--version").output().ok().and_then(|output| {
161 command.arg("--version").output().ok().and_then(|output| {
162 major_from_version_output(&String::from_utf8_lossy(&output.stdout))
162 major_from_version_output(&String::from_utf8_lossy(&output.stdout))
@@ -214,7 +214,7 @@ impl Launcher for SystemLauncher {
214 })
214 })
215 }
215 }
216 };
216 };
217 let mut command = Command::new(&executable);
217 let mut command = crate::host::command(&executable);
218 strip_app_fontconfig(&mut command);
218 strip_app_fontconfig(&mut command);
219 command
219 command
220 .args(arguments)
220 .args(arguments)
crates/browser/src/lib.rs +1 −0
@@ -3,6 +3,7 @@ mod bidi_transport;
3 3 mod browser;
4 4 mod config;
5 5 mod error;
6 mod host;
6 7 mod http;
7 8 mod launch;
8 9 mod process;
@@ -3,6 +3,7 @@ mod bidi_transport;
3mod browser;
3mod browser;
4mod config;
4mod config;
5mod error;
5mod error;
6mod host;
6mod http;
7mod http;
7mod launch;
8mod launch;
8mod process;
9mod process;
crates/browser/src/process.rs +12 −5
@@ -1,4 +1,3 @@
1 use std::process::Command;
2 1 use std::time::{Duration, Instant};
3 2
4 3 use crate::config::Platform;
@@ -38,7 +37,7 @@ pub(crate) fn parse_lsof_pid(output: &str) -> Option<u32> {
38 37 }
39 38
40 39 fn run(program: &str, arguments: &[&str]) -> Result<String, BrowserError> {
41 let output = Command::new(program).args(arguments).output()?;
40 let output = crate::host::command(program).args(arguments).output()?;
42 41 Ok(String::from_utf8_lossy(&output.stdout).into_owned())
43 42 }
44 43
@@ -85,6 +84,9 @@ fn process_image_name(platform: Platform, pid: &str) -> Result<String, BrowserEr
85 84 let filter = format!("PID eq {pid}");
86 85 let csv_arguments = ["/FI", filter.as_str(), "/FO", "CSV", "/NH"];
87 86 let output = match platform {
87 Platform::Linux if crate::host::in_flatpak() => {
88 run("cat", &[&format!("/proc/{pid}/comm")])?
89 }
88 90 Platform::Linux => std::fs::read_to_string(format!("/proc/{pid}/comm"))?,
89 91 Platform::Macos => run("ps", &["-p", pid, "-o", "comm="])?,
90 92 Platform::Windows => run("tasklist", &csv_arguments)?,
@@ -103,10 +105,12 @@ pub(crate) fn terminate_listener(platform: Platform, port: u16) -> Result<(), Br
103 105 if !platform.uses_unix_paths() {
104 106 return kill_pid(platform, &pid);
105 107 }
106 Command::new("kill").args(["-TERM", &pid]).output()?;
108 crate::host::command("kill")
109 .args(["-TERM", &pid])
110 .output()?;
107 111 let deadline = Instant::now() + EXIT_WAIT;
108 112 while Instant::now() < deadline {
109 let alive = Command::new("kill")
113 let alive = crate::host::command("kill")
110 114 .args(["-0", &pid])
111 115 .output()?
112 116 .status
@@ -144,7 +148,10 @@ fn kill_pid(platform: Platform, pid: &str) -> Result<(), BrowserError> {
144 148 Platform::Windows => ("taskkill", vec!["/PID", pid, "/T", "/F"]),
145 149 Platform::Wsl => ("taskkill.exe", vec!["/PID", pid, "/T", "/F"]),
146 150 };
147 let status = Command::new(program).args(arguments).output()?.status;
151 let status = crate::host::command(program)
152 .args(arguments)
153 .output()?
154 .status;
148 155 if status.success() {
149 156 Ok(())
150 157 } else {
@@ -1,4 +1,3 @@
1use std::process::Command;
2use std::time::{Duration, Instant};
1use std::time::{Duration, Instant};
3
2
4use crate::config::Platform;
3use crate::config::Platform;
@@ -38,7 +37,7 @@ pub(crate) fn parse_lsof_pid(output: &str) -> Option<u32> {
38}
37}
39
38
40fn run(program: &str, arguments: &[&str]) -> Result<String, BrowserError> {
39fn run(program: &str, arguments: &[&str]) -> Result<String, BrowserError> {
41 let output = Command::new(program).args(arguments).output()?;
40 let output = crate::host::command(program).args(arguments).output()?;
42 Ok(String::from_utf8_lossy(&output.stdout).into_owned())
41 Ok(String::from_utf8_lossy(&output.stdout).into_owned())
43}
42}
44
43
@@ -85,6 +84,9 @@ fn process_image_name(platform: Platform, pid: &str) -> Result<String, BrowserEr
85 let filter = format!("PID eq {pid}");
84 let filter = format!("PID eq {pid}");
86 let csv_arguments = ["/FI", filter.as_str(), "/FO", "CSV", "/NH"];
85 let csv_arguments = ["/FI", filter.as_str(), "/FO", "CSV", "/NH"];
87 let output = match platform {
86 let output = match platform {
87 Platform::Linux if crate::host::in_flatpak() => {
88 run("cat", &[&format!("/proc/{pid}/comm")])?
89 }
88 Platform::Linux => std::fs::read_to_string(format!("/proc/{pid}/comm"))?,
90 Platform::Linux => std::fs::read_to_string(format!("/proc/{pid}/comm"))?,
89 Platform::Macos => run("ps", &["-p", pid, "-o", "comm="])?,
91 Platform::Macos => run("ps", &["-p", pid, "-o", "comm="])?,
90 Platform::Windows => run("tasklist", &csv_arguments)?,
92 Platform::Windows => run("tasklist", &csv_arguments)?,
@@ -103,10 +105,12 @@ pub(crate) fn terminate_listener(platform: Platform, port: u16) -> Result<(), Br
103 if !platform.uses_unix_paths() {
105 if !platform.uses_unix_paths() {
104 return kill_pid(platform, &pid);
106 return kill_pid(platform, &pid);
105 }
107 }
106 Command::new("kill").args(["-TERM", &pid]).output()?;
108 crate::host::command("kill")
109 .args(["-TERM", &pid])
110 .output()?;
107 let deadline = Instant::now() + EXIT_WAIT;
111 let deadline = Instant::now() + EXIT_WAIT;
108 while Instant::now() < deadline {
112 while Instant::now() < deadline {
109 let alive = Command::new("kill")
113 let alive = crate::host::command("kill")
110 .args(["-0", &pid])
114 .args(["-0", &pid])
111 .output()?
115 .output()?
112 .status
116 .status
@@ -144,7 +148,10 @@ fn kill_pid(platform: Platform, pid: &str) -> Result<(), BrowserError> {
144 Platform::Windows => ("taskkill", vec!["/PID", pid, "/T", "/F"]),
148 Platform::Windows => ("taskkill", vec!["/PID", pid, "/T", "/F"]),
145 Platform::Wsl => ("taskkill.exe", vec!["/PID", pid, "/T", "/F"]),
149 Platform::Wsl => ("taskkill.exe", vec!["/PID", pid, "/T", "/F"]),
146 };
150 };
147 let status = Command::new(program).args(arguments).output()?.status;
151 let status = crate::host::command(program)
152 .args(arguments)
153 .output()?
154 .status;
148 if status.success() {
155 if status.success() {
149 Ok(())
156 Ok(())
150 } else {
157 } else {
crates/browser/src/sign_in_choice.rs +10 −7
@@ -66,12 +66,11 @@ impl SignInBrowser {
66 66 /// Chromium and Firefox browsers on this machine, Chromium first.
67 67 pub fn installed_browsers() -> Vec<InstalledBrowser> {
68 68 let home = directories::BaseDirs::new().map(|dirs| dirs.home_dir().to_path_buf());
69 let path_variable = std::env::var_os("PATH").unwrap_or_default();
70 69 installed_in(
71 70 Platform::detect(),
72 71 home.as_deref(),
73 &path_variable,
74 &|path| path.is_file(),
72 &crate::host::path_variable(),
73 &crate::host::is_file,
75 74 )
76 75 }
77 76
@@ -90,12 +89,16 @@ pub(crate) fn chosen_executable(platform: Platform, home: Option<&Path>) -> Opti
90 89 return None;
91 90 }
92 91 if let SignInBrowser::Program(path) = SignInBrowser::load()
93 && path.is_file()
92 && crate::host::is_file(&path)
94 93 {
95 94 return Some(path);
96 95 }
97 let path_variable = std::env::var_os("PATH").unwrap_or_default();
98 let installed = installed_in(platform, home, &path_variable, &|path| path.is_file());
96 let installed = installed_in(
97 platform,
98 home,
99 &crate::host::path_variable(),
100 &crate::host::is_file,
101 );
99 102 automatic_in(platform, &installed).map(|browser| browser.path.clone())
100 103 }
101 104
@@ -148,7 +151,7 @@ fn system_default(platform: Platform, installed: &[InstalledBrowser]) -> Option<
148 151 })
149 152 }
150 153 Platform::Linux => {
151 let output = Command::new("xdg-settings")
154 let output = crate::host::command("xdg-settings")
152 155 .args(["get", "default-web-browser"])
153 156 .output()
154 157 .ok()?;
@@ -66,12 +66,11 @@ impl SignInBrowser {
66/// Chromium and Firefox browsers on this machine, Chromium first.
66/// Chromium and Firefox browsers on this machine, Chromium first.
67pub fn installed_browsers() -> Vec<InstalledBrowser> {
67pub fn installed_browsers() -> Vec<InstalledBrowser> {
68 let home = directories::BaseDirs::new().map(|dirs| dirs.home_dir().to_path_buf());
68 let home = directories::BaseDirs::new().map(|dirs| dirs.home_dir().to_path_buf());
69 let path_variable = std::env::var_os("PATH").unwrap_or_default();
70 installed_in(
69 installed_in(
71 Platform::detect(),
70 Platform::detect(),
72 home.as_deref(),
71 home.as_deref(),
73 &path_variable,
72 &crate::host::path_variable(),
74 &|path| path.is_file(),
73 &crate::host::is_file,
75 )
74 )
76}
75}
77
76
@@ -90,12 +89,16 @@ pub(crate) fn chosen_executable(platform: Platform, home: Option<&Path>) -> Opti
90 return None;
89 return None;
91 }
90 }
92 if let SignInBrowser::Program(path) = SignInBrowser::load()
91 if let SignInBrowser::Program(path) = SignInBrowser::load()
93 && path.is_file()
92 && crate::host::is_file(&path)
94 {
93 {
95 return Some(path);
94 return Some(path);
96 }
95 }
97 let path_variable = std::env::var_os("PATH").unwrap_or_default();
96 let installed = installed_in(
98 let installed = installed_in(platform, home, &path_variable, &|path| path.is_file());
97 platform,
98 home,
99 &crate::host::path_variable(),
100 &crate::host::is_file,
101 );
99 automatic_in(platform, &installed).map(|browser| browser.path.clone())
102 automatic_in(platform, &installed).map(|browser| browser.path.clone())
100}
103}
101
104
@@ -148,7 +151,7 @@ fn system_default(platform: Platform, installed: &[InstalledBrowser]) -> Option<
148 })
151 })
149 }
152 }
150 Platform::Linux => {
153 Platform::Linux => {
151 let output = Command::new("xdg-settings")
154 let output = crate::host::command("xdg-settings")
152 .args(["get", "default-web-browser"])
155 .args(["get", "default-web-browser"])
153 .output()
156 .output()
154 .ok()?;
157 .ok()?;
docs/decisions/0021-linux-packages.md +1 −1
@@ -17,5 +17,5 @@ The Linux release is a bare binary that installs and updates itself (ADR 0014).
17 17
18 18 - deb and rpm list the libraries the binary loads with `dlopen` (Wayland, X11, Vulkan or EGL) as dependencies and the call stack's (PulseAudio, PipeWire, VA-API) as recommendations; they conflict with Microsoft's old `teams` package, which also owned `/usr/bin/teams`.
19 19 - The AppImage's `AppRun` writes `~/.local/share/applications/rusty-teams.desktop` like the self-install does; an entry the self-install wrote keeps its `Exec`.
20 - The Flatpak (`packaging/linux/flatpak-bundle.sh`, app id `io.github.danieldaeschle.RustyTeams`) builds but is broken and not released: the app starts the user's own browser with a debug port, and inside the sandbox it can neither see nor start the host's browsers. It needs the browser start to go through `flatpak-spawn --host`. A working Flatpak would end the glibc floor entirely, since it brings its own runtime.
20 - The Flatpak (`packaging/linux/flatpak-bundle.sh`, app id `io.github.danieldaeschle.RustyTeams`) is released next to the other packages. The app starts the user's own browser with a debug port; inside the sandbox it finds, starts and stops the host's browser through `flatpak-spawn --host` (`crates/browser/src/host.rs`). It brings its own runtime, so it has no glibc floor. Its CI step may fail without failing the release.
21 21 - No package repository: deb and rpm are release downloads.
@@ -17,5 +17,5 @@ The Linux release is a bare binary that installs and updates itself (ADR 0014).
17
17
18- deb and rpm list the libraries the binary loads with `dlopen` (Wayland, X11, Vulkan or EGL) as dependencies and the call stack's (PulseAudio, PipeWire, VA-API) as recommendations; they conflict with Microsoft's old `teams` package, which also owned `/usr/bin/teams`.
18- deb and rpm list the libraries the binary loads with `dlopen` (Wayland, X11, Vulkan or EGL) as dependencies and the call stack's (PulseAudio, PipeWire, VA-API) as recommendations; they conflict with Microsoft's old `teams` package, which also owned `/usr/bin/teams`.
19- The AppImage's `AppRun` writes `~/.local/share/applications/rusty-teams.desktop` like the self-install does; an entry the self-install wrote keeps its `Exec`.
19- The AppImage's `AppRun` writes `~/.local/share/applications/rusty-teams.desktop` like the self-install does; an entry the self-install wrote keeps its `Exec`.
20- The Flatpak (`packaging/linux/flatpak-bundle.sh`, app id `io.github.danieldaeschle.RustyTeams`) builds but is broken and not released: the app starts the user's own browser with a debug port, and inside the sandbox it can neither see nor start the host's browsers. It needs the browser start to go through `flatpak-spawn --host`. A working Flatpak would end the glibc floor entirely, since it brings its own runtime.
20- The Flatpak (`packaging/linux/flatpak-bundle.sh`, app id `io.github.danieldaeschle.RustyTeams`) is released next to the other packages. The app starts the user's own browser with a debug port; inside the sandbox it finds, starts and stops the host's browser through `flatpak-spawn --host` (`crates/browser/src/host.rs`). It brings its own runtime, so it has no glibc floor. Its CI step may fail without failing the release.
21- No package repository: deb and rpm are release downloads.
21- No package repository: deb and rpm are release downloads.
packaging/linux/flatpak-bundle.sh +2 −4
@@ -3,9 +3,8 @@
3 3 #
4 4 # $DIST/rusty-teams-<version>-linux-<arch>.flatpak
5 5 #
6 # BROKEN: the app cannot start the host's browser from inside the sandbox, so it cannot sign
7 # in (details in packaging/linux/flatpak/io.github.danieldaeschle.RustyTeams.yml). Not part of
8 # the release; kept to work on the sandbox support.
6 # The app finds, starts and stops the host's browser through `flatpak-spawn --host`
7 # (crates/browser/src/host.rs). The release attaches the bundle next to the other packages.
9 8 #
10 9 # Usage: packaging/linux/flatpak-bundle.sh [--no-test] [TARBALL]
11 10 #
@@ -46,7 +45,6 @@ for tool in flatpak flatpak-builder; do
46 45 command -v "$tool" >/dev/null || { echo "error: $tool not found (apt install flatpak flatpak-builder)" >&2; exit 1; }
47 46 done
48 47
49 warn "the Flatpak is known broken: the app cannot start the host's browser from the sandbox"
50 48 echo "==> Rusty Teams $VERSION Flatpak bundle for $ARCH from $(basename "$TARBALL")"
51 49
52 50 WORK="$CARGO_TARGET_DIR/flatpak-bundle"
@@ -3,9 +3,8 @@
3#
3#
4# $DIST/rusty-teams-<version>-linux-<arch>.flatpak
4# $DIST/rusty-teams-<version>-linux-<arch>.flatpak
5#
5#
6# BROKEN: the app cannot start the host's browser from inside the sandbox, so it cannot sign
6# The app finds, starts and stops the host's browser through `flatpak-spawn --host`
7# in (details in packaging/linux/flatpak/io.github.danieldaeschle.RustyTeams.yml). Not part of
7# (crates/browser/src/host.rs). The release attaches the bundle next to the other packages.
8# the release; kept to work on the sandbox support.
9#
8#
10# Usage: packaging/linux/flatpak-bundle.sh [--no-test] [TARBALL]
9# Usage: packaging/linux/flatpak-bundle.sh [--no-test] [TARBALL]
11#
10#
@@ -46,7 +45,6 @@ for tool in flatpak flatpak-builder; do
46 command -v "$tool" >/dev/null || { echo "error: $tool not found (apt install flatpak flatpak-builder)" >&2; exit 1; }
45 command -v "$tool" >/dev/null || { echo "error: $tool not found (apt install flatpak flatpak-builder)" >&2; exit 1; }
47done
46done
48
47
49warn "the Flatpak is known broken: the app cannot start the host's browser from the sandbox"
50echo "==> Rusty Teams $VERSION Flatpak bundle for $ARCH from $(basename "$TARBALL")"
48echo "==> Rusty Teams $VERSION Flatpak bundle for $ARCH from $(basename "$TARBALL")"
51
49
52WORK="$CARGO_TARGET_DIR/flatpak-bundle"
50WORK="$CARGO_TARGET_DIR/flatpak-bundle"
packaging/linux/flatpak/io.github.danieldaeschle.RustyTeams.yml +9 −9
@@ -1,16 +1,14 @@
1 # Flatpak manifest for Rusty Teams. BROKEN, see below: kept so the packaging matches the
2 # other Craft apps and so the sandbox work has a starting point. Not attached to releases.
1 # Flatpak manifest for Rusty Teams, attached to releases (packaging/linux/flatpak-bundle.sh).
3 2 #
4 3 # It repackages the prebuilt binary from package.sh's tarball (packaging/linux/flatpak-bundle.sh):
5 4 # libwebrtc is downloaded during the cargo build, which flatpak-builder's offline build does not
6 5 # allow, so there is no build-from-source manifest.
7 6 #
8 # Why it is broken: the Teams session runs in the user's own Chromium- or Firefox-based browser,
9 # which the app finds on the host and starts with a debug port (crates/browser, ADR 0003). Inside
10 # the sandbox the host's browsers are not visible and cannot be started without
11 # `flatpak-spawn --host` (needs --talk-name=org.freedesktop.Flatpak, granted below, and app code
12 # that uses it). Until then the app starts but cannot sign in. `--endpoint` to a browser started
13 # by hand on the host (`chromium --remote-debugging-port=9222`) works, since the network is shared.
7 # The Teams session runs in the user's own Chromium- or Firefox-based browser on the host
8 # (crates/browser, ADR 0003). The app finds, starts and stops it through `flatpak-spawn --host`
9 # (crates/browser/src/host.rs, needs --talk-name=org.freedesktop.Flatpak below); the debug port
10 # is reachable since the network is shared, and the profile under ~/.var/app is the same path
11 # on the host.
14 12 #
15 13 # The app id must be reverse-DNS, so the desktop file and icon are renamed to it; the window's
16 14 # Wayland app id stays rusty-teams (StartupWMClass in the desktop file pairs them on X11).
@@ -36,8 +34,10 @@ finish-args:
36 34 # Desktop toasts (ADR 0015) and the StatusNotifierItem tray icon.
37 35 - --talk-name=org.freedesktop.Notifications
38 36 - --talk-name=org.kde.StatusNotifierWatcher
39 # Starting the host's browser would go through flatpak-spawn --host (not implemented yet).
37 # Finding, starting and stopping the host's browser through flatpak-spawn --host.
40 38 - --talk-name=org.freedesktop.Flatpak
39 # CalDAV app passwords in the desktop keyring (ADR 0019).
40 - --talk-name=org.freedesktop.secrets
41 41 # Downloaded files and attachments.
42 42 - --filesystem=xdg-download
43 43 build-options:
@@ -1,16 +1,14 @@
1# Flatpak manifest for Rusty Teams. BROKEN, see below: kept so the packaging matches the
1# Flatpak manifest for Rusty Teams, attached to releases (packaging/linux/flatpak-bundle.sh).
2# other Craft apps and so the sandbox work has a starting point. Not attached to releases.
3#
2#
4# It repackages the prebuilt binary from package.sh's tarball (packaging/linux/flatpak-bundle.sh):
3# It repackages the prebuilt binary from package.sh's tarball (packaging/linux/flatpak-bundle.sh):
5# libwebrtc is downloaded during the cargo build, which flatpak-builder's offline build does not
4# libwebrtc is downloaded during the cargo build, which flatpak-builder's offline build does not
6# allow, so there is no build-from-source manifest.
5# allow, so there is no build-from-source manifest.
7#
6#
8# Why it is broken: the Teams session runs in the user's own Chromium- or Firefox-based browser,
7# The Teams session runs in the user's own Chromium- or Firefox-based browser on the host
9# which the app finds on the host and starts with a debug port (crates/browser, ADR 0003). Inside
8# (crates/browser, ADR 0003). The app finds, starts and stops it through `flatpak-spawn --host`
10# the sandbox the host's browsers are not visible and cannot be started without
9# (crates/browser/src/host.rs, needs --talk-name=org.freedesktop.Flatpak below); the debug port
11# `flatpak-spawn --host` (needs --talk-name=org.freedesktop.Flatpak, granted below, and app code
10# is reachable since the network is shared, and the profile under ~/.var/app is the same path
12# that uses it). Until then the app starts but cannot sign in. `--endpoint` to a browser started
11# on the host.
13# by hand on the host (`chromium --remote-debugging-port=9222`) works, since the network is shared.
14#
12#
15# The app id must be reverse-DNS, so the desktop file and icon are renamed to it; the window's
13# The app id must be reverse-DNS, so the desktop file and icon are renamed to it; the window's
16# Wayland app id stays rusty-teams (StartupWMClass in the desktop file pairs them on X11).
14# Wayland app id stays rusty-teams (StartupWMClass in the desktop file pairs them on X11).
@@ -36,8 +34,10 @@ finish-args:
36 # Desktop toasts (ADR 0015) and the StatusNotifierItem tray icon.
34 # Desktop toasts (ADR 0015) and the StatusNotifierItem tray icon.
37 - --talk-name=org.freedesktop.Notifications
35 - --talk-name=org.freedesktop.Notifications
38 - --talk-name=org.kde.StatusNotifierWatcher
36 - --talk-name=org.kde.StatusNotifierWatcher
39 # Starting the host's browser would go through flatpak-spawn --host (not implemented yet).
37 # Finding, starting and stopping the host's browser through flatpak-spawn --host.
40 - --talk-name=org.freedesktop.Flatpak
38 - --talk-name=org.freedesktop.Flatpak
39 # CalDAV app passwords in the desktop keyring (ADR 0019).
40 - --talk-name=org.freedesktop.secrets
41 # Downloaded files and attachments.
41 # Downloaded files and attachments.
42 - --filesystem=xdg-download
42 - --filesystem=xdg-download
43build-options:
43build-options: