diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b6827d0 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/procs-0.9.11.crate diff --git a/0001-Fix-test-failure-without-docker-41.patch b/0001-Fix-test-failure-without-docker-41.patch new file mode 100644 index 0000000..739b4da --- /dev/null +++ b/0001-Fix-test-failure-without-docker-41.patch @@ -0,0 +1,506 @@ +From c80c5ec34923b6df2487ef2d7de82800ee6feedf Mon Sep 17 00:00:00 2001 +From: dalance +Date: Tue, 18 Feb 2020 21:47:32 +0900 +Subject: [PATCH] Fix test failure without docker #41 + +--- + src/columns/empty.rs | 38 +++++++++++ + src/columns/os_linux.rs | 133 +++----------------------------------- + src/columns/os_macos.rs | 127 +++--------------------------------- + src/columns/os_windows.rs | 8 +++ + 4 files changed, 66 insertions(+), 240 deletions(-) + create mode 100644 src/columns/empty.rs + +diff --git a/src/columns/empty.rs b/src/columns/empty.rs +new file mode 100644 +index 0000000..d50a0b2 +--- /dev/null ++++ b/src/columns/empty.rs +@@ -0,0 +1,38 @@ ++use crate::process::ProcessInfo; ++use crate::{column_default, Column}; ++use std::cmp; ++use std::collections::HashMap; ++ ++pub struct Empty { ++ header: String, ++ unit: String, ++ fmt_contents: HashMap, ++ raw_contents: HashMap, ++ width: usize, ++} ++ ++impl Empty { ++ pub fn new() -> Self { ++ let header = String::from(""); ++ let unit = String::from(""); ++ Empty { ++ fmt_contents: HashMap::new(), ++ raw_contents: HashMap::new(), ++ width: 0, ++ header, ++ unit, ++ } ++ } ++} ++ ++impl Column for Empty { ++ fn add(&mut self, proc: &ProcessInfo) { ++ let raw_content = String::from(""); ++ let fmt_content = String::from(""); ++ ++ self.fmt_contents.insert(proc.pid, fmt_content); ++ self.raw_contents.insert(proc.pid, raw_content); ++ } ++ ++ column_default!(String); ++} +diff --git a/src/columns/os_linux.rs b/src/columns/os_linux.rs +index 3986a63..6804dee 100644 +--- a/src/columns/os_linux.rs ++++ b/src/columns/os_linux.rs +@@ -4,6 +4,7 @@ pub mod cpu_time; + #[cfg(feature = "docker")] + pub mod docker; + pub mod eip; ++pub mod empty; + pub mod esp; + pub mod gid; + pub mod gid_fs; +@@ -71,6 +72,7 @@ pub use self::cpu_time::CpuTime; + #[cfg(feature = "docker")] + pub use self::docker::Docker; + pub use self::eip::Eip; ++pub use self::empty::Empty; + pub use self::esp::Esp; + pub use self::gid::Gid; + pub use self::gid_fs::GidFs; +@@ -146,9 +148,9 @@ pub enum ConfigColumnKind { + Command, + ContextSw, + CpuTime, +- #[cfg(feature = "docker")] + Docker, + Eip, ++ Empty, + Esp, + Gid, + GidFs, +@@ -229,7 +231,10 @@ pub fn gen_column( + ConfigColumnKind::CpuTime => Box::new(CpuTime::new()), + #[cfg(feature = "docker")] + ConfigColumnKind::Docker => Box::new(Docker::new(_docker_path)), ++ #[cfg(not(feature = "docker"))] ++ ConfigColumnKind::Docker => Box::new(Empty::new()), + ConfigColumnKind::Eip => Box::new(Eip::new()), ++ ConfigColumnKind::Empty => Box::new(Empty::new()), + ConfigColumnKind::Esp => Box::new(Esp::new()), + ConfigColumnKind::Gid => Box::new(Gid::new(abbr_sid)), + ConfigColumnKind::GidFs => Box::new(GidFs::new()), +@@ -312,12 +317,12 @@ lazy_static! { + ConfigColumnKind::CpuTime, + ("CpuTime", "Cumulative CPU time") + ), +- #[cfg(feature = "docker")] + ( + ConfigColumnKind::Docker, + ("Docker", "Docker container name") + ), + (ConfigColumnKind::Eip, ("Eip", "Instruction pointer")), ++ (ConfigColumnKind::Empty, ("Empty", "Empty")), + (ConfigColumnKind::Esp, ("Esp", "Stack pointer")), + (ConfigColumnKind::Gid, ("Gid", "Group ID")), + (ConfigColumnKind::GidFs, ("GidFs", "File system group ID")), +@@ -453,7 +458,6 @@ lazy_static! { + // CONFIG_DEFAULT + // --------------------------------------------------------------------------------------------------------------------- + +-#[cfg(feature = "docker")] + pub static CONFIG_DEFAULT: &str = r#" + [[columns]] + kind = "Pid" +@@ -578,126 +582,6 @@ numeric_search = false + nonnumeric_search = true + "#; + +-#[cfg(not(feature = "docker"))] +-pub static CONFIG_DEFAULT: &str = r#" +-[[columns]] +-kind = "Pid" +-style = "BrightYellow" +-numeric_search = true +-nonnumeric_search = false +-[[columns]] +-kind = "User" +-style = "BrightGreen" +-numeric_search = false +-nonnumeric_search = true +-[[columns]] +-kind = "Separator" +-style = "White" +-numeric_search = false +-nonnumeric_search = false +-[[columns]] +-kind = "State" +-style = "ByState" +-numeric_search = false +-nonnumeric_search = false +-[[columns]] +-kind = "Nice" +-style = "BrightMagenta" +-numeric_search = false +-nonnumeric_search = false +-align = "Right" +-[[columns]] +-kind = "Tty" +-style = "BrightWhite" +-numeric_search = false +-nonnumeric_search = false +-[[columns]] +-kind = "UsageCpu" +-style = "ByPercentage" +-numeric_search = false +-nonnumeric_search = false +-align = "Right" +-[[columns]] +-kind = "UsageMem" +-style = "ByPercentage" +-numeric_search = false +-nonnumeric_search = false +-align = "Right" +-[[columns]] +-kind = "VmPeak" +-style = "ByUnit" +-numeric_search = false +-nonnumeric_search = false +-align = "Right" +-[[columns]] +-kind = "VmSize" +-style = "ByUnit" +-numeric_search = false +-nonnumeric_search = false +-align = "Right" +-[[columns]] +-kind = "VmRss" +-style = "ByUnit" +-numeric_search = false +-nonnumeric_search = false +-align = "Right" +-[[columns]] +-kind = "TcpPort" +-style = "BrightCyan" +-numeric_search = true +-nonnumeric_search = false +-max_width = 20 +-[[columns]] +-kind = "UdpPort" +-style = "BrightCyan" +-numeric_search = true +-nonnumeric_search = false +-max_width = 20 +-[[columns]] +-kind = "ReadBytes" +-style = "ByUnit" +-numeric_search = false +-nonnumeric_search = false +-align = "Right" +-[[columns]] +-kind = "WriteBytes" +-style = "ByUnit" +-numeric_search = false +-nonnumeric_search = false +-align = "Right" +-[[columns]] +-kind = "Slot" +-style = "ByUnit" +-numeric_search = false +-nonnumeric_search = false +-align = "Right" +-[[columns]] +-kind = "Separator" +-style = "White" +-numeric_search = false +-nonnumeric_search = false +-[[columns]] +-kind = "CpuTime" +-style = "BrightCyan" +-numeric_search = false +-nonnumeric_search = false +-[[columns]] +-kind = "StartTime" +-style = "BrightMagenta" +-numeric_search = false +-nonnumeric_search = false +-[[columns]] +-kind = "Separator" +-style = "White" +-numeric_search = false +-nonnumeric_search = false +-[[columns]] +-kind = "Command" +-style = "BrightWhite" +-numeric_search = false +-nonnumeric_search = true +-"#; +- + // --------------------------------------------------------------------------------------------------------------------- + // CONFIG_ALL + // --------------------------------------------------------------------------------------------------------------------- +@@ -723,6 +607,9 @@ style = "BrightMagenta" + kind = "Eip" + style = "BrightYellow" + [[columns]] ++kind = "Empty" ++style = "BrightYellow" ++[[columns]] + kind = "Esp" + style = "BrightBlue" + [[columns]] +diff --git a/src/columns/os_macos.rs b/src/columns/os_macos.rs +index 1302786..3906950 100644 +--- a/src/columns/os_macos.rs ++++ b/src/columns/os_macos.rs +@@ -3,6 +3,7 @@ pub mod context_sw; + pub mod cpu_time; + #[cfg(feature = "docker")] + pub mod docker; ++pub mod empty; + pub mod gid; + pub mod gid_real; + pub mod gid_saved; +@@ -43,6 +44,7 @@ pub use self::context_sw::ContextSw; + pub use self::cpu_time::CpuTime; + #[cfg(feature = "docker")] + pub use self::docker::Docker; ++pub use self::empty::Empty; + pub use self::gid::Gid; + pub use self::gid_real::GidReal; + pub use self::gid_saved::GidSaved; +@@ -92,8 +94,8 @@ pub enum ConfigColumnKind { + Command, + ContextSw, + CpuTime, +- #[cfg(feature = "docker")] + Docker, ++ Empty, + Gid, + GidReal, + GidSaved, +@@ -148,6 +150,9 @@ pub fn gen_column( + ConfigColumnKind::CpuTime => Box::new(CpuTime::new()), + #[cfg(feature = "docker")] + ConfigColumnKind::Docker => Box::new(Docker::new(_docker_path)), ++ #[cfg(not(feature = "docker"))] ++ ConfigColumnKind::Docker => Box::new(Empty::new()), ++ ConfigColumnKind::Empty => Box::new(Empty::new()), + ConfigColumnKind::Gid => Box::new(Gid::new(abbr_sid)), + ConfigColumnKind::GidReal => Box::new(GidReal::new()), + ConfigColumnKind::GidSaved => Box::new(GidSaved::new()), +@@ -204,11 +209,11 @@ lazy_static! { + ConfigColumnKind::CpuTime, + ("CpuTime", "Cumulative CPU time") + ), +- #[cfg(feature = "docker")] + ( + ConfigColumnKind::Docker, + ("Docker", "Docker container name") + ), ++ (ConfigColumnKind::Empty, ("Empty", "Empty")), + (ConfigColumnKind::Gid, ("Gid", "Group ID")), + (ConfigColumnKind::GidReal, ("GidReal", "Real group ID")), + (ConfigColumnKind::GidSaved, ("GidSaved", "Saved group ID")), +@@ -282,7 +287,6 @@ lazy_static! { + // CONFIG_DEFAULT + // --------------------------------------------------------------------------------------------------------------------- + +-#[cfg(feature = "docker")] + pub static CONFIG_DEFAULT: &str = r#" + [[columns]] + kind = "Pid" +@@ -401,120 +405,6 @@ numeric_search = false + nonnumeric_search = true + "#; + +-#[cfg(not(feature = "docker"))] +-pub static CONFIG_DEFAULT: &str = r#" +-[[columns]] +-kind = "Pid" +-style = "BrightYellow" +-numeric_search = true +-nonnumeric_search = false +-[[columns]] +-kind = "User" +-style = "BrightGreen" +-numeric_search = false +-nonnumeric_search = true +-[[columns]] +-kind = "Separator" +-style = "White" +-numeric_search = false +-nonnumeric_search = false +-[[columns]] +-kind = "State" +-style = "ByState" +-numeric_search = false +-nonnumeric_search = false +-[[columns]] +-kind = "Nice" +-style = "BrightMagenta" +-numeric_search = false +-nonnumeric_search = false +-align = "Right" +-[[columns]] +-kind = "Tty" +-style = "BrightWhite" +-numeric_search = false +-nonnumeric_search = false +-[[columns]] +-kind = "UsageCpu" +-style = "ByPercentage" +-numeric_search = false +-nonnumeric_search = false +-align = "Right" +-[[columns]] +-kind = "UsageMem" +-style = "ByPercentage" +-numeric_search = false +-nonnumeric_search = false +-align = "Right" +-[[columns]] +-kind = "VmSize" +-style = "ByUnit" +-numeric_search = false +-nonnumeric_search = false +-align = "Right" +-[[columns]] +-kind = "VmRss" +-style = "ByUnit" +-numeric_search = false +-nonnumeric_search = false +-align = "Right" +-[[columns]] +-kind = "TcpPort" +-style = "BrightCyan" +-numeric_search = true +-nonnumeric_search = false +-max_width = 20 +-[[columns]] +-kind = "UdpPort" +-style = "BrightCyan" +-numeric_search = true +-nonnumeric_search = false +-max_width = 20 +-[[columns]] +-kind = "ReadBytes" +-style = "ByUnit" +-numeric_search = false +-nonnumeric_search = false +-align = "Right" +-[[columns]] +-kind = "WriteBytes" +-style = "ByUnit" +-numeric_search = false +-nonnumeric_search = false +-align = "Right" +-[[columns]] +-kind = "Slot" +-style = "ByUnit" +-numeric_search = false +-nonnumeric_search = false +-align = "Right" +-[[columns]] +-kind = "Separator" +-style = "White" +-numeric_search = false +-nonnumeric_search = false +-[[columns]] +-kind = "CpuTime" +-style = "BrightCyan" +-numeric_search = false +-nonnumeric_search = false +-[[columns]] +-kind = "StartTime" +-style = "BrightMagenta" +-numeric_search = false +-nonnumeric_search = false +-[[columns]] +-kind = "Separator" +-style = "White" +-numeric_search = false +-nonnumeric_search = false +-[[columns]] +-kind = "Command" +-style = "BrightWhite" +-numeric_search = false +-nonnumeric_search = true +-"#; +- + // --------------------------------------------------------------------------------------------------------------------- + // CONFIG_ALL + // --------------------------------------------------------------------------------------------------------------------- +@@ -537,6 +427,9 @@ align = "Center" + kind = "Docker" + style = "BrightMagenta" + [[columns]] ++kind = "Empty" ++style = "BrightYellow" ++[[columns]] + kind = "Gid" + style = "White" + [[columns]] +diff --git a/src/columns/os_windows.rs b/src/columns/os_windows.rs +index 401d33e..357feaa 100644 +--- a/src/columns/os_windows.rs ++++ b/src/columns/os_windows.rs +@@ -1,5 +1,6 @@ + pub mod command; + pub mod cpu_time; ++pub mod empty; + pub mod gid; + pub mod group; + pub mod maj_flt; +@@ -26,6 +27,7 @@ pub mod write_bytes; + + pub use self::command::Command; + pub use self::cpu_time::CpuTime; ++pub use self::empty::Empty; + pub use self::gid::Gid; + pub use self::group::Group; + pub use self::maj_flt::MajFlt; +@@ -63,6 +65,7 @@ use std::collections::HashMap; + pub enum ConfigColumnKind { + Command, + CpuTime, ++ Empty, + Gid, + Group, + MajFlt, +@@ -102,6 +105,7 @@ pub fn gen_column( + match kind { + ConfigColumnKind::Command => Box::new(Command::new()), + ConfigColumnKind::CpuTime => Box::new(CpuTime::new()), ++ ConfigColumnKind::Empty => Box::new(Empty::new()), + ConfigColumnKind::Gid => Box::new(Gid::new(abbr_sid)), + ConfigColumnKind::Group => Box::new(Group::new(abbr_sid)), + ConfigColumnKind::MajFlt => Box::new(MajFlt::new()), +@@ -142,6 +146,7 @@ lazy_static! { + ConfigColumnKind::CpuTime, + ("CpuTime", "Cumulative CPU time") + ), ++ (ConfigColumnKind::Empty, ("Empty", "Empty")), + (ConfigColumnKind::Gid, ("Gid", "Group ID")), + (ConfigColumnKind::Group, ("Group", "Group name")), + ( +@@ -303,6 +308,9 @@ kind = "CpuTime" + style = "BrightGreen" + align = "Center" + [[columns]] ++kind = "Empty" ++style = "BrightYellow" ++[[columns]] + kind = "Gid" + style = "White" + [[columns]] +-- +2.25.0 + diff --git a/procs-fix-metadata.diff b/procs-fix-metadata.diff new file mode 100644 index 0000000..0978c44 --- /dev/null +++ b/procs-fix-metadata.diff @@ -0,0 +1,39 @@ +--- procs-0.9.11/Cargo.toml 2020-02-16T07:11:09+00:00 ++++ procs-0.9.11/Cargo.toml 2020-02-18T12:13:49.912410+00:00 +@@ -106,9 +106,6 @@ + [dependencies.unicode-width] + version = "0.1" + +-[features] +-default = ["docker"] +-docker = ["dockworker"] + [target."cfg(target_os = \"linux\")".dependencies.pager] + version = "0.15" + +@@ -123,26 +120,6 @@ + + [target."cfg(target_os = \"linux\")".dependencies.which] + version = "3" +-[target."cfg(target_os = \"macos\")".dependencies.errno] +-version = "0.2" +- +-[target."cfg(target_os = \"macos\")".dependencies.libproc] +-version = "0.5" +- +-[target."cfg(target_os = \"macos\")".dependencies.pager] +-version = "0.15" +- +-[target."cfg(target_os = \"macos\")".dependencies.process_path] +-version = "0.1" +- +-[target."cfg(target_os = \"macos\")".dependencies.users] +-version = "0.9" +- +-[target."cfg(target_os = \"macos\")".dependencies.which] +-version = "3" +-[target."cfg(target_os = \"windows\")".dependencies.winapi] +-version = "0.3" +-features = ["handleapi", "minwindef", "psapi", "securitybaseapi", "tlhelp32", "winbase", "winnt"] + [badges.codecov] + branch = "master" + repository = "dalance/procs" diff --git a/rust-procs.spec b/rust-procs.spec new file mode 100644 index 0000000..6c05203 --- /dev/null +++ b/rust-procs.spec @@ -0,0 +1,73 @@ +# Generated by rust2rpm 13 +%bcond_without check +%global __cargo_skip_build 0 + +%global crate procs + +Name: rust-%{crate} +Version: 0.9.11 +Release: 1%{?dist} +Summary: Modern replacement for ps + +# Upstream license specification: MIT +License: MIT +URL: https://crates.io/crates/procs +Source: %{crates_source} +# Initial patched metadata +# * No windows/macos +# * Remove docker feature +Patch0: procs-fix-metadata.diff +# https://github.com/dalance/procs/commit/c80c5ec34923b6df2487ef2d7de82800ee6feedf +Patch0001: 0001-Fix-test-failure-without-docker-41.patch + +ExclusiveArch: %{rust_arches} + +BuildRequires: rust-packaging + +%global _description %{expand: +Modern replacement for ps.} + +%description %{_description} + +%package -n %{crate} +Summary: %{summary} +# Install all deps (without check), grab their licenses and make it simple +# * ASL 2.0 +# * ASL 2.0 or MIT +# * MIT +# * MIT or ASL 2.0 +# * (MIT or ASL 2.0) and BSD +# * Unlicense or MIT +# * zlib +License: MIT and ASL 2.0 and BSD and zlib + +%description -n %{crate} %{_description} + +%files -n %{crate} +%license LICENSE +%doc README.md CHANGELOG.md +%{_bindir}/procs + +%prep +%autosetup -n %{crate}-%{version_no_tilde} -p1 +%cargo_prep + +%generate_buildrequires +%cargo_generate_buildrequires + +%build +%cargo_build + +%install +%cargo_install + +%if %{with check} +%check +# One test fails related to docker +# https://github.com/dalance/procs/issues/41#issuecomment-587438247 +%cargo_test -- -- --skip tests::test_run_all +%endif + +%changelog +* Tue Feb 18 13:11:48 CET 2020 Igor Raits - 0.9.11-1 +- Initial package diff --git a/sources b/sources new file mode 100644 index 0000000..8e4f635 --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (procs-0.9.11.crate) = 534cb42026ef4c4d94383626859dd9da914ef2a91ea066a775831737385bf646f8bb685f78ea888552b32b42e9f219688dfd12b7a24abd53b419a0af2d1c5a65