Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iana-etc: 2.30 -> 20170321 #23621

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/functions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@
<note>
<para>
If you see errors similar to <literal>getProtocolByName: does not exist (no such protocol name: tcp)</literal>
you may need to add <literal>pkgs.iana_etc</literal> to <varname>contents</varname>.
you may need to add <literal>pkgs.iana-etc</literal> to <varname>contents</varname>.
</para>
</note>

Expand Down
4 changes: 2 additions & 2 deletions nixos/modules/config/networking.nix
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,10 @@ in

environment.etc =
{ # /etc/services: TCP/UDP port assignments.
"services".source = pkgs.iana_etc + "/etc/services";
"services".source = pkgs.iana-etc + "/etc/services";

# /etc/protocols: IP protocol numbers.
"protocols".source = pkgs.iana_etc + "/etc/protocols";
"protocols".source = pkgs.iana-etc + "/etc/protocols";

# /etc/rpc: RPC program numbers.
"rpc".source = pkgs.glibc.out + "/etc/rpc";
Expand Down
89 changes: 89 additions & 0 deletions pkgs/data/misc/iana-etc/builder.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
source $stdenv/setup

# Curl flags :
# progress-bar is lighter on the screen
# retry 3 times
# fail silently (no output at all) on server errors ; an error code is still returned
# use only TLSv1.0, TLSv1.1 or TLSv1.2
# use the collections of trusted CAs from ${cacert}
# write output to a local file named like the remote file we get
# TODO: for security it would be possible to pin IANA certificate with --pinnedpubkey
curl="curl \
--progress-bar \
--retry 3 \
--fail \
--tlsv1 \
--cacert $cacert/etc/ssl/certs/ca-bundle.crt \
-O"


# Fetch protocols-numbers.xml over HTTPS
$curl "https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xml"
protoxml="protocol-numbers.xml"

# Fetch service-names-port-numbers.xml over HTTPS
$curl "https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xml"
svcxml="service-names-port-numbers.xml"


# Make sure protocol-numbers.xml is readable and is the file we expect
if [ ! -r $protoxml ] \
|| [ "$(head -n 1 $protoxml)" != "<?xml version='1.0' encoding='UTF-8'?>" ] \
|| [ "$(awk -F'[<>]' '/registry xmlns/{print $2; exit}' $protoxml)" != 'registry xmlns="http://www.iana.org/assignments" id="protocol-numbers"' ]
then
echo 'ERROR: protocol-numbers.xml does not match the expected structure'
exit 1
fi

# Same checks on service-names-port-numbers.xml
if [ ! -r $svcxml ] \
|| [ "$(head -n 1 $svcxml)" != "<?xml version='1.0' encoding='UTF-8'?>" ] \
|| [ "$(awk -F'[<>]' '/registry xmlns/{print $2; exit}' $svcxml)" != 'registry xmlns="http://www.iana.org/assignments" id="service-names-port-numbers"' ]
then
echo 'ERROR: service-names-port-numbers.xml does not match the expected structure'
exit 1
fi


# Create final directory in Nix store
mkdir -pv $out/etc

# Process /etc/protocols from IANA protocol-numbers.xml and install it
gawk '
BEGIN {
print "# See also protocols(5) and IANA official page :"
print "# https://www.iana.org/assignments/protocol-numbers \n#"
FS="[<>]"
}
{
if (/<updated/) { print "# Last updated: " $3 "\n" ; next }
if (/<record/) { v=n=0 }
if (/<value/) v=$3
if (/<name/ && !($3~/ /)) n=$3
if (/<\/record/ && (v || n=="HOPOPT") && n) printf "%-16s %3i %s\n", tolower(n),v,n
if (/<people/) exit
}
' $protoxml > $out/etc/protocols

# Process /etc/services from IANA service-names-port-numbers.xml and install it
gawk '
BEGIN {
print "# See also services(5) and IANA official page :"
print "# https://www.iana.org/assignments/service-names-port-numbers \n#"
FS="[<>]"
}
{
if (/<updated/) { print "# Last updated: " $3 "\n" ; next }
if (/<record/) { n=u=p=c=0 }
if (/<name/ && !/\(/) n=$3
if (/<number/) u=$3
if (/<protocol/) p=$3
if (/Unassigned/ || /Reserved/ || /historic/) c=1
if (/<\/record/ && n && u && p && !c) printf "%-16s %5i/%s\n", n,u,p
if (/<people/) exit
}
' $svcxml > $out/etc/services


# Some cleanup before leaving
rm *.xml
21 changes: 11 additions & 10 deletions pkgs/data/misc/iana-etc/default.nix
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
{stdenv, fetchurl}:
{ stdenv, cacert, curl }:

stdenv.mkDerivation rec {
name = "iana-etc-2.30";

src = fetchurl {
url = "http://sethwklein.net/${name}.tar.bz2";
sha256 = "03gjlg5zlwsdk6qyw3v85l129rna5bpm4m7pzrp864h0n97qg9mr";
};

preInstall = "installFlags=\"PREFIX=$out\"";
stdenv.mkDerivation rec {

name = "iana-etc-${version}";
version = "20170321";

phases = [ "buildPhase" ];
buildInputs = [ cacert curl ];
builder = ./builder.sh;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can only access the network with a fixed output drv when sandboxing is enabled, I'm pretty sure this will fail on hydra.



meta = {
homepage = http://sethwklein.net/iana-etc;
homepage = https://www.iana.org/;
description = "IANA protocol and port number assignments (/etc/protocols and /etc/services)";
platforms = stdenv.lib.platforms.unix;
};
Expand Down
4 changes: 2 additions & 2 deletions pkgs/development/compilers/go/1.4.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ stdenv, lib, fetchurl, fetchpatch, tzdata, iana_etc, libcCross
{ stdenv, lib, fetchurl, fetchpatch, tzdata, iana-etc, libcCross
, pkgconfig
, pcre
, Security }:
Expand Down Expand Up @@ -56,7 +56,7 @@ stdenv.mkDerivation rec {
# ParseInLocation fails the test
sed -i '/TestParseInSydney/areturn' src/time/format_test.go

sed -i 's,/etc/protocols,${iana_etc}/etc/protocols,' src/net/lookup_unix.go
sed -i 's,/etc/protocols,${iana-etc}/etc/protocols,' src/net/lookup_unix.go
'' + lib.optionalString stdenv.isLinux ''
sed -i 's,/usr/share/zoneinfo/,${tzdata}/share/zoneinfo/,' src/time/zoneinfo_unix.go

Expand Down
6 changes: 3 additions & 3 deletions pkgs/development/compilers/go/1.6.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ stdenv, lib, fetchurl, tzdata, iana_etc, go_bootstrap, runCommand
{ stdenv, lib, fetchurl, tzdata, iana-etc, go_bootstrap, runCommand
, perl, which, pkgconfig, patch, fetchpatch
, pcre
, Security, Foundation, bash }:
Expand Down Expand Up @@ -75,8 +75,8 @@ stdenv.mkDerivation rec {
# Remove the timezone naming test
sed -i '/TestLoadFixed/areturn' src/time/time_test.go

sed -i 's,/etc/protocols,${iana_etc}/etc/protocols,' src/net/lookup_unix.go
sed -i 's,/etc/services,${iana_etc}/etc/services,' src/net/port_unix.go
sed -i 's,/etc/protocols,${iana-etc}/etc/protocols,' src/net/lookup_unix.go
sed -i 's,/etc/services,${iana-etc}/etc/services,' src/net/port_unix.go
'' + lib.optionalString stdenv.isLinux ''
sed -i 's,/usr/share/zoneinfo/,${tzdata}/share/zoneinfo/,' src/time/zoneinfo_unix.go
'' + lib.optionalString stdenv.isDarwin ''
Expand Down
6 changes: 3 additions & 3 deletions pkgs/development/compilers/go/1.7.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ stdenv, fetchFromGitHub, tzdata, iana_etc, go_bootstrap, runCommand, writeScriptBin
{ stdenv, fetchFromGitHub, tzdata, iana-etc, go_bootstrap, runCommand, writeScriptBin
, perl, which, pkgconfig, patch, fetchpatch
, pcre, cacert
, Security, Foundation, bash }:
Expand Down Expand Up @@ -69,8 +69,8 @@ stdenv.mkDerivation rec {
# Remove the timezone naming test
sed -i '/TestLoadFixed/areturn' src/time/time_test.go

sed -i 's,/etc/protocols,${iana_etc}/etc/protocols,' src/net/lookup_unix.go
sed -i 's,/etc/services,${iana_etc}/etc/services,' src/net/port_unix.go
sed -i 's,/etc/protocols,${iana-etc}/etc/protocols,' src/net/lookup_unix.go
sed -i 's,/etc/services,${iana-etc}/etc/services,' src/net/port_unix.go

# Disable cgo lookup tests not works, they depend on resolver
rm src/net/cgo_unix_test.go
Expand Down
6 changes: 3 additions & 3 deletions pkgs/development/compilers/go/1.8.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ stdenv, fetchFromGitHub, tzdata, iana_etc, go_bootstrap, runCommand, writeScriptBin
{ stdenv, fetchFromGitHub, tzdata, iana-etc, go_bootstrap, runCommand, writeScriptBin
, perl, which, pkgconfig, patch, fetchpatch
, pcre, cacert
, Security, Foundation, bash }:
Expand Down Expand Up @@ -71,8 +71,8 @@ stdenv.mkDerivation rec {
# Remove the timezone naming test
sed -i '/TestLoadFixed/areturn' src/time/time_test.go

sed -i 's,/etc/protocols,${iana_etc}/etc/protocols,' src/net/lookup_unix.go
sed -i 's,/etc/services,${iana_etc}/etc/services,' src/net/port_unix.go
sed -i 's,/etc/protocols,${iana-etc}/etc/protocols,' src/net/lookup_unix.go
sed -i 's,/etc/services,${iana-etc}/etc/services,' src/net/port_unix.go

# Disable cgo lookup tests not works, they depend on resolver
rm src/net/cgo_unix_test.go
Expand Down
1 change: 1 addition & 0 deletions pkgs/top-level/aliases.nix
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ doNotDisplayTwice rec {
gupnptools = gupnp-tools; # added 2015-12-19
gnustep-make = gnustep.make; # added 2016-7-6
htmlTidy = html-tidy; # added 2014-12-06
iana_etc = iana-etc; # added 2017-03-08
inherit (haskell.compiler) jhc uhc; # 2015-05-15
inotifyTools = inotify-tools;
joseki = apache-jena-fuseki; # added 2016-02-28
Expand Down
2 changes: 1 addition & 1 deletion pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12593,7 +12593,7 @@ with pkgs;
inherit (callPackages ../data/fonts/gdouros { })
symbola aegyptus akkadian anatolian maya unidings musica analecta;

iana_etc = callPackage ../data/misc/iana-etc { };
iana-etc = callPackage ../data/misc/iana-etc { };

poppler_data = callPackage ../data/misc/poppler-data { };

Expand Down
2 changes: 1 addition & 1 deletion pkgs/top-level/release-small.nix
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ with import ./release-lib.nix { inherit supportedSystems; };
hdparm = linux;
hello = all;
host = linux;
iana_etc = linux;
iana-etc = linux;
icewm = linux;
idutils = all;
inetutils = linux;
Expand Down