From d1124720f4db820d750389ff820e127df309046d Mon Sep 17 00:00:00 2001 From: Fabio Valentini Date: Sun, 22 Sep 2024 01:50:03 +0200 Subject: [PATCH] Port from match_cfg to cfg-if and bump version-sync from 0.8 to 0.9 --- 0001-port-from-match_cfg-to-cfg-if.patch | 49 ++++++++++++++++++++++++ hostname-fix-metadata-auto.diff | 5 ++- hostname-fix-metadata.diff | 16 ++++++++ rust-hostname.spec | 15 ++++++-- 4 files changed, 79 insertions(+), 6 deletions(-) create mode 100644 0001-port-from-match_cfg-to-cfg-if.patch create mode 100644 hostname-fix-metadata.diff diff --git a/0001-port-from-match_cfg-to-cfg-if.patch b/0001-port-from-match_cfg-to-cfg-if.patch new file mode 100644 index 0000000..bffb242 --- /dev/null +++ b/0001-port-from-match_cfg-to-cfg-if.patch @@ -0,0 +1,49 @@ +From 3976c5bac1a5e7a4e9e0b8b12d8695ec6f8f00fb Mon Sep 17 00:00:00 2001 +From: Fabio Valentini +Date: Sun, 22 Sep 2024 01:47:58 +0200 +Subject: [PATCH] port from match_cfg to cfg-if + +--- + src/lib.rs | 12 +++++------- + 1 file changed, 5 insertions(+), 7 deletions(-) + +diff --git a/src/lib.rs b/src/lib.rs +index 1a817b3..7ac8fef 100644 +--- a/src/lib.rs ++++ b/src/lib.rs +@@ -57,27 +57,25 @@ println!("{:?}", name); + #![allow(unknown_lints, unused_extern_crates)] + + #[macro_use] +-extern crate match_cfg; ++extern crate cfg_if; + + #[cfg(feature = "set")] + use std::ffi::OsStr; + use std::ffi::OsString; + use std::io; + +-match_cfg! { +- #[cfg(any(unix, target_os = "redox"))] => { ++cfg_if! { ++ if #[cfg(any(unix, target_os = "redox"))] { + extern crate libc; + + mod nix; + use ::nix as sys; +- } +- #[cfg(target_os = "windows")] => { ++ } else if #[cfg(target_os = "windows")] { + extern crate winapi; + + mod windows; + use ::windows as sys; +- } +- _ => { ++ } else { + compile_error!("Unsupported target OS! Create an issue: https://github.com/svartalf/hostname/issues/new"); + } + } +-- +2.46.1 + diff --git a/hostname-fix-metadata-auto.diff b/hostname-fix-metadata-auto.diff index 6da74dc..1eb76cd 100644 --- a/hostname-fix-metadata-auto.diff +++ b/hostname-fix-metadata-auto.diff @@ -1,9 +1,10 @@ --- hostname-0.3.1/Cargo.toml 2020-02-28T16:58:01+00:00 -+++ hostname-0.3.1/Cargo.toml 2023-05-17T09:32:55.784973+00:00 -@@ -33,6 +33,3 @@ ++++ hostname-0.3.1/Cargo.toml 2024-09-21T23:41:05.031544+00:00 +@@ -33,6 +33,4 @@ set = [] [target."cfg(any(unix, target_os = \"redox\"))".dependencies.libc] version = "^0.2" -[target."cfg(target_os = \"windows\")".dependencies.winapi] -version = "^0.3" -features = ["sysinfoapi"] ++ diff --git a/hostname-fix-metadata.diff b/hostname-fix-metadata.diff new file mode 100644 index 0000000..82cf026 --- /dev/null +++ b/hostname-fix-metadata.diff @@ -0,0 +1,16 @@ +--- hostname-0.3.1/Cargo.toml 2020-02-28T16:58:01+00:00 ++++ hostname-0.3.1/Cargo.toml 2024-09-21T23:41:28.498611+00:00 +@@ -23,10 +23,10 @@ + [package.metadata.docs.rs] + features = ["set"] + rustdoc-args = ["--cfg", "docsrs"] +-[dependencies.match_cfg] +-version = "^0.1" ++[dependencies.cfg-if] ++version = "^1.0" + [dev-dependencies.version-sync] +-version = "0.8" ++version = "0.9" + + [features] + default = [] diff --git a/rust-hostname.spec b/rust-hostname.spec index b6d147a..c765a67 100644 --- a/rust-hostname.spec +++ b/rust-hostname.spec @@ -1,4 +1,4 @@ -# Generated by rust2rpm 24 +# Generated by rust2rpm 26 %bcond_without check %global debug_package %{nil} @@ -12,10 +12,17 @@ Summary: Cross-platform system's host name functions License: MIT URL: https://crates.io/crates/hostname Source: %{crates_source} -# Automatically generated patch to strip foreign dependencies +# Automatically generated patch to strip dependencies and normalize metadata Patch: hostname-fix-metadata-auto.diff +# Manually created patch for downstream crate metadata changes +# * bump version-sync dev-dependency from 0.8 to 0.9: +# https://github.com/svartalf/hostname/commit/ecf28eb +# * backport upstream port from match_cfg to cfg-if: +# https://github.com/svartalf/hostname/commit/7e930e9 +Patch: hostname-fix-metadata.diff +Patch: 0001-port-from-match_cfg-to-cfg-if.patch -BuildRequires: rust-packaging >= 21 +BuildRequires: cargo-rpm-macros >= 24 %global _description %{expand: Cross-platform system's host name functions.} @@ -62,7 +69,7 @@ use the "set" feature of the "%{crate}" crate. %ghost %{crate_instdir}/Cargo.toml %prep -%autosetup -n %{crate}-%{version_no_tilde} -p1 +%autosetup -n %{crate}-%{version} -p1 %cargo_prep %generate_buildrequires