From owner-dev-commits-src-main@freebsd.org Tue Jun 29 18:01:23 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 56012650353; Tue, 29 Jun 2021 18:01:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GDsjb22JMz3hVq; Tue, 29 Jun 2021 18:01:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2452E1DA33; Tue, 29 Jun 2021 18:01:23 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 15TI1NgH016732; Tue, 29 Jun 2021 18:01:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 15TI1NfL016731; Tue, 29 Jun 2021 18:01:23 GMT (envelope-from git) Date: Tue, 29 Jun 2021 18:01:23 GMT Message-Id: <202106291801.15TI1NfL016731@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Colin Percival Subject: git: a9f5512f072d - main - portsnap: Shorten 'Skipping' output lines MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: cperciva X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a9f5512f072d1b4e7a6bd8c3418df1213131efb1 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Jun 2021 18:01:23 -0000 The branch main has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=a9f5512f072d1b4e7a6bd8c3418df1213131efb1 commit a9f5512f072d1b4e7a6bd8c3418df1213131efb1 Author: Colin Percival AuthorDate: 2021-06-29 17:45:46 +0000 Commit: Colin Percival 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