Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 29 Jun 2021 18:01:23 GMT
From:      Colin Percival <cperciva@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: a9f5512f072d - main - portsnap: Shorten 'Skipping' output lines
Message-ID:  <202106291801.15TI1NfL016731@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by cperciva:

URL: https://cgit.FreeBSD.org/src/commit/?id=a9f5512f072d1b4e7a6bd8c3418df1213131efb1

commit a9f5512f072d1b4e7a6bd8c3418df1213131efb1
Author:     Colin Percival <cperciva@FreeBSD.org>
AuthorDate: 2021-06-29 17:45:46 +0000
Commit:     Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2021-06-29 18:00:54 +0000

    portsnap: Shorten 'Skipping' output lines
    
    Portsnap uses patches opportunistically to reduce download bandwidth: It
    attempts to fetch patches which could be useful, and then makes use of
    whichever patches it actually gets.  (This solves the otherwise O(n^2)
    issue for the server to build patches between every pair of versions.)
    
    During the process of applying patches, portsnap prints lines of the
    form "Skipping XXX-YYY (123 of 4567).\r", where the \r serves to allow
    each of these (potentially many) lines to overwrite the previous one
    on the console.  Unfortunately, XXX and YYY here are SHA256 hashes,
    resulting in these lines wrapping on reasonable-width consoles.
    
    Replace the hashes with abbreviations of the form "0123...cdef"
    (cutting 64 characters down to 11) in order to keep lines to a
    reasonable length.
    
    The rather ugly shell code here is used to avoid forking additional
    processes; it would be much cleaner using sed(1), but in my testing
    the sed-based alternative increases CPU time consumption by 50%.
    
    Requested by:   des
---
 usr.sbin/portsnap/portsnap/portsnap.sh | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/usr.sbin/portsnap/portsnap/portsnap.sh b/usr.sbin/portsnap/portsnap/portsnap.sh
index 9db381e99f86..2edc51460642 100644
--- a/usr.sbin/portsnap/portsnap/portsnap.sh
+++ b/usr.sbin/portsnap/portsnap/portsnap.sh
@@ -838,6 +838,11 @@ fetch_update() {
 		I=$(($I + 1))
 		F="${X}-${Y}"
 		if [ ! -f "${F}" ]; then
+			XS=${X%[0-9a-f][0-9a-f][0-9a-f][0-9a-f]}
+			XE=${X#[0-9a-f][0-9a-f][0-9a-f][0-9a-f]}
+			YS=${Y%[0-9a-f][0-9a-f][0-9a-f][0-9a-f]}
+			YE=${Y#[0-9a-f][0-9a-f][0-9a-f][0-9a-f]}
+			F="${X%${XE}}...${X#${XS}}-${Y%${YE}}...${Y#${YS}}"
 			printf "  Skipping ${F} (${I} of ${PATCHCNT}).\r"
 			continue;
 		fi



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202106291801.15TI1NfL016731>