diff options
author | Colin Percival <cperciva@FreeBSD.org> | 2021-06-29 17:45:46 +0000 |
---|---|---|
committer | Colin Percival <cperciva@FreeBSD.org> | 2021-06-29 18:00:54 +0000 |
commit | a9f5512f072d1b4e7a6bd8c3418df1213131efb1 (patch) | |
tree | 49fce2a36b6e598cfec6705099240b96c9ce0abc /usr.sbin | |
parent | 5ca9d41700078aa0757ee49aafbdd8f52fc96aae (diff) | |
download | src-a9f5512f072d1b4e7a6bd8c3418df1213131efb1.tar.gz src-a9f5512f072d1b4e7a6bd8c3418df1213131efb1.zip |
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
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/portsnap/portsnap/portsnap.sh | 5 |
1 files changed, 5 insertions, 0 deletions
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 |