diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 78c96db..1f5f91a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,6 +33,7 @@ jobs: - wasm32-wasi - x86_64-apple-darwin - x86_64-unknown-redox + - x86_64-unknown-illumos steps: - uses: actions/checkout@v2 - uses: actions-rs/toolchain@v1 @@ -186,6 +187,25 @@ jobs: - run: cargo update -p js-sys --precise 0.3.55 - run: cargo update -p wasm-bindgen --precise 0.2.78 - run: cargo update -p log --precise 0.4.17 + - run: cargo update -p quote --precise 1.0.30 + - run: cargo update -p proc-macro2 --precise 1.0.63 - run: cargo build --all-features --target=${{ matrix.cc }} - run: cargo build --no-default-features --target=${{ matrix.cc }} - run: RUSTFLAGS="--cfg target_os=\"daku\"" cargo build --target=${{ matrix.cc }} + cross-compile-illumos: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] + tc: [1.65.0, stable, beta, nightly] + cc: + - x86_64-unknown-illumos + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: ${{ matrix.tc }} + target: ${{ matrix.cc }} + override: true + - run: cargo build --all-features --target=${{ matrix.cc }} diff --git a/src/unix.rs b/src/unix.rs index ba92f55..a1e262c 100644 --- a/src/unix.rs +++ b/src/unix.rs @@ -300,12 +300,9 @@ pub(crate) fn devicename_os() -> OsString { #[cfg(not(any(target_os = "macos", target_os = "illumos")))] pub(crate) fn devicename() -> String { - let mut distro = String::new(); - if let Ok(program) = std::fs::read_to_string("/etc/machine-info") { let program = program.into_bytes(); - - distro.push_str(&String::from_utf8_lossy(&program)); + let distro = String::from_utf8_lossy(&program); for i in distro.split('\n') { let mut j = i.split('='); @@ -330,24 +327,27 @@ pub(crate) fn devicename_os() -> OsString { let out = os_from_cfstring(unsafe { SCDynamicStoreCopyComputerName(null_mut(), null_mut()) }); - let computer = if out.as_bytes().is_empty() { Err(hostname_os()) } else { Ok(out) }; + fancy_fallback_os(computer) } #[cfg(target_os = "illumos")] pub(crate) fn devicename() -> String { - let mut nodename = String::new(); - if let Ok(program) = std::fs::read_to_string("/etc/nodename") { let program = program.into_bytes(); - nodename.push_str(&String::from_utf8_lossy(&program)); - nodename.pop(); // Remove the trailing newline + let mut nodename = String::from_utf8_lossy(&program).to_string(); + + // Remove the trailing newline + nodename.pop(); + + return nodename; } + fancy_fallback(Err(hostname())) } @@ -444,14 +444,10 @@ pub(crate) fn distro_os() -> Option { #[cfg(not(target_os = "macos"))] pub(crate) fn distro() -> Option { - let mut distro = String::new(); - let program = std::fs::read_to_string("/etc/os-release") .ok()? .into_bytes(); - - distro.push_str(&String::from_utf8_lossy(&program)); - + let distro = String::from_utf8_lossy(&program); let mut fallback = None; for i in distro.split('\n') {