[Clfs-dev] iana-etc
Grail Dane
grail69 at hotmail.com
Sun Jan 16 21:53:28 PST 2011
Hey Andrew
Sorry about that ... Appears I was being a bit dyslexic when I typed mine in and put the * in the wrong spot.The following is the correction:
sed -i '/file=/s at pro[^ ]*@&/&.txt@' MakefileI also did not like the formatting used in the source (picky I know), soattached are a couple of replacement scripts for protocols.gawk and services.gawkshould anyone like to use them :)CheersGrail
Date: Sun, 16 Jan 2011 11:24:03 -0500
From: bradfa at gmail.com
To: clfs-dev at lists.cross-lfs.org
Subject: Re: [Clfs-dev] iana-etc
On Sun, Jan 16, 2011 at 11:13 AM, Andrew Bradford <bradfa at gmail.com> wrote:
>
> On Thu, Jan 13, 2011 at 2:19 AM, Grail Dane <grail69 at hotmail.com> wrote:
>>
>> Hi All
>> Wasn't sure if this was a dev thing or not, but I see we have recently started to host our own copy of iana-etc as the original site seems
>> to not be responding. After searching for a bit I found a thread on LFS talking about it and the fact that not only could
>> the source not been downloaded but once it is that the files being used, ie services and protocols, are out of date (circa 2008).
>> The hot debate about how to update them never really seemed to get resolved except to say to get them from iana directly.
>> What I thought I would add here is that with one simple change and an addition to make this can be done:
>> 1. The following sed update the now out of date link to where the protocol files are stored:
>> sed -i '/file=/s at pro[^ *]@&/&.txt@' Makefile
>> 2. There is already a built in get call that can retrieve the latest copies, so simply do the following:
>> make get && make
>> And viola, if you ran this today the files would be as up to date as:
>> services 2011-01-11
>> protocols 2010-11-23
>> Just thought you might all like to know :)
>> Cheers
>> Grail
>
> Grail,
>
> Thanks for pointing this out! I didn't know the package had a built in updater script, that's neat.
>
> I did find that your sed line doesn't work well for me on amd64 Debian 5, it ends up garbling the protocol-numbers.iana line in Makefile to look like this:
>
> protocol-numbers.iana:
> $(AWK) -f get.gawk -v file=prot/prot.txtocol-numbers >protocol-numbers.i
> ana
>
> Which isn't the desired output. A less complex sed line that works for me, achieves your desired intent, and is a little easier for the regex impaired (myself included :) would be:
>
> sed -i '/file=/s at protocol-numbers@&/&.txt@' Makefile
>
> I'll craft a patch and submit it to the list.
>
> Regards,
> Andrew
Patch attached for the embedded book. It may also work on other books
but I haven't tested that.
Sorry if my previous email's sed line got wrecked (the list archiver
didn't like it, thought it was an email address).
Regards,
Andrew
_______________________________________________
Clfs-dev mailing list
Clfs-dev at lists.cross-lfs.org
http://lists.cross-lfs.org/listinfo.cgi/clfs-dev-cross-lfs.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.clfs.org/pipermail/clfs-dev-clfs.org/attachments/20110117/76bac860/attachment-0001.htm>
-------------- next part --------------
#!/usr/bin/awk -f
BEGIN{
if(strip == "yes"){
strip = 1
format = "%-20s %-7s %-20s\n"
}
else{
strip = 0
format = "%-20s %-7s %-20s # %s\n"
print "# See also: protocols(5)" \
", http://www.iana.org/protocols\n#"
}
}
/People/{ concat = 0 }
concat && $1 ~ /^[0-9[]/{
if(!$1){
f2 = index($0,$2)
f3 = index($0,$3)
f2l = f3 - f2
bpos = index($0,"[")
linel = 52 - f3 + 1
}
if($1 ~ /^\[/){
line = ""
while($1 !~ /^[0-9-]+$/){
if(line)
line = sprintf("%s\n#%-"linel + bpos - 1"s%s", line, " ", substr($0, bpos))
else
line = substr($0, bpos)
getline
}
$0 = substr($0, 1, bpos - 1) line
}
while(!/]$/){
getline temp
$0 = sprintf("%s\n#%-"linel"s%s", $0, " ", temp)
}
prot = substr($0,f2,f2l)
printf format, tolower(prot), $1, prot, substr($0,f3)
next
}
!strip{
if(concat)
printf "#%-"linel"s%s\n", " ",$0
else
print "#" $0
}
/Decimal/{
printf format, "# protocol", "num", "aliases", "comments"
concat = 1
}
-------------- next part --------------
#!/usr/bin/gawk -f
# Copyright (c) 2003-2004, 2006, 2008 Seth W. Klein <sk at sethwklein.net>
# Licensed under the Open Software License version 3.0
# See the file COPYING in the distribution tarball or
# http://www.opensource.org/licenses/osl-3.0.txt
BEGIN {
if (strip == "yes") {
strip = 1
format = "%-20s%-15s\n"
}
else {
strip = 0
format = "%-20s%-15s%s\n"
print "# See also: services(5)" \
", http://www.iana.org/protocols\n#"
}
while (getline <"port-aliases")
if(/^[[:alnum:]]/)
aliases[$1$2]=" "$3
}
x && ((/IANA/ && ! y )|| /PRIVATE/){ x = 0;y=1 }
# 1:name 2:port 3:proto 4:comment
x{
if(match($0, /(^[[:alnum:]][^ \t]+)[ \t]+([0-9]+)[0-9-]*\/([^ \t]+)[ \t]*(.*)/, f)){
if(!f[2])# port 0 means unallocated, per port-numbers
f[1] = "# "f[1]
if(f[4])
comment = " # "f[4]
else
comment = ""
printf format, f[1], f[2]"/"f[3] aliases[f[1] f[3]], comment
next
}
if(/^#?[ \t]+[0-9]/){
sub(/^#/,"")
$0 = sprintf("%-20s%-18s%s", "#", $1, gensub("^.*"$1,"","g"))
}
else if(/^#?[ \t]+[^0-9]/)
$0 = sprintf("%-38s%s", "#", gensub(/^#?[ \t]*/,"","g"))
}
/^------- /{ x = 1 }
# comment out, prettily
!/^#/ { sub(/^ /, "#") || sub(/^/, "# ") }
!strip
More information about the Clfs-dev
mailing list