time: Update to 1.9

This commit is contained in:
Alexey Pavlov
2018-07-27 11:19:57 +03:00
parent 02b52dbc1f
commit 26b244b5ec
5 changed files with 94 additions and 190 deletions

View File

@@ -1,8 +1,8 @@
# Maintainer: Alexey Pavlov <Alexpux@gmail.com>
pkgname=time
pkgver=1.7
pkgrel=2
pkgver=1.9
pkgrel=1
pkgdesc="Utility for monitoring a program's use of system resources"
depends=('msys2-runtime')
makedepends=('gcc')
@@ -12,32 +12,18 @@ license=('GPL')
arch=('i686' 'x86_64')
intall=time.install
source=(https://ftp.gnu.org/pub/gnu/${pkgname}/${pkgname}-${pkgver}.tar.gz
time-1.7-Recompute-CPU-usage-at-microsecond-level.patch
time-1.7-ru_maxrss-is-in-kilobytes-on-Linux.patch
time-1.7-cygwin.patch)
sha256sums=('e37ea79a253bf85a85ada2f7c632c14e481a5fd262a362f6f4fd58e68601496d'
'360b5ff9c413cdc14a35d15934eaf07b67d181becdfe3717afe528386c75c7b6'
'5a4efc406962df9790ff7a2f88b03a846b25e17d3c95bd3c5ef534c4bb70cfa2'
'799600e27fb0b9c029d88d3c416602146b74bd784f0379c12373b2a6f8c06393')
time-1.9-msysize.patch)
sha256sums=('fbacf0c81e62429df3e33bda4cee38756604f18e01d977338e23306a3e3b521e'
'1b33fa8b18f9768af2ab830e804e5ecd30b902572525db52af191ff82ebd47bc')
prepare() {
cd "$pkgname-$pkgver"
# cf https://bugzilla.redhat.com/show_bug.cgi?id=527276
patch -Np1 < "$srcdir"/time-1.7-Recompute-CPU-usage-at-microsecond-level.patch
# cf https://bugzilla.redhat.com/show_bug.cgi?id=702826
patch -Np1 < "$srcdir"/time-1.7-ru_maxrss-is-in-kilobytes-on-Linux.patch
patch -Np1 < "$srcdir"/time-1.7-cygwin.patch
# rebuild the ancient autoconf setup to fix a variety of build issues
# surrounding missing/incorrect includes.
cd "${pkgname}-${pkgver}"
patch -p1 -i ${srcdir}/time-1.9-msysize.patch
autoreconf -fisv
}
build() {
cd "$srcdir/$pkgname-$pkgver"
cd "${srcdir}/${pkgname}-${pkgver}"
./configure \
--prefix=/usr \
@@ -47,7 +33,7 @@ build() {
}
package() {
cd "$srcdir/$pkgname-$pkgver"
cd "${srcdir}/${pkgname}-${pkgver}"
make exec_prefix="$pkgdir/usr" infodir="$pkgdir/usr/share/info" install
make exec_prefix="${pkgdir}/usr" infodir="${pkgdir}/usr/share/info" install
}

View File

@@ -1,71 +0,0 @@
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
Subject: [PATCH] Recompute CPU usage at microsecond level
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)
{
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)
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;
+ if (r == 0 && v == 0)
+ {
+ ru = resp->elapsed.tv_usec;
+ vu = resp->ru.ru_utime.TV_USEC + resp->ru.ru_stime.TV_USEC;
+ }
+ else
+ {
+ ru = 0;
+ vu = 0;
+ }
+
while (*fmt)
{
switch (*fmt)
@@ -408,6 +421,8 @@ summarize (fp, fmt, command, resp)
/* % cpu is (total cpu time)/(elapsed time). */
if (r > 0)
fprintf (fp, "%lu%%", (v * 100 / r));
+ else if (ru > 0)
+ fprintf (fp, "%lu%%", (vu * 100 / ru));
else
fprintf (fp, "?%%");
break;
--
1.7.4.4

View File

@@ -1,64 +0,0 @@
diff -Naur time-1.7-orig/Makefile.in time-1.7-3/Makefile.in
--- time-1.7-orig/Makefile.in 1996-07-12 00:07:03.000000000 +0300
+++ time-1.7/Makefile.in 2013-10-16 21:03:31.000000000 +0300
@@ -7,22 +7,24 @@
SHELL = /bin/sh
+DESTDIR=
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
-bindir = @bindir@
-sbindir = @sbindir@
-libexecdir = @libexecdir@
-datadir = @datadir@
-sysconfdir = @sysconfdir@
-sharedstatedir = @sharedstatedir@
-localstatedir = @localstatedir@
-libdir = @libdir@
-infodir = @infodir@
-mandir = @mandir@
+EXEEXT = @EXEEXT@
+bindir = ${DESTDIR}@bindir@
+sbindir = ${DESTDIR}@sbindir@
+libexecdir = ${DESTDIR}@libexecdir@
+datadir = ${DESTDIR}@datadir@
+sysconfdir = ${DESTDIR}@sysconfdir@
+sharedstatedir = ${DESTDIR}@sharedstatedir@
+localstatedir = ${DESTDIR}@localstatedir@
+libdir = ${DESTDIR}@libdir@
+infodir = ${DESTDIR}@infodir@
+mandir = ${DESTDIR}@mandir@
includedir = @includedir@
oldincludedir = /usr/include
@@ -38,7 +40,7 @@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
transform = @program_transform_name@
-bin_PROGRAMS = time
+bin_PROGRAMS = time${EXEEXT}
info_TEXINFOS = time.texi
time_SOURCES = time.c getopt.c getopt1.c error.c resuse.c version.c \
getopt.h getpagesize.h resuse.h port.h wait.h
@@ -139,7 +141,7 @@
maintainer-clean-compile:
-time: $(time_OBJECTS) $(time_DEPENDENCIES)
+time${EXEEXT}: $(time_OBJECTS) $(time_DEPENDENCIES)
$(LINK) $(time_OBJECTS) $(time_LDADD) $(LIBS)
version.texi: stamp-vti
diff -Naur time-1.7-orig/time.mknetrel time-1.7-3/time.mknetrel
--- time-1.7-orig/time.mknetrel 1970-01-01 03:00:00.000000000 +0300
+++ time-1.7-3/time.mknetrel 2013-10-22 00:37:36.000000000 +0300
@@ -0,0 +1,4 @@
+preconfig() {
+ export ac_cv_func_wait3_rusage=yes
+ export useDESTDIR=1
+}

View File

@@ -1,31 +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

@@ -0,0 +1,84 @@
diff -Naur time-1.9-orig/build-aux/config.rpath time-1.9/build-aux/config.rpath
--- time-1.9-orig/build-aux/config.rpath 2018-01-04 03:03:52.000000000 +0300
+++ time-1.9/build-aux/config.rpath 2018-07-27 11:09:54.370470600 +0300
@@ -57,7 +57,7 @@
aix*)
wl='-Wl,'
;;
- mingw* | cygwin* | pw32* | os2* | cegcc*)
+ mingw* | cygwin* | msys* | pw32* | os2* | cegcc*)
;;
hpux9* | hpux10* | hpux11*)
wl='-Wl,'
@@ -149,7 +149,7 @@
hardcode_minus_L=no
case "$host_os" in
- cygwin* | mingw* | pw32* | cegcc*)
+ cygwin* | msys* | mingw* | pw32* | cegcc*)
# FIXME: the MSVC++ port hasn't been tested in a loooong time
# When not using gcc, we currently assume that we are using
# Microsoft Visual C++.
@@ -198,7 +198,7 @@
ld_shlibs=no
fi
;;
- cygwin* | mingw* | pw32* | cegcc*)
+ cygwin* | msys* | mingw* | pw32* | cegcc*)
# hardcode_libdir_flag_spec is actually meaningless, as there is
# no search path for DLLs.
hardcode_libdir_flag_spec='-L$libdir'
@@ -348,7 +348,7 @@
;;
bsdi[45]*)
;;
- cygwin* | mingw* | pw32* | cegcc*)
+ cygwin* | msys* | mingw* | pw32* | cegcc*)
# When not using gcc, we currently assume that we are using
# Microsoft Visual C++.
# hardcode_libdir_flag_spec is actually meaningless, as there is
@@ -533,7 +533,7 @@
bsdi[45]*)
library_names_spec='$libname$shrext'
;;
- cygwin* | mingw* | pw32* | cegcc*)
+ cygwin* | msys* | mingw* | pw32* | cegcc*)
shrext=.dll
library_names_spec='$libname.dll.a $libname.lib'
;;
diff -Naur time-1.9-orig/m4/double-slash-root.m4 time-1.9/m4/double-slash-root.m4
--- time-1.9-orig/m4/double-slash-root.m4 2018-01-04 03:03:53.000000000 +0300
+++ time-1.9/m4/double-slash-root.m4 2018-07-27 11:11:41.589458900 +0300
@@ -16,7 +16,7 @@
# special semantics and is distinct from /, please report it to
# <bug-gnulib@gnu.org>.
case $host in
- *-cygwin | i370-ibm-openedition)
+ *-cygwin | *-msys | i370-ibm-openedition)
gl_cv_double_slash_root=yes ;;
*)
# Be optimistic and assume that / and // are the same when we
diff -Naur time-1.9-orig/m4/malloc.m4 time-1.9/m4/malloc.m4
--- time-1.9-orig/m4/malloc.m4 2018-01-04 03:03:53.000000000 +0300
+++ time-1.9/m4/malloc.m4 2018-07-27 11:11:26.863033000 +0300
@@ -33,7 +33,7 @@
[case "$host_os" in
# Guess yes on platforms where we know the result.
*-gnu* | gnu* | freebsd* | netbsd* | openbsd* \
- | hpux* | solaris* | cygwin* | mingw*)
+ | hpux* | solaris* | cygwin* | msys* | mingw*)
ac_cv_func_malloc_0_nonnull=yes ;;
# If we don't know, assume the worst.
*) ac_cv_func_malloc_0_nonnull=no ;;
diff -Naur time-1.9-orig/m4/stdnoreturn.m4 time-1.9/m4/stdnoreturn.m4
--- time-1.9-orig/m4/stdnoreturn.m4 2018-01-04 03:03:53.000000000 +0300
+++ time-1.9/m4/stdnoreturn.m4 2018-07-27 11:11:52.868278700 +0300
@@ -11,7 +11,7 @@
[
AC_REQUIRE([AC_CANONICAL_HOST])
case "$host_os" in
- cygwin*)
+ cygwin* | msys*)
dnl Regardless whether a working <stdnoreturn.h> exists or not,
dnl we need our own <stdnoreturn.h>, because of the definition
dnl of _Noreturn done by gnulib-common.m4.