Skip to content

Commit

Permalink
Add a version check for bubblewrap in the server. Fixes crossbeam-rs#316
Browse files Browse the repository at this point in the history
  • Loading branch information
chmanchester committed Jul 18, 2019
1 parent 2866bbe commit 6ba6f6c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ nix = { version = "0.11.0", optional = true }
rouille = { version = "2.2", optional = true, default-features = false, features = ["ssl"] }
syslog = { version = "4.0.1", optional = true }
void = { version = "1", optional = true }
version-compare = { version = "0.0.8", optional = true }

[patch.crates-io]
# Waiting for https://github.com/tiny-http/tiny-http/pull/151
Expand Down Expand Up @@ -134,7 +135,7 @@ unstable = []
# Enables distributed support in the sccache client
dist-client = ["ar", "flate2", "hyper", "hyperx", "reqwest", "rust-crypto", "url"]
# Enables the sccache-dist binary
dist-server = ["arraydeque", "crossbeam-utils", "jsonwebtoken", "flate2", "libmount", "nix", "openssl", "reqwest", "rouille", "syslog", "void"]
dist-server = ["arraydeque", "crossbeam-utils", "jsonwebtoken", "flate2", "libmount", "nix", "openssl", "reqwest", "rouille", "syslog", "void", "version-compare"]
# Enables dist tests with external requirements
dist-tests = []

Expand Down
21 changes: 21 additions & 0 deletions src/bin/sccache-dist/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use std::iter;
use std::path::{self, Path, PathBuf};
use std::process::{ChildStdin, Command, Output, Stdio};
use std::sync::{Mutex};
use version_compare::Version;

use crate::errors::*;

Expand Down Expand Up @@ -95,6 +96,26 @@ impl OverlayBuilder {
bail!("not running as root")
}

let out = Command::new(&bubblewrap).arg("--version").check_stdout_trim()
.chain_err(|| "Failed to execute bwrap for version check")?;
if let Some(s) = out.split_whitespace().nth(1) {
match (Version::from("0.3.0"), Version::from(s)) {
(Some(min), Some(seen)) => {
if seen < min {
bail!("bubblewrap 0.3.0 or later is required, got {:?} for {:?}",
out, bubblewrap);
}
},
(_, _) => {
bail!("Unexpected version format running {:?}: got {:?}, expected \"bubblewrap x.x.x\"",
bubblewrap, out);
}
}
} else {
bail!("Unexpected version format running {:?}: got {:?}, expected \"bubblewrap x.x.x\"",
bubblewrap, out);
}

// TODO: pidfile
let ret = Self {
bubblewrap,
Expand Down

0 comments on commit 6ba6f6c

Please sign in to comment.