8.5. Iana-Etc-4.0

The Iana-Etc package provides data for network services and protocols.

Approximate build time: less than 0.1 SBU
Required disk space: 600 KB

8.5.1. Installation of Iana-Etc

Prepare the PKGBUILD file for iana-etc:

mkdir /sources/iana-etc
cd /sources/iana-etc
cat > PKGBUILD << "REALEOF"
# Maintainer: Linux From Scratch <lfs-dev@lists.linuxfromscratch.org>

pkgname="iana-etc"
pkgver="4.0"
pkgrel="3"
pkgdesc="The Iana-Etc package provides data for network services and protocols."
arch=('any')
url="https://github.com/djlucas/iana-etc"
license=('OSL3')
groups=('core')
depends=('coreutils'
         'rootfs')
makedepends=('make')
backup=('etc/services'
        'etc/protocols')
source=("https://github.com/djlucas/iana-etc/releases/download/v4.0/iana-etc-4.0.tar.xz")
md5sums=('eccda8b61730fb53169491bdae0a77ea')

package() {
  cd "${pkgname}-${pkgver}"
  make get
  make
  make DESTDIR="${pkgdir}" install
  install -vdm755 "${pkgdir}/usr/libexec/iana-etc"
  install -vm644 protocols.gawk "${pkgdir}/usr/libexec/iana-etc"
  install -vm644 services.gawk "${pkgdir}/usr/libexec/iana-etc"
  install -vm644 get.pl "${pkgdir}/usr/libexec/iana-etc"
  install -vdm755 "${pkgdir}/usr/sbin"
  cat > "${pkgdir}/usr/sbin/iana-update" << "EOF"
#!/bin/bash

TEMPDIR=`mktemp -d`
cd ${TEMPDIR}
perl /usr/libexec/iana-etc/get.pl protocol-numbers
perl /usr/libexec/iana-etc/get.pl service-names-port-numbers
awk -f /usr/libexec/iana-etc/protocols.gawk -F"[<>]" protocol-numbers.xml > protocols
awk -f /usr/libexec/iana-etc/services.gawk -F"[<>]" service-names-port-numbers.xml > services
mv /etc/protocols{,.old}
mv /etc/services{,.old}
install -vm644 protocols /etc
install -vm644 services /etc
EOF
  chmod 755 "${pkgdir}/usr/sbin/iana-update"
}
REALEOF

Prepare the build directory for the pacman user and build the package:

chown -R root:pacman .
chmod 2775 .
chmod 664 PKGBUILD
su pacman -c 'makepkg -L --nodeps'

Add the newly created package to the central package repository:

cp iana-etc-4.0-3-any.pkg.tar.xz \
   /srv/pacman/repos/LFS/
repo-add /srv/pacman/repos/LFS/LFS.db.tar.xz \
         /srv/pacman/repos/LFS/iana-etc-4.0-3-any.pkg.tar.xz

Update the local cache and install the iana-etc package:

pacman -Syu
pacman -S iana-etc --overwrite \* -dd --noconfirm

Finally, copy the source files into the source repository and clean up the build directory:

mkdir /srv/pacman/source/LFS/iana-etc
cp PKGBUILD /srv/pacman/source/LFS/iana-etc
cd /sources
rm -rf iana-etc

8.5.2. Contents of Iana-Etc

Installed files: /etc/protocols and /etc/services

Short Descriptions

/etc/protocols

Describes the various DARPA Internet protocols that are available from the TCP/IP subsystem

/etc/services

Provides a mapping between friendly textual names for internet services, and their underlying assigned port numbers and protocol types