diff --git a/openeuler-add-M-and-N-options-for-top.patch b/openeuler-add-M-and-N-options-for-top.patch new file mode 100644 index 0000000000000000000000000000000000000000..7856467ac6e6dc8a6ee43e5a829e2930bb24575b --- /dev/null +++ b/openeuler-add-M-and-N-options-for-top.patch @@ -0,0 +1,62 @@ +From 6e59f5e746c15df4d4b53f2df85b64aa1f10d0c3 Mon Sep 17 00:00:00 2001 +From: xuchunmei +Date: Fri, 11 Jan 2019 01:29:55 -0500 +Subject: [PATCH] procps-ng: add -M and -N options for top + +Signed-off-by: xuchunmei +Signed-off-by: zhoujie +Signed-off-by: Qiang Wei +--- + top/top.c | 15 ++++++++++++++- + top/top_nls.c | 2 ++ + 2 files changed, 16 insertions(+), 1 deletion(-) + +--- a/src/top/top.c ++++ b/src/top/top.c +@@ -4227,7 +4227,7 @@ default_or_error: + * overridden -- we'll force some on and negate others in our + * best effort to honor the loser's (oops, user's) wishes... */ + static void parse_args (int argc, char **argv) { +- static const char sopts[] = "bcd:E:e:Hhin:Oo:p:SsU:u:Vw::1"; ++ static const char sopts[] = "bcd:E:e:Hhin:Oo:p:SsU:u:Vw::1MN:"; + static const struct option lopts[] = { + { "batch-mode", no_argument, NULL, 'b' }, + { "cmdline-toggle", no_argument, NULL, 'c' }, +@@ -4248,6 +4248,8 @@ static void parse_args (int argc, char * + { "version", no_argument, NULL, 'V' }, + { "width", optional_argument, NULL, 'w' }, + { "single-cpu-toggle", no_argument, NULL, '1' }, ++ { "sort-by-mem", no_argument, NULL, 'M' }, ++ { "display-task-num", required_argument, NULL, 'N' }, + { NULL, 0, NULL, 0 } + }; + float tmp_delay = FLT_MAX; +@@ -4370,6 +4372,17 @@ static void parse_args (int argc, char * + error_exit(fmtmk(N_fmt(BAD_widtharg_fmt), cp)); + Width_mode = (int)tmp; + continue; ++ case 'M': ++ { ++ Curwin->rc.sortindx = EU_MEM; ++ break; ++ } ++ case 'N': ++ { ++ if (sscanf(cp, "%d", &Curwin->rc.maxtasks) != 1 || Curwin->rc.maxtasks < 0) ++ error_exit(fmtmk("bad iterations arg '%s'", cp)); ++ continue; ++ } + default: + // we'll rely on getopt for any error message ... + bye_bye(NULL); +--- a/src/top/top_nls.c ++++ b/src/top/top_nls.c +@@ -431,6 +431,8 @@ static void build_norm_nlstab (void) { + " -u, --filter-only-euser =USER show only processes owned by USER\n" + " -w, --width [=COLUMNS] change print width [,use COLUMNS]\n" + " -1, --single-cpu-toggle reverse last remembered '1' state\n" ++ " -M, --sort-by-mem show tasks by memory usage\n" ++ " -N, --show-task-num show the specified number of tasks\n" + "\n" + " -h, --help display this help text, then exit\n" + " -V, --version output version information & exit\n" diff --git a/openeuler-top-exit-with-error-when-pid-overflow.patch b/openeuler-top-exit-with-error-when-pid-overflow.patch new file mode 100644 index 0000000000000000000000000000000000000000..89bdb8914b51a8755eba420a05839f8dabd0c665 --- /dev/null +++ b/openeuler-top-exit-with-error-when-pid-overflow.patch @@ -0,0 +1,23 @@ +From 68bd42fb10cfaf278e841d2925da7f061820abd4 Mon Sep 17 00:00:00 2001 +From: xuchunmei +Date: Wed, 23 Jan 2019 07:57:53 -0500 +Subject: [PATCH] top: exit with error when pid overflow + +Signed-off-by: xuchunmei +Signed-off-by: Qiang Wei +--- + top/top.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/src/top/top.c ++++ b/src/top/top.c +@@ -4338,7 +4338,8 @@ static void parse_args (int argc, char * + if (Monpidsidx >= MONPIDMAX) + error_exit(fmtmk(N_fmt(LIMIT_exceed_fmt), MONPIDMAX)); + if (1 != sscanf(cp, "%d", &pid) +- || strpbrk(cp, "+-.")) ++ || strpbrk(cp, "+-.") ++ || 0 > pid) + error_exit(fmtmk(N_fmt(BAD_mon_pids_fmt), cp)); + if (!pid) pid = getpid(); + for (i = 0; i < Monpidsidx; i++) diff --git a/procps-ng-4.0.2.tar.xz b/procps-ng-4.0.2.tar.xz new file mode 100644 index 0000000000000000000000000000000000000000..8ebf3053e7530340f9da4bcbc543e70f7e4722a7 Binary files /dev/null and b/procps-ng-4.0.2.tar.xz differ diff --git a/procps-ng.spec b/procps-ng.spec index e15ba5258705efe75ddd470f798d032c86ba6977..7c6b47d95d666f18c9db031a15baeb8a5d875b28 100644 --- a/procps-ng.spec +++ b/procps-ng.spec @@ -1,6 +1,6 @@ Name: procps-ng -Version: 4.0.0 -Release: 4 +Version: 4.0.2 +Release: 1 Summary: Utilities that provide system information. License: GPL+ and GPLv2 and GPLv2+ and GPLv3+ and LGPLv2+ URL: https://sourceforge.net/projects/procps-ng/ @@ -9,12 +9,11 @@ Source0: http://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.xz Source1: README.md Source2: README.top -Patch1: 0001-add-M-and-N-options-for-top.patch -Patch2: 0002-top-exit-with-error-when-pid-overflow.patch -Patch3: 0003-top-eliminate-a-potential-abend-when-exiting-A-mode.patch -Patch4: 0004-skill-Restore-the-p-flag-functionality.patch +Patch1: openeuler-add-M-and-N-options-for-top.patch +Patch2: openeuler-top-exit-with-error-when-pid-overflow.patch +Patch3: skill-Restore-the-p-flag-functionality.patch -BuildRequires: ncurses-devel libtool autoconf automake gcc gettext-devel systemd-devel systemd-pam +BuildRequires: ncurses-devel libtool autoconf automake gcc gettext-devel systemd-devel Provides: procps = %{version}-%{release} Provides: %{name} @@ -47,7 +46,7 @@ The package is used for the Internationalization of %{name} %autosetup -n procps-ng-%{version} -p1 cp -p %{SOURCE1} . -cp -p %{SOURCE2} top/ +cp -p %{SOURCE2} src/top/ %build autoreconf -ivf @@ -73,10 +72,10 @@ ln -s %{_bindir}/pidof %{buildroot}%{_sbindir}/pidof %doc COPYING COPYING.LIB %{!?_licensedir:%global license %%doc} %license COPYING COPYING.LIB -%{_libdir}/libproc-2.so.* +%{_libdir}/libproc2.so.* %{_bindir}/* %{_sbindir}/* -%exclude %{_libdir}/libproc-2.la +%exclude %{_libdir}/libproc2.la %exclude /unwanted/* %exclude %{_libdir}/*.a @@ -84,17 +83,20 @@ ln -s %{_bindir}/pidof %{buildroot}%{_sbindir}/pidof %doc COPYING COPYING.LIB %{!?_licensedir:%global license %%doc} %license COPYING COPYING.LIB -%{_libdir}/libproc-2.so -%{_libdir}/pkgconfig/libproc-2.pc -%{_includedir}/procps +%{_libdir}/libproc2.so +%{_libdir}/pkgconfig/libproc2.pc +%{_includedir}/libproc2 %files i18n -f %{name}.lang %files help -%doc AUTHORS Documentation/bugs.md Documentation/FAQ NEWS README.md top/README.top Documentation/TODO +%doc AUTHORS NEWS README.md %{_mandir}/man* %changelog +* Wed Feb 1 2023 Qiang Wei - 4.0.2-1 +- Update to 4.0.2. + * Mon Dec 12 2022 Liu Chao - 4.0.0-4 - skill: Restore the -p flag functionality diff --git a/skill-Restore-the-p-flag-functionality.patch b/skill-Restore-the-p-flag-functionality.patch new file mode 100644 index 0000000000000000000000000000000000000000..55065d128a762a9b489aaf34a23f3c233680d7bb --- /dev/null +++ b/skill-Restore-the-p-flag-functionality.patch @@ -0,0 +1,85 @@ +From f7a33746f8484629df9055f9a2dc5654f377c2fe Mon Sep 17 00:00:00 2001 +From: Craig Small +Date: Mon, 12 Dec 2022 16:46:36 +1100 +Subject: [PATCH] skill: Restore the -p flag functionality + +When the skill program was ported to the new API the code to filter +on PID, used by the -p option, was missed. It is now restored. + +References: + https://bugs.debian.org/1025915 + +Signed-off-by: Qiang Wei +--- + NEWS | 4 ++++ + src/skill.c | 2 ++ + testsuite/skill.test/skill.exp | 32 ++++++++++++++++++++++++++++++++ + 3 files changed, 38 insertions(+) + create mode 100644 testsuite/skill.test/skill.exp + +diff --git a/NEWS b/NEWS +index d334c0d6..2d13978d 100644 +--- a/NEWS ++++ b/NEWS +@@ -1,3 +1,7 @@ ++procps-ng-NEXT ++--------------- ++ * docs: Don't install English manpages twice ++ * skill: Match on -p again Debian #1025915 + procps-ng-4.0.2 + --------------- + * library revision - 0:1:0 +diff --git a/src/skill.c b/src/skill.c +index 9f617bfd..c2e52744 100644 +--- a/src/skill.c ++++ b/src/skill.c +@@ -287,6 +287,8 @@ static void scan_procs(struct run_time_conf_t *run_time) + for (i=0; i < total_procs; i++) { + if (PIDS_GETINT(PID) == my_pid || PIDS_GETINT(PID) == 0) + continue; ++ if (pids && !match_intlist(PIDS_GETINT(PID), pid_count, pids)) ++ continue; + if (uids && !match_intlist(PIDS_GETUNT(EUID), uid_count, (int *)uids)) + continue; + if (ttys && !match_intlist(PIDS_GETINT(TTY), tty_count, ttys)) +diff --git a/testsuite/skill.test/skill.exp b/testsuite/skill.test/skill.exp +new file mode 100644 +index 00000000..162d9610 +--- /dev/null ++++ b/testsuite/skill.test/skill.exp +@@ -0,0 +1,32 @@ ++# ++# Dejagnu testsuite for skill - part of procps ++# ++set skill ${topdir}src/skill ++set tty [ get_tty ] ++ ++if { ![ file exists $skill ] } { ++ untested { skipping (not built)} ++ return ++} ++ ++set test "skill with no arguments" ++spawn $skill ++expect_pass "$test" "Usage:\\s+\(lt-\)?skill \\\[signal\\\] \\\[options\\\] " ++ ++set test "skill list signal names" ++spawn $skill -l ++expect_pass "$test" "^\(\[A-Z12+-\]\\s*\)+$" ++ ++set test "skill list signal names in table" ++spawn $skill -L ++expect_pass "$test" "^\(\\s+\\d+ \[A-Z12+-\]+\)+\\s*$" ++ ++make_testproc ++ ++# Debian 1025915 ++set test "skill find one process" ++spawn $skill -n -p $testproc1_pid ++expect_pass "$test" "^$testproc1_pid\\s*$" ++ ++# Cleanup ++kill_testproc +-- +2.33.0 +