I try building RustDesk server (from GitHub - rustdesk/rustdesk-server: RustDesk Server Program).
After unpacking the tarball, I run cargo build --release, which compiles a lot until it hits this error:
Compiling mac_address v1.1.3
error[E0433]: failed to resolve: use of undeclared crate or module `nix`
--> /root/.cargo/registry/src/github.com-1285ae84e5963aae/mac_address-1.1.3/src/linux.rs:4:5
|
4 | use nix::{ifaddrs::*, sys::socket::SockAddr};
| ^^^ use of undeclared crate or module `nix`
The fix seems simple. mac_address has OS-dependent parts, with tests on target_os for linux, freebsd, and macos. I am building on netbsd, I need a minor adjustment in /root/.cargo/registry/src/github.com-1285ae84e5963aae/mac_address-1.1.3 (patch below).
But the change is not taken into account, cargo build --release yields the same error. Any hint about what I am doing wrong?
--- mac_address-1.1.3.orig/Cargo.toml 2022-12-06 09:56:29.628514870 +0100
+++ mac_address-1.1.3/Cargo.toml 2022-12-06 09:57:05.244779593 +0100
@@ -27,9 +27,9 @@
version = "1.0.59"
[dev-dependencies.serde_test]
version = "1.0.117"
-[target."cfg(any(target_os = \"linux\", target_os = \"macos\", target_os = \"freebsd\"))".dependencies.nix]
+[target."cfg(any(target_os = \"linux\", target_os = \"macos\", target_os = \"freebsd\" , target_os = \"netbsd\"))".dependencies.nix]
version = "0.23.1"
[target."cfg(windows)".dependencies.winapi]
version = "0.3"
features = ["winerror", "ws2def", "iphlpapi"]
diff -r -U4 mac_address-1.1.3.orig/Cargo.toml.orig mac_address-1.1.3/Cargo.toml.orig
--- mac_address-1.1.3.orig/Cargo.toml.orig 2022-12-06 09:56:29.628597544 +0100
+++ mac_address-1.1.3/Cargo.toml.orig 2022-12-06 09:57:24.792895719 +0100
@@ -11,9 +11,9 @@
[dependencies]
serde = { version = "1.0.117", features = ["derive"], optional = true }
-[target.'cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd"))'.dependencies]
+[target.'cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd", target_os = "netbsd"))'.dependencies]
nix = "0.23.1"
[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3", features = ["winerror", "ws2def", "iphlpapi"] }
diff -r -U4 mac_address-1.1.3.orig/examples/lookup.rs mac_address-1.1.3/examples/lookup.rs
--- mac_address-1.1.3.orig/examples/lookup.rs 2022-12-06 09:56:29.629130800 +0100
+++ mac_address-1.1.3/examples/lookup.rs 2022-12-06 09:57:42.401808037 +0100
@@ -6,8 +6,11 @@
#[cfg(any(target_os = "freebsd"))]
let name = "em0";
+ #[cfg(any(target_os = "netbsd"))]
+ let name = "xennet0";
+
#[cfg(target_os = "windows")]
let name = "Ethernet";
match mac_address_by_name(name) {
diff -r -U4 mac_address-1.1.3.orig/src/iter/mod.rs mac_address-1.1.3/src/iter/mod.rs
--- mac_address-1.1.3.orig/src/iter/mod.rs 2022-12-06 09:56:29.629518872 +0100
+++ mac_address-1.1.3/src/iter/mod.rs 2022-12-06 09:58:02.801940916 +0100
@@ -1,9 +1,9 @@
#[cfg(target_os = "windows")]
#[path = "windows.rs"]
mod internal;
-#[cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd"))]
+#[cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd", target_os = "netbsd"))]
#[path = "linux.rs"]
mod internal;
pub use internal::MacAddressIterator;
diff -r -U4 mac_address-1.1.3.orig/src/lib.rs mac_address-1.1.3/src/lib.rs
--- mac_address-1.1.3.orig/src/lib.rs 2022-12-06 09:56:29.629711886 +0100
+++ mac_address-1.1.3/src/lib.rs 2022-12-06 09:58:33.217489123 +0100
@@ -9,9 +9,9 @@
#[cfg(target_os = "windows")]
#[path = "windows.rs"]
mod os;
-#[cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd"))]
+#[cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd", target_os = "netbsd"))]
#[path = "linux.rs"]
mod os;
mod iter;
@@ -25,9 +25,9 @@
/// Signifies an internal API error has occurred.
InternalError,
}
-#[cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd"))]
+#[cfg(any(target_os = "linux", target_os = "macos", target_os = "freebsd", arget_os = "netbsd"))]
impl From<nix::Error> for MacAddressError {
fn from(_: nix::Error) -> MacAddressError {
MacAddressError::InternalError
}