06.10.2024 23:52, Klemens Nanni пишет:
> 'checksum' is noisy, especially when working on ports with lots of distfiles.
> Take net/go-ipfs for example with 1996(!) files in distinfo:
> 
>       $ cat checksum.sh
>       make checksum "$@" | awk '
>           /up to date/ {up++; if (up > 1) next}
>           /SHA256.*OK/ {ok++; if (ok > 1) next}
>           {print}
>           END {print "skipped up/ok", up, ok}
>       '
> 
>       $ sh ./checksum.sh CHECKSUM_QUIET=No
>       ===>  Checking files for kubo-0.26.0
>       `/home/distfiles/kubo-v0.26.0.zip' is up to date.
>       >> (SHA256) kubo-v0.26.0.zip: OK
>       skipped up/ok 1996 1996
> 
> In this usual case, I'd like to see all good cases folded so the output fits
> on a page, even for monster ports.

> So far so good, I haven't looked into the 'up to date' part, yet.

checksum is quiet now, but fetch is not:

        $ make fetch | grep -c 'is up to date'
        1996

These lines are produced by make(1) itself;  minimal reproducer (works anywhere,
needs no Makefile):

        $ echo 'int main(){return 0;}' >| foo.c
        $ make foo                             
        cc -O2 -pipe    -o foo foo.c 
        $ make foo
        `foo' is up to date.

Here's a WIP bsd.port.mk diff filtering those lines, such that, finally, even 
huge
ports produce a sane amount of output:

        $ make clean=all ; make clean=dist
        ...
        $ make fetch
        ...
        $ make checksum  # runs 'fetch' internally, but now all files are there
        ===>  Checking files for kubo-0.26.0
        >> (SHA256) all files: OK


The "drawback" is that ftp(1) progress meters, if enabled, do not load 
progressively,
since they now run through a pipe and not directly on the TTY anymore.
Use 'make _FETCH_FILTER=' with this diff to see old/current behaviour.

One fix would be to teach make(1) how to shut up on such messages.
GNU make(1) can do that already:

     -s, --silent, --quiet
          Silent operation; do not print the commands as they are executed.

        $ gmake foo
        gmake: 'foo' is up to date.
        $ gmake foo -s ; echo $?
        0

What do you think about quieting down 'fetch' and 'fetch-all' in general?

Personally, I'd be happy with the simple .mk diff below and not touching 
make(1),
but teaching make(1) a new trick and silencing our targets properly is fun, too.



Index: bsd.port.mk
===================================================================
RCS file: /cvs/ports/infrastructure/mk/bsd.port.mk,v
diff -u -p -r1.1640 bsd.port.mk
--- bsd.port.mk 18 Oct 2024 22:39:30 -0000      1.1640
+++ bsd.port.mk 20 Oct 2024 10:41:18 -0000
@@ -2525,12 +2530,23 @@ ${_DEP${_m}WANTLIB_COOKIE}: ${_DEPBUILD_
 
 .endfor
 
+# make(1) has no switch (yet) to silence general target status messages.
+# FIXME  using a pipe means ftp(1) runs without TTY and progress bars,
+# if enabled, will appear once as single line rather than "load".
+#
+# Having something similar to gmake(1) -s, --silent, --quiet that omits
+# "... is up to date." messages would solve this problem.
+#
+# | included in variable to allow easy testing with and without, e.g.
+#      `make ...' vs. `make ... _FETCH_FILTER='
+_FETCH_FILTER =        | { grep -v ' is up to date\.$$' || true; }
+
 _internal-fetch-all:
 # See ports/infrastructure/templates/Makefile.template
        @${ECHO_MSG} "===>  Checking files for ${FULLPKGNAME}${_MASTER}"
 # What FETCH-ALL normally does:
 .  if !empty(MAKESUMFILES)
-       @${_MAKE} ${MAKESUMFILES:S@^@${DISTDIR}/@}
+       @${_MAKE} ${MAKESUMFILES:S@^@${DISTDIR}/@} ${_FETCH_FILTER}
 .    endif
 # End of FETCH
 
@@ -2581,7 +2597,7 @@ _internal-fetch:
        @${ECHO_MSG} "===>  Checking files for ${FULLPKGNAME}${_MASTER}"
 # What FETCH normally does:
 .  if !empty(CHECKSUMFILES)
-       @${_MAKE} ${CHECKSUMFILES:S@^@${DISTDIR}/@}
+       @${_MAKE} ${CHECKSUMFILES:S@^@${DISTDIR}/@} ${_FETCH_FILTER}
 .  endif
 # End of FETCH
 

Reply via email to