Eric van Gyzen wrote in <59cd421e-f5d4-855a-83ec-65726f792555_at_vangyzen.net>: |On 9/10/18 12:04 PM, Eric van Gyzen wrote: |> Would anyone like to review this change to generate /etc/services from |> the IANA registry? |> |> https://reviews.freebsd.org/D17106 | |If that review made your browser unhappy, try this one instead: Yes it did. | https://reviews.freebsd.org/D17115 I mean, i have nothing to do with FreeBSD except that i use it since 4.7 (though some yours only indirectly as Mac OS X), and i am in opposition to quite some directions taken, but who am i, that is ok, i have a very narrow use case. But this is one of the things i really do not understand, bringing XML and Python stuff needlessly into FreeBSD seems very odd. For example, ArchLinux and CRUX Linux use a simple portable awk script to generate services and protocols, and all you need to count the number of services is a normal Unix pipeline which strips comments and then calls wc -l. I'll paste the script below this. Thank you. And ciao already here #!/bin/sh - #_at_ Update protocols and services from IANA. #_at_ Taken from ArchLinux script written by Gaetan Bisson. Adjusted for CRUX. awk=awk curl=curl url_pn=https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xml url_snpn=https://www.iana.org/assignments/service-names-port-numbers/\ service-names-port-numbers.xml datetime=`date +'%FT%T%z'` download() { echo 'Downloading protocols' ${curl} -o protocols.xml ${url_pn} [ ${?} -eq 0 ] || exit 20 echo 'Downloading services' ${curl} -o services.xml ${url_snpn} [ ${?} -eq 0 ] || exit 21 } process() { echo 'Processing protocols' ${awk} -F "[<>]" -v URL="${url_pn}" -v DT="${datetime}" ' BEGIN{ print "# /etc/protocols, created " DT print "# Source: " URL } /<record/ {v = n = ""} /<value/ {v = $3} /<name/ && $3 !~ / / {n = $3} /<\/record/ && n && v != ""{ printf "%-12s %3i %s\n", tolower(n), v, n } ' < protocols.xml > protocols.new [ ${?} -eq 0 ] || exit 30 echo 'Processing services' ${awk} -F "[<>]" -v URL="${url_snpn}" -v DT="${datetime}" ' BEGIN{ print "# /etc/services, created " DT print "# Source: " URL } /<record/ {n = u = p = c = ""} /<name/ && !/\(/ {n = $3} /<number/ {u = $3} /<protocol/ {p = $3} /Unassigned/ || /Reserved/ || /historic/ {c = 1} /<\/record/ && n && u && p && !c{ printf "%-15s %5i/%s\n", n, u, p } ' < services.xml > services.new [ ${?} -eq 0 ] || exit 31 } update() { mv protocols.new protocols [ ${?} -eq 0 ] || exit 40 mv services.new services [ ${?} -eq 0 ] || exit 41 rm -f protocols.xml services.xml } download process #update --steffen | |Der Kragenbaer, The moon bear, |der holt sich munter he cheerfully and one by one |einen nach dem anderen runter wa.ks himself off |(By Robert Gernhardt)Received on Tue Sep 11 2018 - 12:18:35 UTC
This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:18 UTC