diff --git a/.gitignore b/.gitignore index c1b0999..af8e1ab 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ /nispor-1.2.3.tar.gz /nispor-1.2.5.tar.gz /nispor-1.2.7.tar.gz +/nispor-1.2.8.tar.gz diff --git a/fix_tokio_dep.patch b/fix_tokio_dep.patch deleted file mode 100644 index d9937b0..0000000 --- a/fix_tokio_dep.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/src/lib/Cargo.toml b/src/lib/Cargo.toml -index 60400ff..6d27cae 100644 ---- a/src/lib/Cargo.toml -+++ b/src/lib/Cargo.toml -@@ -23,7 +23,7 @@ netlink-packet-route = "0.12.0" - netlink-sys = "0.8.3" - netlink-packet-utils = "0.5.1" - ethtool = "0.2.2" --tokio = { version = "1.19.2", features = ["macros", "rt"] } -+tokio = { version = "1.18", features = ["macros", "rt"] } - futures = "0.3.21" - libc = "0.2.126" - log = "0.4.17" diff --git a/nispor.spec b/nispor.spec index f015a7d..e3c32c3 100644 --- a/nispor.spec +++ b/nispor.spec @@ -2,13 +2,13 @@ %bcond_with check Name: nispor -Version: 1.2.7 -Release: 2%{?dist} +Version: 1.2.8 +Release: 1%{?dist} Summary: Unified interface for Linux network state querying License: ASL 2.0 URL: https://github.com/nispor/nispor Source: https://github.com/nispor/nispor/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz -Patch0: fix_tokio_dep.patch +Patch1: use-clap-3.patch ExclusiveArch: %{rust_arches} BuildRequires: make BuildRequires: pkg-config @@ -18,23 +18,24 @@ BuildRequires: rust-packaging BuildRequires: systemd-devel BuildRequires: systemd-rpm-macros BuildRequires: patchelf +BuildRequires: (crate(clap/cargo) >= 3.1.0 with crate(clap/cargo) < 4.0) +BuildRequires: (crate(clap/default) >= 3.1.0 with crate(clap/default) < 4.0) +BuildRequires: (crate(env_logger/default) >= 0.9 with crate(env_logger/default) < 0.10) +BuildRequires: (crate(ethtool/default) >= 0.2.2 with crate(ethtool/default) < 0.3) +BuildRequires: (crate(futures/default) >= 0.3 with crate(futures/default) < 0.4) +BuildRequires: (crate(libc/default) >= 0.2.126 with crate(libc/default) < 0.3) +BuildRequires: (crate(log/default) >= 0.4 with crate(log/default) < 0.5) +BuildRequires: (crate(mptcp-pm/default) >= 0.1.1 with crate(mptcp-pm/default) < 0.2) +BuildRequires: (crate(netlink-packet-route/default) >= 0.13.0 with crate(netlink-packet-route/default) < 0.14) +BuildRequires: (crate(netlink-packet-utils/default) >= 0.5.1 with crate(netlink-packet-utils/default) < 0.6) +BuildRequires: (crate(netlink-sys/default) >= 0.8.3 with crate(netlink-sys/default) < 0.9) +BuildRequires: (crate(rtnetlink/default) >= 0.11.0 with crate(rtnetlink/default) < 0.12) BuildRequires: (crate(serde/default) >= 1.0 with crate(serde/default) < 2.0) BuildRequires: (crate(serde/derive) >= 1.0 with crate(serde/derive) < 2.0) BuildRequires: (crate(serde_json/default) >= 1.0 with crate(serde_json/default) < 2.0) -BuildRequires: (crate(rtnetlink/default) >= 0.10.0 with crate(rtnetlink/default) < 0.11.0) -BuildRequires: (crate(netlink-packet-route/default) >= 0.12.0 with crate(netlink-packet-route/default) < 0.13.0) -BuildRequires: (crate(netlink-packet-utils/default) >= 0.5.1 with crate(netlink-packet-utils/default) < 0.6.0) -BuildRequires: (crate(netlink-sys/default) >= 0.8.3 with crate(netlink-sys/default) < 0.9.0) -BuildRequires: (crate(ethtool/default) >= 0.2.2 with crate(ethtool/default) < 0.3.0) -BuildRequires: (crate(mptcp-pm/default) >= 0.1.1 with crate(mptcp-pm/default) < 0.2.0) +BuildRequires: (crate(serde_yaml/default) >= 0.9 with crate(serde_yaml/default) < 0.10) BuildRequires: (crate(tokio/macros) >= 1.18 with crate(tokio/macros) < 2.0) BuildRequires: (crate(tokio/rt) >= 1.18 with crate(tokio/rt) < 2.0) -BuildRequires: (crate(libc/default) >= 0.2.126 with crate(libc/default) < 0.3.0) -BuildRequires: (crate(clap/default) >= 3.1.2 with crate(clap/default) < 4.0) -BuildRequires: (crate(clap/cargo) >= 3.1.2 with crate(clap/cargo) < 4.0) -BuildRequires: (crate(serde_yaml/default) >= 0.8 with crate(serde_yaml/default) < 0.9) -BuildRequires: (crate(env_logger/default) >= 0.9 with crate(env_logger/default) < 0.10) -BuildRequires: (crate(log/default) >= 0.4 with crate(log/default) < 0.5) %description Unified interface for Linux network state querying. @@ -132,7 +133,4 @@ patchelf --set-soname libnispor.so.1 \ %ghost %{cargo_registry}/%{name}-%{version_no_tilde}/Cargo.toml %changelog -* Fri Jul 22 2022 Fedora Release Engineering - 1.2.7-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild - %autochangelog diff --git a/sources b/sources index 739cae0..8540b21 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (nispor-1.2.7.tar.gz) = 397a946c09802d736eb8cfdf177c759c46f64cedf9685161694eab638d939924fcb412b5de27690b76ced421b64dfdad9c623508ef2a3603ba8ac020fa463fb3 +SHA512 (nispor-1.2.8.tar.gz) = 221b76cfa6ebfa6a41e688005daec663d7775dd82714f62e0d1b04f398825268b09b4167effadddaeecada1f929a32016895031c2908515d22e2e68370b64cfe diff --git a/use-clap-3.patch b/use-clap-3.patch new file mode 100644 index 0000000..5654166 --- /dev/null +++ b/use-clap-3.patch @@ -0,0 +1,209 @@ +From e6ba58fa345d6e88ebc15687814facc883d4fdc8 Mon Sep 17 00:00:00 2001 +From: Gris Ge +Date: Mon, 17 Oct 2022 19:46:15 +0800 +Subject: [PATCH] Revert "cli: Upgrade to clap 4.0" + +This reverts commit c46050b7ff2fd4080eed3451f0793b231dfa7a3f. + +Signed-off-by: Gris Ge +--- + src/cli/Cargo.toml | 2 +- + src/cli/npc.rs | 49 +++++++++++++++++++++++----------------------- + 2 files changed, 26 insertions(+), 25 deletions(-) + +diff --git a/src/cli/Cargo.toml b/src/cli/Cargo.toml +index b727330..8f2b85e 100644 +--- a/src/cli/Cargo.toml ++++ b/src/cli/Cargo.toml +@@ -18,7 +18,7 @@ path = "npc.rs" + [dependencies] + serde_json = "1.0" + serde = { version = "1.0.136", features = ["derive"] } +-clap = { version = "4.0", features = ["cargo"] } ++clap = { version = "3.1.2", features = ["cargo"] } + nispor = { path = "../lib", version="1.2.8" } + serde_yaml = "0.9" + env_logger = "0.9.0" +diff --git a/src/cli/npc.rs b/src/cli/npc.rs +index 9272130..bdfc369 100644 +--- a/src/cli/npc.rs ++++ b/src/cli/npc.rs +@@ -316,7 +316,7 @@ fn print_result( + } + + fn parse_arg_output_format(matches: &clap::ArgMatches) -> CliOutputType { +- match matches.contains_id("json") { ++ match matches.is_present("json") { + true => CliOutputType::Json, + false => CliOutputType::Yaml, + } +@@ -347,13 +347,13 @@ fn main() { + .arg( + clap::Arg::new("verbose") + .short('v') +- .action(clap::ArgAction::Count) ++ .multiple_occurrences(true) + .help("Set verbose level"), + ) + .arg( + clap::Arg::new("json") + .short('j') +- .action(clap::ArgAction::Append) ++ .takes_value(false) + .global(true) + .help("Show in json format"), + ) +@@ -384,7 +384,7 @@ fn main() { + clap::Arg::new("dev") + .short('d') + .long("dev") +- .action(clap::ArgAction::Append) ++ .takes_value(true) + .help( + "Show only route entries output to \ + the specified interface", +@@ -394,7 +394,7 @@ fn main() { + clap::Arg::new("table") + .short('t') + .long("table") +- .action(clap::ArgAction::Append) ++ .takes_value(true) + .help( + "Show only route entries output in \ + the specified route table", +@@ -404,9 +404,9 @@ fn main() { + clap::Arg::new("scope") + .short('s') + .long("scope") +- .action(clap::ArgAction::Append) ++ .takes_value(true) + .help("Show only route entries with specified scope") +- .value_parser([ ++ .possible_values([ + "a", "all", "u", "universe", "g", "global", "s", + "site", "l", "link", "h", "host", "n", "nowhere", + "no_where", +@@ -416,9 +416,9 @@ fn main() { + clap::Arg::new("protocol") + .short('p') + .long("protocol") +- .action(clap::ArgAction::Append) ++ .takes_value(true) + .help("Show only route with specified protocol") +- .value_parser([ ++ .possible_values([ + "icmp_redirect", + "kernel", + "boot", +@@ -457,7 +457,8 @@ fn main() { + ) + .get_matches(); + +- let (log_module_filter, log_level) = match matches.get_count("verbose") { ++ let (log_module_filter, log_level) = match matches.occurrences_of("verbose") ++ { + 0 => (Some("nispor"), log::LevelFilter::Warn), + 1 => (Some("nispor"), log::LevelFilter::Info), + 2 => (Some("nispor"), log::LevelFilter::Debug), +@@ -471,7 +472,7 @@ fn main() { + let mut output_format = parse_arg_output_format(&matches); + + if let Some(m) = matches.subcommand_matches("set") { +- if let Some(file_path) = m.get_one::("file_path") { ++ if let Some(file_path) = m.value_of("file_path") { + print_result(apply_conf(file_path), output_format); + process::exit(0); + } else { +@@ -591,7 +592,7 @@ fn get_link_info(iface: &Iface) -> String { + } + + fn get_ifaces(matches: &clap::ArgMatches) -> Result { +- if let Some(iface_name) = matches.get_one::("iface_name") { ++ if let Some(iface_name) = matches.value_of("iface_name") { + let mut filter = NetStateFilter::minimum(); + let mut iface_filter = NetStateIfaceFilter::default(); + // In order to get controller/port relation ship, +@@ -606,7 +607,7 @@ fn get_ifaces(matches: &clap::ArgMatches) -> Result { + let state = NetState::retrieve_with_filter(&filter)?; + + if let Some(iface) = state.ifaces.get(iface_name) { +- if matches.contains_id("delete") { ++ if matches.is_present("delete") { + delete_iface(&iface.name) + } else { + Ok(CliReply::Ifaces(vec![iface.clone()])) +@@ -614,7 +615,7 @@ fn get_ifaces(matches: &clap::ArgMatches) -> Result { + } else { + Err(format!("Interface '{}' not found", iface_name).into()) + } +- } else if matches.contains_id("delete") { ++ } else if matches.is_present("delete") { + Err("Need to specific a interface to delete".to_string().into()) + } else { + let state = NetState::retrieve()?; +@@ -625,9 +626,9 @@ fn get_ifaces(matches: &clap::ArgMatches) -> Result { + fn get_routes(matches: &clap::ArgMatches) -> Result { + let mut route_filter = NetStateRouteFilter::default(); + +- if let Some(scope) = matches.get_one::("scope") { ++ if let Some(scope) = matches.value_of("scope") { + if scope != "a" && scope != "all" { +- let rt_scope = RouteScope::from(scope.as_str()); ++ let rt_scope = RouteScope::from(scope); + if rt_scope == RouteScope::Unknown { + return Err(format!("Invalid scope {}", scope).into()); + } +@@ -635,16 +636,16 @@ fn get_routes(matches: &clap::ArgMatches) -> Result { + } + } + +- if let Some(protocol) = matches.get_one::("protocol") { +- let rt_protocol = RouteProtocol::from(protocol.as_str()); ++ if let Some(protocol) = matches.value_of("protocol") { ++ let rt_protocol = RouteProtocol::from(protocol); + if rt_protocol == RouteProtocol::Unknown { + return Err(format!("Invalid protocol {}", protocol).into()); + } + route_filter.protocol = Some(rt_protocol); + } + +- if let Some(table) = matches.get_one::("table") { +- route_filter.table = Some(match table.as_str() { ++ if let Some(table) = matches.value_of("table") { ++ route_filter.table = Some(match table { + "main" => RT_TABLE_MAIN, + "local" => RT_TABLE_LOCAL, + _ => table.parse::().map_err(|e| CliError { +@@ -653,7 +654,7 @@ fn get_routes(matches: &clap::ArgMatches) -> Result { + }); + } + +- if let Some(iface_name) = matches.get_one::("dev") { ++ if let Some(iface_name) = matches.value_of("dev") { + route_filter.oif = Some(iface_name.to_string()); + } + +@@ -690,17 +691,17 @@ fn get_brief(matches: &clap::ArgMatches) -> Result { + filter.iface = Some(iface_filter); + let mut route_filter = NetStateRouteFilter::default(); + route_filter.table = Some(RT_TABLE_MAIN); +- if let Some(iface_name) = matches.get_one::("iface_name") { ++ if let Some(iface_name) = matches.value_of("iface_name") { + route_filter.oif = Some(iface_name.to_string()); + } + filter.route = Some(route_filter); + filter.route_rule = None; + let state = NetState::retrieve_with_filter(&filter)?; + +- if let Some(iface_name) = matches.get_one::("iface_name") { ++ if let Some(iface_name) = matches.value_of("iface_name") { + if state.ifaces.get(iface_name).is_some() { + for iface_brief in CliIfaceBrief::from_net_state(&state) { +- if &iface_brief.name == iface_name { ++ if iface_brief.name == iface_name { + return Ok(CliReply::Brief(vec![iface_brief])); + } + } +-- +2.38.0 +