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>
@@ -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: Flatpak78
continue-on-error: true79
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-builder83
DIST="$RUNNER_TEMP/flatpak" packaging/linux/package.sh --skip-build --formats tar84
packaging/linux/flatpak-bundle.sh --no-test "$RUNNER_TEMP"/flatpak/rusty-teams-*-linux-x86_64.tar.gz85
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@v787
- uses: actions/upload-artifact@v778
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
@@ -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, whose84
/// Installed by a deb/rpm (under `/usr` or `/opt`), a Flatpak (under `/app`) or started from85
/// runtime sets `APPIMAGE`. Those bring their own menu entry and updates, so the app85
/// an AppImage, whose runtime sets `APPIMAGE`. Those bring their own menu entry and updates, so the app86
/// 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).87
pub fn is_packaged(executable: &Path, appimage: Option<&std::ffi::OsStr>) -> bool {87
pub 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
93
pub fn should_offer_install(executable: &Path, layout: &Layout, dont_ask: bool) -> bool {94
pub 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"))@@ -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 first163
/// 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
@@ -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, so2
//! lookups and processes go to the host through `flatpak-spawn --host`. The debug port and the3
//! 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
command25
} 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_PATH37
.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 in48
/// 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 path55
.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 = output76
.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
}@@ -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>) -> V156
fn chrome_major(platform: Platform, executable: &Path) -> u32 {156
fn 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
command219
command220
.args(arguments)220
.args(arguments)@@ -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;3
mod browser;3
mod browser;4
mod config;4
mod config;5
mod error;5
mod error;6
mod host;6
mod http;7
mod http;7
mod launch;8
mod launch;8
mod process;9
mod process;@@ -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 @@1
use std::process::Command;2
use std::time::{Duration, Instant};1
use std::time::{Duration, Instant};3
2
4
use crate::config::Platform;3
use crate::config::Platform;@@ -38,7 +37,7 @@ pub(crate) fn parse_lsof_pid(output: &str) -> Option<u32> {38
}37
}39
38
40
fn run(program: &str, arguments: &[&str]) -> Result<String, BrowserError> {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
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, BrowserEr85
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<(), Br103
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
.status116
.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 {@@ -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.67
pub fn installed_browsers() -> Vec<InstalledBrowser> {67
pub 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>) -> Opti90
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()?;@@ -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.@@ -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>.flatpak4
# $DIST/rusty-teams-<version>-linux-<arch>.flatpak5
#5
#6
# BROKEN: the app cannot start the host's browser from inside the sandbox, so it cannot sign6
# 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 of7
# (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; do46
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; }47
done46
done48
47
49
warn "the Flatpak is known broken: the app cannot start the host's browser from the sandbox"50
echo "==> Rusty Teams $VERSION Flatpak bundle for $ARCH from $(basename "$TARBALL")"48
echo "==> Rusty Teams $VERSION Flatpak bundle for $ARCH from $(basename "$TARBALL")"51
49
52
WORK="$CARGO_TARGET_DIR/flatpak-bundle"50
WORK="$CARGO_TARGET_DIR/flatpak-bundle"@@ -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 the1
# 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 not4
# libwebrtc is downloaded during the cargo build, which flatpak-builder's offline build does not6
# 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 host9
# which the app finds on the host and starts with a debug port (crates/browser, ADR 0003). Inside8
# (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 without9
# (crates/browser/src/host.rs, needs --talk-name=org.freedesktop.Flatpak below); the debug port11
# `flatpak-spawn --host` (needs --talk-name=org.freedesktop.Flatpak, granted below, and app code10
# is reachable since the network is shared, and the profile under ~/.var/app is the same path12
# that uses it). Until then the app starts but cannot sign in. `--endpoint` to a browser started11
# 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's13
# The app id must be reverse-DNS, so the desktop file and icon are renamed to it; the window's16
# 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.Notifications35
- --talk-name=org.freedesktop.Notifications38
- --talk-name=org.kde.StatusNotifierWatcher36
- --talk-name=org.kde.StatusNotifierWatcher39
# 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.Flatpak38
- --talk-name=org.freedesktop.Flatpak39
# CalDAV app passwords in the desktop keyring (ADR 0019).40
- --talk-name=org.freedesktop.secrets41
# Downloaded files and attachments.41
# Downloaded files and attachments.42
- --filesystem=xdg-download42
- --filesystem=xdg-download43
build-options:43
build-options: