From 426e7c488aa12f7b21e02709bc6d8eff11421fb9 Mon Sep 17 00:00:00 2001 From: aokblast Date: Sun, 22 Sep 2024 22:35:39 +0800 Subject: [PATCH] feat: add FreeBSD enhancement (#67) * feat: add /usr/local/bin in search path Because OS like *BSD tends to install 3rd software into /usr/local/bin instead of /bin, so I think we should add it as the default search path * feat: add FreeBSD x86-64 cross compile support * Minor edits --------- Co-authored-by: Eric Zhang --- Cross.toml | 5 +++++ crates/sshx/src/terminal.rs | 7 ++++++- scripts/release.sh | 3 +++ static/get | 1 + 4 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 Cross.toml diff --git a/Cross.toml b/Cross.toml new file mode 100644 index 0000000..419b8f7 --- /dev/null +++ b/Cross.toml @@ -0,0 +1,5 @@ +[target.x86_64-unknown-freebsd] +pre-build = [ + "apt-get update", + "apt install -y protobuf-compiler", +] diff --git a/crates/sshx/src/terminal.rs b/crates/sshx/src/terminal.rs index a330bbf..a0873e4 100644 --- a/crates/sshx/src/terminal.rs +++ b/crates/sshx/src/terminal.rs @@ -29,7 +29,12 @@ pub async fn get_default_shell() -> String { return shell; } } - for shell in ["/bin/bash", "/bin/sh"] { + for shell in [ + "/bin/bash", + "/bin/sh", + "/usr/local/bin/bash", + "/usr/local/bin/sh", + ] { if fs::metadata(shell).await.is_ok() { return shell.to_string(); } diff --git a/scripts/release.sh b/scripts/release.sh index dc69b83..4c22a0e 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -35,6 +35,8 @@ cargo build --release --target x86_64-apple-darwin # aarch64-apple-darwin: for macOS on Apple Silicon cargo build --release --target aarch64-apple-darwin +cross build --release --target x86_64-unknown-freebsd + temp=$(mktemp) targets=( x86_64-unknown-linux-musl @@ -43,6 +45,7 @@ targets=( armv7-unknown-linux-musleabihf x86_64-apple-darwin aarch64-apple-darwin + x86_64-unknown-freebsd ) for target in "${targets[@]}" do diff --git a/static/get b/static/get index 50f3b6d..69b353b 100644 --- a/static/get +++ b/static/get @@ -14,6 +14,7 @@ set +e case "$(uname -s)" in Linux*) suffix="-unknown-linux-musl";; Darwin*) suffix="-apple-darwin";; + FreeBSD*) suffix="-unknown-freebsd";; *) echo "Unsupported OS $(uname -s)"; exit 1;; esac