archrelease: copy trunk to extra-x86_64
[arch-packages.git] / iana-etc / trunk / PKGBUILD
blob22f7c75ef62cbd1bc4a780f17d1ccce84a3e1b43
1 # Contributor: Thomas Bächler <thomas@archlinux.org>
2 # Contributor: Gaetan Bisson <bisson@archlinux.org>
3 # Maintainer: Jelle van der Waa <jelle@archlinux.org>
5 pkgname=iana-etc
6 pkgver=20220427
7 _ports=service-names-port-numbers-${pkgver}
8 _protocols=protocol-numbers-20210718
9 pkgrel=1
10 pkgdesc='/etc/protocols and /etc/services provided by IANA'
11 url='https://www.iana.org/protocols'
12 arch=('any')
13 license=('custom:none')
14 backup=('etc/'{protocols,services})
15 source=("https://sources.archlinux.org/other/packages/iana-etc/${_ports}.xml"
16         "https://sources.archlinux.org/other/packages/iana-etc/${_protocols}.xml"
17         'LICENSE')
18 sha256sums=('ae629d2095d289924d5c3b9ce13c2b5283cb9b292b554c4f428e006d21da14c4'
19             '1a9570d4a35702a2b5fcb010701a607d874fc08e51d496c5e893e5881ea2837b'
20             'dd37e92942d5a4024f1c77df49d61ca77fc6284691814903a741785df61f78cb')
22 # Original but unversioned IANA files:
23 # https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xml
24 # https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xml
26 package() {
27         cd "${srcdir}"
29         install -d "${pkgdir}/etc"
30         install -Dm644 LICENSE "${pkgdir}/usr/share/licenses/iana-etc/LICENSE"
31         install -Dm644 ${_ports}.xml "${pkgdir}/usr/share/iana-etc/port-numbers.iana"
32         install -Dm644 ${_protocols}.xml "${pkgdir}/usr/share/iana-etc/protocol-numbers.iana"
34         gawk -F"[<>]" '
35 BEGIN { print "# Full data: /usr/share/iana-etc/protocol-numbers.iana\n" }
36 (/<record/) { v=n="" }
37 (/<value/) { v=$3 }
38 (/<name/ && $3!~/ /) { n=$3 }
39 (/<\/record/ && n && v!="") { printf "%-12s %3i %s\n", tolower(n),v,n }
40 ' ${_protocols}.xml > "${pkgdir}/etc/protocols"
42         gawk -F"[<>]" '
43 BEGIN { print "# Full data: /usr/share/iana-etc/port-numbers.iana\n" }
44 (/<record/) { n=u=p=c="" }
45 (/<name/ && !/\(/) { n=$3 }
46 (/<number/) { u=$3 }
47 (/<protocol/) { p=$3 }
48 (/Unassigned/ || /Reserved/ || /historic/) { c=1 }
49 (/<\/record/ && n && u && p && !c) { printf "%-15s %5i/%s\n", n,u,p }
50 ' ${_ports}.xml > "${pkgdir}/etc/services"