[Bug 273641] [new port] misc/gtime: GNU version of 'time' utility

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 15 Sep 2023 19:11:36 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=273641

--- Comment #4 from Ian Valentine <ivalentine@arizona.edu> ---
Comment on attachment 244860
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=244860
misc/gtime: Changes per request

>From 5353f3c8e0dd1533a5549f2d49fa324dac7965d2 Mon Sep 17 00:00:00 2001
>From: Ian Valentine <ivalentine@arizona.edu>
>Date: Fri, 15 Sep 2023 10:44:00 -0700
>Subject: [PATCH] misc/gtime: Add MAKEINFO, reformat Makefile
>
>---
> misc/gtime/Makefile                          | 51 ++++++++++++++++++++
> misc/gtime/distinfo                          |  3 ++
> misc/gtime/files/patch-tests_time-max-rss.sh | 38 +++++++++++++++
> misc/gtime/pkg-descr                         |  2 +
> 4 files changed, 94 insertions(+)
> create mode 100644 misc/gtime/Makefile
> create mode 100644 misc/gtime/distinfo
> create mode 100644 misc/gtime/files/patch-tests_time-max-rss.sh
> create mode 100644 misc/gtime/pkg-descr
>
>diff --git a/misc/gtime/Makefile b/misc/gtime/Makefile
>new file mode 100644
>index 0000000000..10d9038543
>--- /dev/null
>+++ b/misc/gtime/Makefile
>@@ -0,0 +1,51 @@
>+PORTNAME=	time
>+DISTVERSION=	1.9
>+CATEGORIES=	misc
>+MASTER_SITES=	GNU/time
>+PKGNAMEPREFIX=	g
>+
>+MAINTAINER=	ivalentine@arizona.edu
>+COMMENT=	GNU version of 'time' utility
>+WWW=		https://www.gnu.org/software/time/
>+
>+LICENSE=	GPLv3
>+LICENSE_FILE=	${WRKSRC}/COPYING
>+
>+BUILD_DEPENDS=	help2man:misc/help2man
>+
>+USES=		cpe gmake makeinfo
>+CPE_VENDOR=	gnu
>+
>+GNU_CONFIGURE=	yes
>+CONFIGURE_ARGS=	--program-prefix=g
>+CONFIGURE_ENV+=	MAKEINFO="${MAKEINFO} --no-split"
>+INSTALL_TARGET=	install-strip
>+TEST_TARGET=	check
>+
>+DATADIR=	${PREFIX}/share/${PKGBASE}
>+DOCSDIR=	${PREFIX}/share/doc/${PKGBASE}
>+INFO=		time
>+PLIST_FILES=	bin/gtime \
>+		man/man1/gtime.1.gz
>+PORTDOCS=	AUTHORS ChangeLog NEWS README
>+
>+OPTIONS_DEFINE=	DOCS
>+OPTIONS_SUB=	yes
>+
>+post-build:
>+	${MKDIR} ${WRKDIR}/man1
>+	help2man -Nn "run programs and summarize system resource usage" ${WRKSRC}/time -o ${WRKDIR}/man1/${PKGBASE}.1
>+
>+post-install:
>+	${INSTALL_MAN} ${WRKDIR}/man1/${PKGBASE}.1 ${STAGEDIR}${MAN1PREFIX}/man/man1/
>+
>+post-install-DOCS-on:
>+	@${MKDIR} ${STAGEDIR}${DOCSDIR}
>+	${INSTALL_DATA} ${PORTDOCS:S,^,${WRKSRC}/,} ${STAGEDIR}${DOCSDIR}
>+
>+pre-test:
>+.for f in help-version.sh time-exit-codes.sh time-max-rss.sh time-posix-quiet.sh
>+	@${REINPLACE_CMD} -e 's|env time|env ${WRKSRC}/time|g' ${WRKSRC}/tests/${f}
>+.endfor
>+
>+.include <bsd.port.mk>
>diff --git a/misc/gtime/distinfo b/misc/gtime/distinfo
>new file mode 100644
>index 0000000000..1fe0e48d5b
>--- /dev/null
>+++ b/misc/gtime/distinfo
>@@ -0,0 +1,3 @@
>+TIMESTAMP = 1694798374
>+SHA256 (time-1.9.tar.gz) = fbacf0c81e62429df3e33bda4cee38756604f18e01d977338e23306a3e3b521e
>+SIZE (time-1.9.tar.gz) = 596779
>diff --git a/misc/gtime/files/patch-tests_time-max-rss.sh b/misc/gtime/files/patch-tests_time-max-rss.sh
>new file mode 100644
>index 0000000000..7f5d8f9157
>--- /dev/null
>+++ b/misc/gtime/files/patch-tests_time-max-rss.sh
>@@ -0,0 +1,38 @@
>+--- tests/time-max-rss.sh.orig	2023-09-14 02:47:32 UTC
>++++ tests/time-max-rss.sh
>+@@ -32,13 +32,13 @@ time-aux || framework_failure_ "time-aux is missing/no
>+ env time -o mem-baseline -f "%M" time-aux \
>+   || framework_failure_ "failed to run time/time-aux (baseline max-rss)"
>+ 
>+-# Allocate 5MB of RAM
>+-env time -o mem-5MB -f "%M" time-aux -m 5M \
>+-  || framework_failure_ "failed to run time/time-aux (5M max-rss)"
>++# Allocate 400MB of RAM
>++env time -o mem-400MB -f "%M" time-aux -m 400M \
>++  || framework_failure_ "failed to run time/time-aux (400M max-rss)"
>+ 
>+ # Calculate the difference
>+ b=$(cat mem-baseline) || framework_failure_ "failed to read mem-baseline"
>+-c=$(cat mem-5MB) || framework_failure_ "failed to read mem-5MB"
>++c=$(cat mem-400MB) || framework_failure_ "failed to read mem-400MB"
>+ d=$(( c - b ))
>+ 
>+ # On some systems (e.g. OpenSolaris) getrusage(2) returns zero in ru_maxrss.
>+@@ -48,13 +48,13 @@ test "$b" -eq "0" && test "$c" -eq 0 \
>+ 
>+ # There could be alot of variation between each invocation,
>+ # accept a reasonable range
>+-if test "$d" -ge 5000 && test "$d" -le 6000 ; then
>+-    : # acceptable values: 5000-6000 KB
>++if test "$d" -ge 400000 && test "$d" -le 500000 ; then
>++    : # acceptable values: 400000-500000 KB
>+ else
>+     cat<<EOF>&2
>+-time(1) failed to detect 5MB allcoation.
>++time(1) failed to detect 400MB allcoation.
>+   mem-baseline(kb): $b
>+-  mem-5MB(kb):      $c
>++  mem-400MB(kb):      $c
>+   delta(kb):        $d
>+ EOF
>+     fail=1
>diff --git a/misc/gtime/pkg-descr b/misc/gtime/pkg-descr
>new file mode 100644
>index 0000000000..57ab9872c9
>--- /dev/null
>+++ b/misc/gtime/pkg-descr
>@@ -0,0 +1,2 @@
>+GNU time runs another program, then displays information about the
>+resources used by that program.
>-- 
>2.42.0
>
>

-- 
You are receiving this mail because:
You are the assignee for the bug.