This commit is contained in:
Petr Písař 2017-11-08 17:43:00 +01:00
parent 8cdfc64ff5
commit 8cdaa02d87
10 changed files with 150 additions and 302 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
time-1.7.tar.gz
/time-1.8.tar.gz

View File

@ -1 +1 @@
e38d2b8b34b1ca259cf7b053caac32b3 time-1.7.tar.gz
SHA512 (time-1.8.tar.gz) = 6337021407af1774cb6cd0b98d18531af3e393095776e86d1c6b192e6eca98ee8bd820fb27fc7c6355300654cfad61bb1385fa2212670a09ba4d54bb921c8abb

View File

@ -1,133 +0,0 @@
From 73e60377a708ea6d9e45c981b9b131df4d93e511 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Wed, 30 Nov 2016 17:38:37 +0100
Subject: [PATCH 1/2] Modernize configure.in
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
After editting configure.in and running autoreconf with autoconf-2.69
and automake-1.15, make command failed because configure.in did not
hook Automake. This patch allows to regenerate the scripts with
contemporary autotools.
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
INSTALL | 4 ++--
configure.ac | 39 +++++++++++++++++++++++++++++++++++++++
configure.in | 42 ------------------------------------------
3 files changed, 41 insertions(+), 44 deletions(-)
create mode 100644 configure.ac
delete mode 100644 configure.in
diff --git a/INSTALL b/INSTALL
index a2c8722..0cbcb35 100644
--- a/INSTALL
+++ b/INSTALL
@@ -19,8 +19,8 @@ diffs or instructions to the address given in the `README' so they can
be considered for the next release. If at some point `config.cache'
contains results you don't want to keep, you may remove or edit it.
- The file `configure.in' is used to create `configure' by a program
-called `autoconf'. You only need `configure.in' if you want to change
+ The file `configure.ac' is used to create `configure' by a program
+called `autoconf'. You only need `configure.ac' if you want to change
it or regenerate `configure' using a newer version of `autoconf'.
The simplest way to compile this package is:
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..2380b76
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,39 @@
+dnl Process this file with autoconf to produce a configure script.
+AC_INIT([time], [1.7])
+AM_INIT_AUTOMAKE()
+
+AC_ARG_PROGRAM
+
+dnl Checks for programs.
+AC_PROG_CC
+AC_PROG_CPP
+AC_PROG_INSTALL
+
+dnl Checks for header files.
+AC_HEADER_STDC
+AC_HEADER_SYS_WAIT
+AC_CHECK_HEADERS(unistd.h string.h sys/rusage.h)
+
+dnl Checks for typedefs, structures, and compiler characteristics.
+AC_C_CONST
+AC_TYPE_PID_T
+AC_TYPE_SIZE_T
+AC_TYPE_SIGNAL
+
+AC_MSG_CHECKING(for struct timeval in sys/time.h)
+AC_EGREP_HEADER(tv_usec, sys/time.h, have_tv=yes, have_tv=no)
+AC_MSG_RESULT($have_tv)
+test $have_tv = yes && AC_DEFINE(HAVE_TIMEVAL)
+
+dnl Checks for library functions.
+AC_FUNC_VPRINTF
+AC_FUNC_WAIT3
+AC_CHECK_FUNCS(strerror)
+
+AC_MSG_CHECKING(for getpagesize)
+AC_TRY_LINK([#include <sys/param.h>],
+[getpagesize();], have_gp=yes, have_gp=no)
+AC_MSG_RESULT($have_gp)
+test $have_gp = yes && AC_DEFINE(HAVE_GETPAGESIZE)
+
+AC_OUTPUT(Makefile)
diff --git a/configure.in b/configure.in
deleted file mode 100644
index 1531bad..0000000
--- a/configure.in
+++ /dev/null
@@ -1,42 +0,0 @@
-dnl Process this file with autoconf to produce a configure script.
-AC_INIT(time.c)
-VERSION=1.7
-AC_SUBST(VERSION)
-PACKAGE=time
-AC_SUBST(PACKAGE)
-
-AC_ARG_PROGRAM
-
-dnl Checks for programs.
-AC_PROG_CC
-AC_PROG_CPP
-AC_PROG_INSTALL
-
-dnl Checks for header files.
-AC_HEADER_STDC
-AC_HEADER_SYS_WAIT
-AC_CHECK_HEADERS(unistd.h string.h sys/rusage.h)
-
-dnl Checks for typedefs, structures, and compiler characteristics.
-AC_C_CONST
-AC_TYPE_PID_T
-AC_TYPE_SIZE_T
-AC_TYPE_SIGNAL
-
-AC_MSG_CHECKING(for struct timeval in sys/time.h)
-AC_EGREP_HEADER(tv_usec, sys/time.h, have_tv=yes, have_tv=no)
-AC_MSG_RESULT($have_tv)
-test $have_tv = yes && AC_DEFINE(HAVE_TIMEVAL)
-
-dnl Checks for library functions.
-AC_FUNC_VPRINTF
-AC_FUNC_WAIT3
-AC_CHECK_FUNCS(strerror)
-
-AC_MSG_CHECKING(for getpagesize)
-AC_TRY_LINK([#include <sys/param.h>],
-[getpagesize();], have_gp=yes, have_gp=no)
-AC_MSG_RESULT($have_gp)
-test $have_gp = yes && AC_DEFINE(HAVE_GETPAGESIZE)
-
-AC_OUTPUT(Makefile)
--
2.7.4

View File

@ -1,37 +0,0 @@
--- time-1.7/Makefile.in.destdir 2007-02-27 12:13:10.000000000 +0100
+++ time-1.7/Makefile.in 2007-02-27 12:18:07.000000000 +0100
@@ -114,10 +114,10 @@
maintainer-clean-binPROGRAMS:
install-binPROGRAMS: $(bin_PROGRAMS)
- $(mkinstalldirs) $(bindir)
+ $(mkinstalldirs) $(DESTDIR)/$(bindir)
list="$(bin_PROGRAMS)"; for p in $$list; do \
if test -f $$p; then \
- $(INSTALL_PROGRAM) $$p $(bindir)/`echo $$p|sed '$(transform)'`; \
+ $(INSTALL_PROGRAM) $$p $(DESTDIR)/$(bindir)/`echo $$p|sed '$(transform)'`; \
else :; fi; \
done
@@ -176,10 +176,10 @@
TEXINPUTS=$(srcdir):$$TEXINPUTS $(TEXI2DVI) $<
install-info: $(INFO_DEPS)
- $(mkinstalldirs) $(infodir)
+ $(mkinstalldirs) $(DESTDIR)/$(infodir)
for file in $(INFO_DEPS); do \
for ifile in `cd $(srcdir) && echo $$file*`; do \
- $(INSTALL_DATA) $(srcdir)/$$ifile $(infodir)/$$ifile; \
+ $(INSTALL_DATA) $(srcdir)/$$ifile $(DESTDIR)/$(infodir)/$$ifile; \
done; \
done
@@ -279,7 +279,7 @@
install-strip:
$(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install
installdirs:
- $(mkinstalldirs) $(bindir) $(infodir)
+ $(mkinstalldirs) $(DESTDIR)/$(bindir) $(DESTDIR)/$(infodir)
mostlyclean-generic:

View File

@ -1,32 +0,0 @@
From ad24a929bdcc15abae14a64ea21b821bcd8cb030 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Wed, 11 May 2011 15:19:11 +0200
Subject: [PATCH] ru_maxrss is in kilobytes on Linux
Since 2.6.32 Linux returns ru_maxrss in kilobytes. Not in pages.
See http://lists.gnu.org/archive/html/bug-gnu-utils/2008-12/msg00047.html
for discussion.
---
time.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/time.c b/time.c
index d15fee4..43aec0b 100644
--- a/time.c
+++ b/time.c
@@ -395,7 +395,11 @@ summarize (fp, fmt, command, resp)
ptok ((UL) resp->ru.ru_ixrss) / MSEC_TO_TICKS (v));
break;
case 'M': /* Maximum resident set size. */
+#ifdef __linux__
+ fprintf (fp, "%ld", resp->ru.ru_maxrss);
+#else
fprintf (fp, "%lu", ptok ((UL) resp->ru.ru_maxrss));
+#endif
break;
case 'O': /* Outputs. */
fprintf (fp, "%ld", resp->ru.ru_oublock);
--
1.7.4.4

View File

@ -1,19 +0,0 @@
--- time-1.7/time.c.verbose Fri Jun 14 05:38:21 1996
+++ time-1.7/time.c Sun Nov 4 16:21:09 2001
@@ -327,6 +327,8 @@
unsigned long r; /* Elapsed real milliseconds. */
unsigned long v; /* Elapsed virtual (CPU) milliseconds. */
+ if (verbose)
+ {
if (WIFSTOPPED (resp->waitstatus))
fprintf (fp, "Command stopped by signal %d\n",
WSTOPSIG (resp->waitstatus));
@@ -336,6 +338,7 @@
else if (WIFEXITED (resp->waitstatus) && WEXITSTATUS (resp->waitstatus))
fprintf (fp, "Command exited with non-zero status %d\n",
WEXITSTATUS (resp->waitstatus));
+ }
/* Convert all times to milliseconds. Occasionally, one of these values
comes out as zero. Dividing by zero causes problems, so we first

View File

@ -0,0 +1,41 @@
From ca7e5b4eed72b74b0e5c0001adc3b7348d247342 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Wed, 8 Nov 2017 17:34:03 +0100
Subject: [PATCH] Do not report command failure in POSIX mode
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
POSIX allows only an empty line before the time usage report. time-1.8
violates it:
$ ./time-1.8/time -p /usr/bin/false
Command exited with non-zero status 1
real 0.00
user 0.00
sys 0.00
This patch disables reporting the command failure if -p option is
specified.
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
src/time.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/time.c b/src/time.c
index cba2c32..c6d557d 100644
--- a/src/time.c
+++ b/src/time.c
@@ -431,7 +431,7 @@ summarize (fp, fmt, command, resp)
unsigned long ru; /* Elapsed real microseconds. */
unsigned long vu; /* Elapsed virtual (CPU) microseconds. */
- if (!quiet)
+ if (!quiet && output_format != posix_format)
{
if (WIFSTOPPED (resp->waitstatus))
fprintf (fp, "Command stopped by signal %d\n",
--
2.13.6

View File

@ -1,7 +1,7 @@
From 0d9b55f773b13dc1d44651163888b6a5037a2c7d Mon Sep 17 00:00:00 2001
From a3c400a8553b598bc2fd01eb0f63c5748b2147e1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Wed, 30 Nov 2016 17:13:16 +0100
Subject: [PATCH 2/2] Prefer clock_gettime(CLOCK_MONOTONIC)
Date: Wed, 8 Nov 2017 17:02:42 +0100
Subject: [PATCH] Prefer clock_gettime(CLOCK_MONOTONIC)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
@ -17,30 +17,31 @@ that does not suffer from the issue.
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
configure.ac | 2 ++
resuse.c | 27 +++++++++++++++++++++++++--
2 files changed, 27 insertions(+), 2 deletions(-)
configure.ac | 3 +++
src/resuse.c | 27 +++++++++++++++++++++++++--
2 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac
index 2380b76..558d112 100644
index ede8fd5..d2950bd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -29,6 +29,8 @@ dnl Checks for library functions.
@@ -72,6 +72,9 @@ dnl Checks for library functions.
AC_FUNC_VPRINTF
AC_FUNC_WAIT3
AC_CHECK_FUNCS(strerror)
+AC_SEARCH_LIBS(clock_gettime, [rt])
+test "$ac_cv_search_clock_gettime" != "no" && AC_DEFINE(HAVE_CLOCK_GETTIME)
+test "$ac_cv_search_clock_gettime" != "no" && \
+ AC_DEFINE([HAVE_CLOCK_GETTIME], [1], [System provides clock_gettime() call])
AC_MSG_CHECKING(for getpagesize)
AC_TRY_LINK([#include <sys/param.h>],
diff --git a/resuse.c b/resuse.c
index 4133941..da0da64 100644
--- a/resuse.c
+++ b/resuse.c
@@ -23,7 +23,14 @@
#include "wait.h"
#include "port.h"
# What memory units are reported by getrusage(2) ?
diff --git a/src/resuse.c b/src/resuse.c
index d2ab870..ec54863 100644
--- a/src/resuse.c
+++ b/src/resuse.c
@@ -26,7 +26,14 @@
#include <sys/wait.h>
#include <sys/resource.h>
-#if !HAVE_WAIT3
+#if HAVE_WAIT3
@ -54,7 +55,7 @@ index 4133941..da0da64 100644
# include <sys/times.h>
# ifndef HZ
# include <sys/param.h>
@@ -48,7 +55,14 @@ resuse_start (resp)
@@ -51,7 +58,14 @@ resuse_start (resp)
RESUSE *resp;
{
#if HAVE_WAIT3
@ -69,7 +70,7 @@ index 4133941..da0da64 100644
#else
long value;
struct tms tms;
@@ -56,7 +70,7 @@ resuse_start (resp)
@@ -59,7 +73,7 @@ resuse_start (resp)
value = times (&tms);
resp->start.tv_sec = value / HZ;
resp->start.tv_usec = value % HZ * (1000000 / HZ);
@ -78,7 +79,7 @@ index 4133941..da0da64 100644
}
/* Wait for and fill in data on child process PID.
@@ -76,6 +90,9 @@ resuse_end (pid, resp)
@@ -79,6 +93,9 @@ resuse_end (pid, resp)
int status;
#if HAVE_WAIT3
@ -88,7 +89,7 @@ index 4133941..da0da64 100644
pid_t caught;
/* Ignore signals, but don't ignore the children. When wait3
@@ -86,7 +103,13 @@ resuse_end (pid, resp)
@@ -89,7 +106,13 @@ resuse_end (pid, resp)
return 0;
}
@ -103,5 +104,5 @@ index 4133941..da0da64 100644
long value;
struct tms tms;
--
2.7.4
2.13.6

View File

@ -1,46 +1,49 @@
From 0d743a7d946fe176a07baf2586a6af0e867fd89c Mon Sep 17 00:00:00 2001
From: H.J. Lu <hongjiu.lu@intel.com>
Date: Wed, 11 May 2011 16:19:55 +0200
From 0962ebfcb9d30d0898ee4c108e71a1b6bca0785e Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hongjiu.lu@intel.com>
Date: Wed, 8 Nov 2017 16:50:21 +0100
Subject: [PATCH] Recompute CPU usage at microsecond level
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
If job finishes quickly, miliseconds arithmetic rounds to zero. If
that happens, recalculate CPU usage ratio with microsecond accuracy
to raise chance to get non-zero values.
---
resuse.h | 2 ++
time.c | 15 +++++++++++++++
2 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/resuse.h b/resuse.h
index 992143f..7a3ee66 100644
--- a/resuse.h
+++ b/resuse.h
@@ -33,9 +33,11 @@ struct timeval
#if HAVE_SYS_RUSAGE_H
/* This rusage structure measures nanoseconds instead of microseconds. */
# define TV_MSEC tv_nsec / 1000000
+# define TV_USEC tv_nsec / 1000
# include <sys/rusage.h>
#else
# define TV_MSEC tv_usec / 1000
+# define TV_USEC tv_usec
# if HAVE_WAIT3
# include <sys/resource.h>
# else
diff --git a/time.c b/time.c
index 43aec0b..96cfdde 100644
--- a/time.c
+++ b/time.c
@@ -326,6 +326,8 @@ summarize (fp, fmt, command, resp)
Petr Pisar: Ported to 1.8.
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
src/resuse.h | 1 +
src/time.c | 15 +++++++++++++++
2 files changed, 16 insertions(+)
diff --git a/src/resuse.h b/src/resuse.h
index a5edfaa..b21e2ad 100644
--- a/src/resuse.h
+++ b/src/resuse.h
@@ -23,6 +23,7 @@
/* Convert rusage's microseconds to miliseconds */
#define TV_MSEC tv_usec / 1000
+#define TV_USEC tv_usec
diff --git a/src/time.c b/src/time.c
index a6d99fb..cba2c32 100644
--- a/src/time.c
+++ b/src/time.c
@@ -428,6 +428,8 @@ summarize (fp, fmt, command, resp)
{
unsigned long r; /* Elapsed real milliseconds. */
unsigned long v; /* Elapsed virtual (CPU) milliseconds. */
+ unsigned long ru; /* Elapsed real microseconds. */
+ unsigned long vu; /* Elapsed virtual (CPU) microseconds. */
if (verbose)
{
@@ -350,6 +352,17 @@ summarize (fp, fmt, command, resp)
if (!quiet)
{
@@ -452,6 +454,17 @@ summarize (fp, fmt, command, resp)
v = resp->ru.ru_utime.tv_sec * 1000 + resp->ru.ru_utime.TV_MSEC +
resp->ru.ru_stime.tv_sec * 1000 + resp->ru.ru_stime.TV_MSEC;
@ -58,7 +61,7 @@ index 43aec0b..96cfdde 100644
while (*fmt)
{
switch (*fmt)
@@ -408,6 +421,8 @@ summarize (fp, fmt, command, resp)
@@ -509,6 +522,8 @@ summarize (fp, fmt, command, resp)
/* % cpu is (total cpu time)/(elapsed time). */
if (r > 0)
fprintf (fp, "%lu%%", (v * 100 / r));
@ -68,5 +71,5 @@ index 43aec0b..96cfdde 100644
fprintf (fp, "?%%");
break;
--
1.7.4.4
2.13.6

View File

@ -1,23 +1,42 @@
Summary: A GNU utility for monitoring a program's use of system resources
Name: time
Version: 1.7
Release: 54%{?dist}
License: GPLv2+
Group: Applications/System
Url: http://www.gnu.org/software/time/
Source: ftp://prep.ai.mit.edu/pub/gnu/%{name}/%{name}-%{version}.tar.gz
Patch0: time-1.7-destdir.patch
Patch1: time-1.7-verbose.patch
# Bug #702826
Patch2: time-1.7-ru_maxrss-is-in-kilobytes-on-Linux.patch
Summary: A GNU utility for monitoring a program's use of system resources
Name: time
Version: 1.8
Release: 1%{?dist}
# src/time.c: GPLv3+
# COPYING: GPLv3 text
# doc/time.texi: GFDL
# doc/fdl.texi: GFDL 1.3 text
# doc/time.info: GFDL
# lib/strerror-override.c: GPLv3+
# lib/error.h: GPLv3+
## Not in a binary package
# tests/init.sh: GPLv3+
# INSTALL: FSFAP
# build-aux/config.guess: GPLv3+ with exceptions
# build-aux/install-sh: MIT and Public Domain
# build-aux/config.rpath: FSFULLR
# build-aux/test-driver: GPLv2+ with exceptions
# build-aux/missing: GPLv2+ with exceptions
# build-aux/compile: GPLv2+ with exceptions
# build-aux/config.sub: GPLv3+ with exceptions
# build-aux/gitlog-to-changelog: GPLv3+
# build-aux/git-version-gen: GPLv3+
# build-aux/texinfo.tex: GPLv3+ with exceptions
# build-aux/depcomp: GPLv2+ with exceptions
# build-aux/mdate-sh: GPLv2+ with exceptions
# m4/ssize_t.m4: FSFULLR
# m4/longlong.m4: FSFULLR
# m4/gnulib-cache.m4: GPLv3+ with exceptions
License: GPLv3+ and GFDL
Url: http://www.gnu.org/software/%{name}/
Source: ftp://prep.ai.mit.edu/pub/gnu/%{name}/%{name}-%{version}.tar.gz
# Bug #527276
Patch3: time-1.7-Recompute-CPU-usage-at-microsecond-level.patch
# 1/2 Fix measuring time when a clock experiences a jump, bug #1004416,
Patch0: time-1.8-Recompute-CPU-usage-at-microsecond-level.patch
# Fix measuring time when a clock experiences a jump, bug #1004416,
# <http://lists.gnu.org/archive/html/bug-gnu-utils/2013-09/msg00003.html>
Patch4: time-1.7-Modernize-configure.in.patch
# 2/2 Fix measuring time when a clock experiences a jump, bug #1004416,
# <http://lists.gnu.org/archive/html/bug-gnu-utils/2013-09/msg00003.html>
Patch5: time-1.7-Prefer-clock_gettime-CLOCK_MONOTONIC.patch
Patch1: time-1.8-Prefer-clock_gettime-CLOCK_MONOTONIC.patch
# Do not print command failure in POSIX mode
Patch2: time-1.8-Do-not-report-command-failure-in-POSIX-mode.patch
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: bash
@ -37,22 +56,21 @@ the results.
%setup -q
%patch0 -p1
%patch1 -p1
%patch2 -p1 -b .ru_maxrss
%patch3 -p1 -b .recompute_cpu
%patch4 -p1
%patch5 -p1
%patch2 -p1
autoreconf -fi
%build
echo "ac_cv_func_wait3=\${ac_cv_func_wait3='yes'}" >> config.cache
%configure
make %{?_smp_mflags}
%make_build
%install
make install DESTDIR=$RPM_BUILD_ROOT
# Remove info index, we update it in %%post script
rm -f $RPM_BUILD_ROOT%{_infodir}/dir
%check
make %{?_smp_mflags} check
%post
/sbin/install-info %{_infodir}/time.info.gz %{_infodir}/dir \
--entry="* time: (time). GNU time Utility" >/dev/null 2>&1 || :
@ -70,6 +88,11 @@ fi
%{_infodir}/time.info*
%changelog
* Wed Nov 08 2017 Petr Pisar <ppisar@redhat.com> - 1.8-1
- 1.8 bump
- License changed from GPLv2+ to (GPLv3+ and GFDL)
- Disable printing command failure in POSIX mode
* Thu Aug 03 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.7-54
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild