From b04e2a96cc3554da2a4c0ad73e02bb835a58f3d8 Mon Sep 17 00:00:00 2001 From: Igor Raits Date: Sat, 15 Feb 2020 11:40:33 +0100 Subject: [PATCH] Fix build Signed-off-by: Igor Raits --- ...thostname-arguments-to-a-proper-type.patch | 27 +++++++++++++++++++ rust-sys-info.spec | 5 ++-- 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 0001-Cast-gethostname-arguments-to-a-proper-type.patch diff --git a/0001-Cast-gethostname-arguments-to-a-proper-type.patch b/0001-Cast-gethostname-arguments-to-a-proper-type.patch new file mode 100644 index 0000000..cd3f6da --- /dev/null +++ b/0001-Cast-gethostname-arguments-to-a-proper-type.patch @@ -0,0 +1,27 @@ +From f7c398680b57b3fce0584314ac255e45ef1bd932 Mon Sep 17 00:00:00 2001 +From: Igor Raits +Date: Sat, 15 Feb 2020 11:38:40 +0100 +Subject: [PATCH] Cast gethostname() arguments to a proper type + +Closes: https://github.com/FillZpp/sys-info-rs/issues/43 +Signed-off-by: Igor Raits +--- + lib.rs | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lib.rs b/lib.rs +index b26bb9f..8bb1891 100644 +--- a/lib.rs ++++ b/lib.rs +@@ -395,7 +395,7 @@ pub fn hostname() -> Result { + unsafe { + let buf_size = libc::sysconf(libc::_SC_HOST_NAME_MAX) as usize; + let mut buf = Vec::::with_capacity(buf_size + 1); +- if libc::gethostname(buf.as_mut_ptr() as *mut i8, buf_size) < 0 { ++ if libc::gethostname(buf.as_mut_ptr() as *mut libc::c_char, buf_size) < 0 { + return Err(Error::IO(io::Error::last_os_error())); + } + let hostname_len = libc::strnlen(buf.as_ptr() as *const i8, buf_size); +-- +2.25.0 + diff --git a/rust-sys-info.spec b/rust-sys-info.spec index bdcb977..f6006dc 100644 --- a/rust-sys-info.spec +++ b/rust-sys-info.spec @@ -13,6 +13,8 @@ Summary: Get system information in Rust License: MIT URL: https://crates.io/crates/sys-info Source: %{crates_source} +# https://github.com/FillZpp/sys-info-rs/pull/44 +Patch0001: 0001-Cast-gethostname-arguments-to-a-proper-type.patch ExclusiveArch: %{rust_arches} %if %{__cargo_skip_build} @@ -28,7 +30,6 @@ Get system information in Rust.} %package devel Summary: %{summary} -Requires: /usr/bin/hostname BuildArch: noarch %description devel %{_description} @@ -68,7 +69,7 @@ which use "default" feature of "%{crate}" crate. %if %{with check} %check -%cargo_test -- -- --skip test::test_hostname +%cargo_test %endif %changelog