archrelease: copy trunk to extra-x86_64
[arch-packages.git] / iana-etc / repos / core-any / PKGBUILD
blob9056aff2af10f3b6908da2cfd2f0bf5e84fbc4c6
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=20230405
7 _ports=service-names-port-numbers-${pkgver}
8 _protocols=protocol-numbers-20230316
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=('1f633a11b2f9d1b81f22885cb8b43eb80edc4893a2ef77c1fe16bf738adebe95'
19             '99d939412debbd69e49ad198f4c08b6d512b9e8f2f83e8f69be77da93aba1a24'
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"