Make BUILD_GUI=0 avoid using GUI libraries & better errors when spawn fails (#592)

Co-authored-by: Mark Sheppard <[email protected]>
Co-authored-by: Kevin Yue <[email protected]>
This commit is contained in:
Kevin YueandMark Sheppard authored and GitHub committed 2026-04-16 10:32:38 -04:00
commit 635fd9f8bf
6 files changed
+36 -17

No files matched your search

+1 -1
View File
@@ -111,7 +111,7 @@ build-rs:
if [ $(BUILD_GUI) -eq 1 ]; then \
$(CARGO) build $(CARGO_BUILD_ARGS) -p gpclient -p gpservice -p gpauth -p gpgui-helper; \
else \
$(CARGO) build $(CARGO_BUILD_ARGS) -p gpclient -p gpservice -p gpauth; \
$(CARGO) build $(CARGO_BUILD_ARGS) -p gpclient -p gpservice -p gpauth --no-default-features; \
fi
clean:
+5 -2
View File
@@ -288,13 +288,16 @@ This project includes a DevContainer configuration that provides a consistent, r
```
3. **Build the project:**
To build everything including the GUI helper run this command:
```bash
docker run --privileged --cap-add=NET_ADMIN --device=/dev/net/tun \
-v "$(pwd)":/workspace -w /workspace gpoc-devcontainer \
--tty -v "$(pwd)":/workspace -w /workspace gpoc-devcontainer \
bash -c "export PATH=/usr/local/cargo/bin:\$PATH && make build"
```
To build without the GUI helper run the same command as above, but with `BUILD_GUI=0` passed as an argument to `make`.
4. **Locate build artifacts:**
5. **Locate build artifacts:**
The compiled binaries will be available in `target/release/`:
- `gpclient` – CLI client
+10 -6
View File
@@ -177,12 +177,16 @@ impl<'a> SamlAuthLauncher<'a> {
}
let mut non_root_cmd = auth_cmd.into_non_root()?;
let output = non_root_cmd
.kill_on_drop(true)
.stdout(Stdio::piped())
.spawn()?
.wait_with_output()
.await?;
let child = non_root_cmd.kill_on_drop(true).stdout(Stdio::piped()).spawn();
let child = match child {
Ok(child) => child,
Err(err) => {
bail!("Failed to spawn {}: {}", program, err);
}
};
let output = child.wait_with_output().await?;
let Ok(auth_result) = serde_json::from_slice::<SamlAuthResult>(&output.stdout) else {
bail!("Failed to parse auth data")
@@ -50,7 +50,12 @@ impl<'a> GuiHelperLauncher<'a> {
info!("Launching gpgui-helper");
let mut non_root_cmd = cmd.into_non_root()?;
let mut child = non_root_cmd.kill_on_drop(true).stdin(Stdio::piped()).spawn()?;
let child = non_root_cmd.kill_on_drop(true).stdin(Stdio::piped()).spawn();
let mut child = match child {
Ok(child) => child,
Err(err) => bail!("Failed to spawn {}: {}", self.program.display(), err),
};
let Some(mut stdin) = child.stdin.take() else {
bail!("Failed to open stdin");
};
+6 -1
View File
@@ -69,7 +69,12 @@ impl<'a> GuiLauncher<'a> {
info!("Launching gpgui");
let mut non_root_cmd = cmd.into_non_root()?;
let mut child = non_root_cmd.kill_on_drop(true).stdin(Stdio::piped()).spawn()?;
let child = non_root_cmd.kill_on_drop(true).stdin(Stdio::piped()).spawn();
let mut child = match child {
Ok(child) => child,
Err(err) => bail!("Failed to spawn {}: {}", self.program.display(), err),
};
let Some(mut stdin) = child.stdin.take() else {
bail!("Failed to open stdin");
};
+8 -6
View File
@@ -72,12 +72,14 @@ impl<'a> HipLauncher<'a> {
cmd.env("APP_VERSION", client_version);
}
let output = cmd
.kill_on_drop(true)
.stdout(Stdio::piped())
.spawn()?
.wait_with_output()
.await?;
let child = cmd.kill_on_drop(true).stdout(Stdio::piped()).spawn();
let child = match child {
Ok(child) => child,
Err(err) => bail!("Failed to spawn {}: {}", self.program, err),
};
let output = child.wait_with_output().await?;
if let Some(exit_status) = output.status.code() {
if exit_status != 0 {