mirror of
https://github.com/EFForg/rayhunter.git
synced 2026-04-26 23:49:59 -07:00
Currently you have to override a bunch of paths to use firmware-devel when building the installer. This changes that, and adds a new FIRMWARE_PROFILE envvar that can be used to fix both rootshell and rayhunter-daemon paths at the same time. There is now also a new cargo command for building rootshell, similar to how building the daemon firmware works. I'm not sure what to do with make.sh. I have personally never used it.
38 lines
1.4 KiB
Rust
38 lines
1.4 KiB
Rust
use std::path::Path;
|
|
use std::process::exit;
|
|
|
|
fn main() {
|
|
println!("cargo::rerun-if-env-changed=NO_FIRMWARE_BIN");
|
|
println!("cargo::rerun-if-env-changed=FIRMWARE_PROFILE");
|
|
let profile = std::env::var("FIRMWARE_PROFILE").unwrap_or_else(|_| "firmware".to_string());
|
|
let include_dir = Path::new(env!("CARGO_MANIFEST_DIR"))
|
|
.join("../target/armv7-unknown-linux-musleabihf")
|
|
.join(&profile);
|
|
set_binary_var(&include_dir, "FILE_ROOTSHELL", "rootshell");
|
|
set_binary_var(&include_dir, "FILE_RAYHUNTER_DAEMON", "rayhunter-daemon");
|
|
}
|
|
|
|
fn set_binary_var(include_dir: &Path, var: &str, file: &str) {
|
|
println!("cargo::rerun-if-env-changed={var}");
|
|
if std::env::var_os("NO_FIRMWARE_BIN").is_some() {
|
|
let out_dir = std::env::var("OUT_DIR").unwrap();
|
|
std::fs::create_dir_all(&out_dir).unwrap();
|
|
let blank = Path::new(&out_dir).join("blank");
|
|
std::fs::write(&blank, []).unwrap();
|
|
println!("cargo::rustc-env={var}={}", blank.display());
|
|
return;
|
|
}
|
|
if std::env::var_os(var).is_none() {
|
|
let binary = include_dir.join(file);
|
|
println!("cargo::rerun-if-changed={}", binary.display());
|
|
if !binary.exists() {
|
|
println!(
|
|
"cargo::error=Firmware binary {file} not present at {}",
|
|
binary.display()
|
|
);
|
|
exit(0);
|
|
}
|
|
println!("cargo::rustc-env={var}={}", binary.display());
|
|
}
|
|
}
|