Always include firmware binaries statically into installer

This commit is contained in:
Sashanoraa
2025-05-15 23:24:45 -04:00
committed by Cooper Quintin
parent a2269fb5f7
commit d6e4f6a71d
6 changed files with 54 additions and 26 deletions

View File

@@ -8,6 +8,10 @@ on:
env:
CARGO_TERM_COLOR: always
FILE_ROOTSHELL: ../../rootshell/rootshell
FILE_RAYHUNTER_DAEMON_ORBIC: ../../rayhunter-daemon-orbic/rayhunter-daemon
FILE_RAYHUNTER_DAEMON_TPLINK: ../../rayhunter-daemon-tplink/rayhunter-daemon
jobs:
build_rayhunter_check:
@@ -105,8 +109,7 @@ jobs:
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.platform.target }}
- run: cargo build --bin installer --release --target ${{ matrix.platform.target }} --features vendor
- run: cargo build --bin installer --release --target ${{ matrix.platform.target }}
- uses: actions/upload-artifact@v4
with:
name: installer-${{ matrix.platform.name }}

View File

@@ -8,6 +8,7 @@ on:
env:
CARGO_TERM_COLOR: always
NO_FIRMWARE_BIN: true
jobs:
check_and_test:

View File

@@ -3,9 +3,6 @@ name = "installer"
version = "0.1.0"
edition = "2024"
[features]
vendor = []
[dependencies]
anyhow = "1.0.98"
axum = "0.8.3"

45
installer/build.rs Normal file
View File

@@ -0,0 +1,45 @@
use core::str;
use std::path::Path;
use std::process::exit;
fn main() {
println!("cargo::rerun-if-env-changed=NO_FIRMWARE_BIN");
let include_dir = Path::new(concat!(
env!("CARGO_MANIFEST_DIR"),
"/../target/armv7-unknown-linux-musleabihf/release/"
));
set_binary_var(&include_dir, "FILE_ROOTSHELL", "rootshell");
set_binary_var(
&include_dir,
"FILE_RAYHUNTER_DAEMON_ORBIC",
"rayhunter-daemon",
);
set_binary_var(
&include_dir,
"FILE_RAYHUNTER_DAEMON_TPLINK",
"rayhunter-daemon",
);
}
fn set_binary_var(include_dir: &Path, var: &str, file: &str) {
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);
if !binary.exists() {
println!(
"cargo::error=Firmware binary {file} not present at {}",
binary.display()
);
exit(0);
}
println!("cargo::rustc-env={var}={}", binary.display());
println!("cargo::rerun-if-changed={}", binary.display());
}
}

View File

@@ -70,13 +70,7 @@ async fn setup_rootshell(
serial_interface: &Interface,
adb_device: &mut ADBUSBDevice,
) -> Result<()> {
#[cfg(feature = "vendor")]
let rootshell_bin = include_bytes!("../../rootshell/rootshell");
#[cfg(not(feature = "vendor"))]
let rootshell_bin = &tokio::fs::read("target/armv7-unknown-linux-musleabihf/release/rootshell")
.await
.context("Error reading rootshell from local file system")?;
let rootshell_bin = include_bytes!(env!("FILE_ROOTSHELL"));
install_file(
serial_interface,
@@ -100,14 +94,7 @@ async fn setup_rayhunter(
serial_interface: &Interface,
mut adb_device: ADBUSBDevice,
) -> Result<ADBUSBDevice> {
#[cfg(feature = "vendor")]
let rayhunter_daemon_bin = include_bytes!("../../rayhunter-daemon-orbic/rayhunter-daemon");
#[cfg(not(feature = "vendor"))]
let rayhunter_daemon_bin =
&tokio::fs::read("target/armv7-unknown-linux-musleabihf/release/rayhunter-daemon")
.await
.context("Error reading rayhunter-daemon from local file system")?;
let rayhunter_daemon_bin = include_bytes!(env!("FILE_RAYHUNTER_DAEMON_ORBIC"));
at_syscmd(serial_interface, "mkdir -p /data/rayhunter").await?;
install_file(

View File

@@ -114,12 +114,7 @@ async fn tplink_run_install(skip_sdcard: bool, admin_ip: String) -> Result<(), E
)
.await?;
#[cfg(feature = "vendor")]
let rayhunter_daemon_bin = include_bytes!("../../rayhunter-daemon-tplink/rayhunter-daemon");
#[cfg(not(feature = "vendor"))]
let rayhunter_daemon_bin =
&tokio::fs::read("target/armv7-unknown-linux-musleabihf/release/rayhunter-daemon").await?;
let rayhunter_daemon_bin = include_bytes!(env!("FILE_RAYHUNTER_DAEMON_TPLINK"));
telnet_send_file(addr, "/media/card/rayhunter-daemon", rayhunter_daemon_bin).await?;
telnet_send_file(