Bug 273641 - [new port] misc/gtime: GNU version of 'time' utility
Summary: [new port] misc/gtime: GNU version of 'time' utility
Status: Open
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-ports-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-09-08 20:22 UTC by Ian Valentine
Modified: 2023-09-22 07:11 UTC (History)
2 users (show)

See Also:


Attachments
0001-misc-gtime-GNU-version-of-time-utility.patch (2.71 KB, text/plain)
2023-09-08 20:22 UTC, Ian Valentine
no flags Details
misc/gtime: Changes per request (4.16 KB, text/plain)
2023-09-15 00:43 UTC, Ian Valentine
no flags Details
13-2-amd64 poudriere log (67.08 KB, text/plain)
2023-09-15 19:46 UTC, Ian Valentine
no flags Details
misc/gtime: diff with all requested changes (4.39 KB, patch)
2023-09-15 19:50 UTC, Ian Valentine
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ian Valentine 2023-09-08 20:22:46 UTC
Created attachment 244715 [details]
0001-misc-gtime-GNU-version-of-time-utility.patch

GNU time runs another program, then displays information about the resources used by that program.
Comment 1 Daniel Engberg freebsd_committer freebsd_triage 2023-09-08 21:00:17 UTC
Hi,

PKGNAMEPREFIX, see https://cgit.freebsd.org/ports/tree/textproc/gsed/Makefile
This will also remove the need of DISTNAME

Remove version check in TEST_DEPENDS, no need to test for something that's been true for 15+ years.

INFO entry missing (see above)

Don't use variables in PLIST_FILES

TEST_USES= localbase don't work?

You're probably looking for MANDIR instead of MAN1PREFIX in the post-install section

Out of curiosity, what's the reasonning about creating a port for time?

Best regars,
Daniel
Comment 2 Daniel Engberg freebsd_committer freebsd_triage 2023-09-09 08:44:40 UTC
Sorry, MANDIR is a bit odd so ignore that one.
Comment 3 Ian Valentine 2023-09-15 00:43:07 UTC
Created attachment 244860 [details]
misc/gtime: Changes per request

Submitting new patch with requested changes.
Comment 4 Ian Valentine 2023-09-15 19:11:36 UTC
Comment on attachment 244860 [details]
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
>
>
Comment 5 Ian Valentine 2023-09-15 19:23:34 UTC
Sorry about that, the "Edit Attachment as Comment" button didn't do what I was expecting. Anyways...

Swapped out DISTNAME for PKGNAMEPREFIX.

Removed TEST_DEPENDS and TEST_USES altogether since the source includes the libraries it needs.

Cleaned up the PLIST_FILES and removed the variables.

Added the INFO entries.

Added a DOCS option.

Edited the max-rss test to allocate 400MB instead of 5, since the smaller allocation has inconsistent results even with /usr/bin/time (some quirk of how FreeBSD allocates memory?)

I'm mostly making this port because GNU time provides the '-f' format string parameter that some other software I use expects, and isn't provided by the builtin. It also seemed like a pretty decent case for a first port submission.
Comment 6 Ian Valentine 2023-09-15 19:46:20 UTC
Created attachment 244900 [details]
13-2-amd64 poudriere log

=>> Checking shared library dependencies
 0x0000000000000001 NEEDED               Shared library: [libc.so.7]

sticks out to me but I'm unsure if it's significant.
Comment 7 Ian Valentine 2023-09-15 19:50:58 UTC
Created attachment 244901 [details]
misc/gtime: diff with all requested changes