about summary refs log tree commit diff
path: root/pkgs/os-specific/linux/minimal-bootstrap
diff options
context:
space:
mode:
authorEmily Trau <emily@downunderctf.com>2023-09-11 21:44:03 -0700
committerEmily Trau <emily@downunderctf.com>2023-09-11 21:44:03 -0700
commit5a3d1bcb12edfeb665e41351163fd1628cb29c23 (patch)
tree36f3ec8c3fc0bd3b47c57d452bdb5a9e36496cd9 /pkgs/os-specific/linux/minimal-bootstrap
parent04a90698aa2615d33eb5360a6cb4de3f1cf3571a (diff)
minimal-bootstrap.gawk: init at 4.1.4
Diffstat (limited to 'pkgs/os-specific/linux/minimal-bootstrap')
-rw-r--r--pkgs/os-specific/linux/minimal-bootstrap/default.nix8
-rw-r--r--pkgs/os-specific/linux/minimal-bootstrap/gawk/common.nix11
-rw-r--r--pkgs/os-specific/linux/minimal-bootstrap/gawk/default.nix68
-rw-r--r--pkgs/os-specific/linux/minimal-bootstrap/gawk/mes.nix13
4 files changed, 90 insertions, 10 deletions
diff --git a/pkgs/os-specific/linux/minimal-bootstrap/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/default.nix
index 83bf415c24d62..b8807eec0902f 100644
--- a/pkgs/os-specific/linux/minimal-bootstrap/default.nix
+++ b/pkgs/os-specific/linux/minimal-bootstrap/default.nix
@@ -65,6 +65,13 @@ lib.makeScope
       gnused = gnused-mes;
     };
 
+    gawk = callPackage ./gawk {
+      bash = bash_2_05;
+      gcc = gcc2;
+      glibc = glibc22;
+      bootGawk = gawk-mes;
+    };
+
     gcc2 = callPackage ./gcc/2.nix {
       bash = bash_2_05;
       gcc = gcc2-mes;
@@ -162,6 +169,7 @@ lib.makeScope
       echo ${diffutils.tests.get-version}
       echo ${findutils.tests.get-version}
       echo ${gawk-mes.tests.get-version}
+      echo ${gawk.tests.get-version}
       echo ${gcc2.tests.get-version}
       echo ${gcc2-mes.tests.get-version}
       echo ${gcc46.tests.get-version}
diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gawk/common.nix b/pkgs/os-specific/linux/minimal-bootstrap/gawk/common.nix
new file mode 100644
index 0000000000000..d95c66d86337c
--- /dev/null
+++ b/pkgs/os-specific/linux/minimal-bootstrap/gawk/common.nix
@@ -0,0 +1,11 @@
+{ lib }:
+
+{
+  meta = with lib; {
+    description = "GNU implementation of the Awk programming language";
+    homepage = "https://www.gnu.org/software/gawk";
+    license = licenses.gpl3Plus;
+    maintainers = teams.minimal-bootstrap.members;
+    platforms = platforms.unix;
+  };
+}
diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gawk/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/gawk/default.nix
new file mode 100644
index 0000000000000..935414f21760a
--- /dev/null
+++ b/pkgs/os-specific/linux/minimal-bootstrap/gawk/default.nix
@@ -0,0 +1,68 @@
+{ lib
+, buildPlatform
+, hostPlatform
+, fetchurl
+, bash
+, gcc
+, glibc
+, binutils
+, linux-headers
+, gnumake
+, gnugrep
+, gnused
+, gnutar
+, gzip
+, bootGawk
+}:
+let
+  inherit (import ./common.nix { inherit lib; }) meta;
+  pname = "gawk";
+  # >= 4.2.0 fails to cleanly build. may be worth investigating in the future.
+  # for now this version is sufficient to build glibc 2.16
+  version = "4.1.4";
+
+  src = fetchurl {
+    url = "mirror://gnu/gawk/gawk-${version}.tar.gz";
+    sha256 = "0dadjkpyyizmyd0l098qps8lb39r0vrz3xl3hwz2cmjs5c70h0wc";
+  };
+in
+bash.runCommand "${pname}-${version}" {
+  inherit pname version meta;
+
+  nativeBuildInputs = [
+    gcc
+    binutils
+    gnumake
+    gnused
+    gnugrep
+    gnutar
+    gzip
+    bootGawk
+  ];
+
+  passthru.tests.get-version = result:
+    bash.runCommand "${pname}-get-version-${version}" {} ''
+      ${result}/bin/awk --version
+      mkdir $out
+    '';
+} ''
+  # Unpack
+  tar xzf ${src}
+  cd gawk-${version}
+
+  # Configure
+  export C_INCLUDE_PATH="${glibc}/include:${linux-headers}/include"
+  export LIBRARY_PATH="${glibc}/lib"
+  export LIBS="-lc -lnss_files -lnss_dns -lresolv"
+  bash ./configure \
+    --prefix=$out \
+    --build=${buildPlatform.config} \
+    --host=${hostPlatform.config}
+
+  # Build
+  make gawk
+
+  # Install
+  install -D gawk $out/bin/gawk
+  ln -s gawk $out/bin/awk
+''
diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gawk/mes.nix b/pkgs/os-specific/linux/minimal-bootstrap/gawk/mes.nix
index d840a204416d6..c14399309306f 100644
--- a/pkgs/os-specific/linux/minimal-bootstrap/gawk/mes.nix
+++ b/pkgs/os-specific/linux/minimal-bootstrap/gawk/mes.nix
@@ -10,7 +10,8 @@
 , gnugrep
 }:
 let
-  pname = "gawk";
+  inherit (import ./common.nix { inherit lib; }) meta;
+  pname = "gawk-mes";
   # >=3.1.x is incompatible with mes-libc
   version = "3.0.6";
 
@@ -25,7 +26,7 @@ let
   ];
 in
 bash.runCommand "${pname}-${version}" {
-  inherit pname version;
+  inherit pname version meta;
 
   nativeBuildInputs = [
     tinycc.compiler
@@ -40,14 +41,6 @@ bash.runCommand "${pname}-${version}" {
       ${result}/bin/awk --version
       mkdir $out
     '';
-
-  meta = with lib; {
-    description = "GNU implementation of the Awk programming language";
-    homepage = "https://www.gnu.org/software/gawk";
-    license = licenses.gpl3Plus;
-    maintainers = teams.minimal-bootstrap.members;
-    platforms = platforms.unix;
-  };
 } ''
   # Unpack
   ungz --file ${src} --output gawk.tar