summary refs log tree commit diff
path: root/pkgs/os-specific/linux/minimal-bootstrap
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/os-specific/linux/minimal-bootstrap')
-rw-r--r--pkgs/os-specific/linux/minimal-bootstrap/bzip2/default.nix70
-rw-r--r--pkgs/os-specific/linux/minimal-bootstrap/default.nix36
-rw-r--r--pkgs/os-specific/linux/minimal-bootstrap/gawk/default.nix77
-rw-r--r--pkgs/os-specific/linux/minimal-bootstrap/gawk/no-stamp.patch10
-rw-r--r--pkgs/os-specific/linux/minimal-bootstrap/gnugrep/default.nix60
-rw-r--r--pkgs/os-specific/linux/minimal-bootstrap/gnutar/default.nix65
-rw-r--r--pkgs/os-specific/linux/minimal-bootstrap/gzip/default.nix58
-rw-r--r--pkgs/os-specific/linux/minimal-bootstrap/ln-boot/default.nix2
-rw-r--r--pkgs/os-specific/linux/minimal-bootstrap/ln-boot/ln.c2
-rw-r--r--pkgs/os-specific/linux/minimal-bootstrap/tinycc/common.nix2
10 files changed, 375 insertions, 7 deletions
diff --git a/pkgs/os-specific/linux/minimal-bootstrap/bzip2/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/bzip2/default.nix
new file mode 100644
index 0000000000000..cce36a2295011
--- /dev/null
+++ b/pkgs/os-specific/linux/minimal-bootstrap/bzip2/default.nix
@@ -0,0 +1,70 @@
+{ lib
+, fetchurl
+, bash
+, tinycc
+, gnumake
+, gnupatch
+, gzip
+}:
+let
+  pname = "bzip2";
+  version = "1.0.8";
+
+  src = fetchurl {
+    url = "https://sourceware.org/pub/bzip2/bzip2-${version}.tar.gz";
+    sha256 = "0s92986cv0p692icqlw1j42y9nld8zd83qwhzbqd61p1dqbh6nmb";
+  };
+
+  patches = [
+    # mes libc has no time support, so we remove that.
+    # It also does not have fch{own,mod}, which we don't care about in the bootstrap
+    # anyway, so we can null-op those calls.
+    (fetchurl {
+      url = "https://github.com/fosslinux/live-bootstrap/raw/87e9d7db9d22b400d1c05247254ac39ee2577e80/sysa/bzip2-1.0.8/patches/mes-libc.patch";
+      sha256 = "14dciwib28h413skzfkh7samzh8x87dmwhldyxxphff04pvl1j3c";
+    })
+  ];
+in
+bash.runCommand "${pname}-${version}" {
+  inherit pname version;
+
+  nativeBuildInputs = [
+    tinycc.compiler
+    gnumake
+    gnupatch
+    gzip
+  ];
+
+  passthru.tests.get-version = result:
+    bash.runCommand "${pname}-get-version-${version}" {} ''
+      ${result}/bin/bzip2 --version --help
+      mkdir $out
+    '';
+
+  meta = with lib; {
+    description = "High-quality data compression program";
+    homepage = "https://www.sourceware.org/bzip2";
+    license = licenses.bsdOriginal;
+    maintainers = teams.minimal-bootstrap.members;
+    platforms = platforms.unix;
+  };
+} ''
+  # Unpack
+  cp ${src} bzip2.tar.gz
+  gunzip bzip2.tar.gz
+  untar --file bzip2.tar
+  rm bzip2.tar
+  cd bzip2-${version}
+
+  # Patch
+  ${lib.concatMapStringsSep "\n" (f: "patch -Np0 -i ${f}") patches}
+
+  # Build
+  make \
+    CC="tcc -static -B ${tinycc.libs}/lib -I ." \
+    AR="tcc -ar" \
+    bzip2 bzip2recover
+
+  # Install
+  make install PREFIX=$out
+''
diff --git a/pkgs/os-specific/linux/minimal-bootstrap/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/default.nix
index 423f9e3f56519..066c75b9bf371 100644
--- a/pkgs/os-specific/linux/minimal-bootstrap/default.nix
+++ b/pkgs/os-specific/linux/minimal-bootstrap/default.nix
@@ -13,8 +13,23 @@ lib.makeScope
 
     bash_2_05 = callPackage ./bash/2.nix { tinycc = tinycc-mes; };
 
+    bzip2 = callPackage ./bzip2 {
+      bash = bash_2_05;
+      tinycc = tinycc-mes;
+    };
+
     coreutils = callPackage ./coreutils { tinycc = tinycc-mes; };
 
+    gawk = callPackage ./gawk {
+      bash = bash_2_05;
+      tinycc = tinycc-mes;
+    };
+
+    gnugrep = callPackage ./gnugrep {
+      bash = bash_2_05;
+      tinycc = tinycc-mes;
+    };
+
     gnumake = callPackage ./gnumake { tinycc = tinycc-mes; };
 
     gnupatch = callPackage ./gnupatch { tinycc = tinycc-mes; };
@@ -24,23 +39,38 @@ lib.makeScope
       tinycc = tinycc-mes;
     };
 
+    gnutar = callPackage ./gnutar {
+      bash = bash_2_05;
+      tinycc = tinycc-mes;
+    };
+
+    gzip = callPackage ./gzip {
+      bash = bash_2_05;
+      tinycc = tinycc-mes;
+    };
+
     ln-boot = callPackage ./ln-boot { };
 
-    mes = callPackage ./mes { };
+    mes = lib.recurseIntoAttrs (callPackage ./mes { });
     mes-libc = callPackage ./mes/libc.nix { };
 
     stage0-posix = callPackage ./stage0-posix { };
 
     inherit (self.stage0-posix) kaem m2libc mescc-tools mescc-tools-extra;
 
-    tinycc-bootstrappable = callPackage ./tinycc/bootstrappable.nix { };
-    tinycc-mes = callPackage ./tinycc/mes.nix { };
+    tinycc-bootstrappable = lib.recurseIntoAttrs (callPackage ./tinycc/bootstrappable.nix { });
+    tinycc-mes = lib.recurseIntoAttrs (callPackage ./tinycc/mes.nix { });
 
     inherit (callPackage ./utils.nix { }) fetchurl derivationWithMeta writeTextFile writeText;
 
     test = kaem.runCommand "minimal-bootstrap-test" {} ''
       echo ${bash_2_05.tests.get-version}
+      echo ${bzip2.tests.get-version}
+      echo ${gawk.tests.get-version}
+      echo ${gnugrep.tests.get-version}
       echo ${gnused.tests.get-version}
+      echo ${gnutar.tests.get-version}
+      echo ${gzip.tests.get-version}
       echo ${mes.compiler.tests.get-version}
       echo ${tinycc-mes.compiler.tests.chain}
       mkdir ''${out}
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..a395fe4b2a6cf
--- /dev/null
+++ b/pkgs/os-specific/linux/minimal-bootstrap/gawk/default.nix
@@ -0,0 +1,77 @@
+{ lib
+, buildPlatform
+, hostPlatform
+, fetchurl
+, bash
+, tinycc
+, gnumake
+, gnupatch
+, gnused
+, gnugrep
+}:
+let
+  pname = "gawk";
+  # >=3.1.x is incompatible with mes-libc
+  version = "3.0.6";
+
+  src = fetchurl {
+    url = "mirror://gnu/gawk/gawk-${version}.tar.gz";
+    sha256 = "1z4bibjm7ldvjwq3hmyifyb429rs2d9bdwkvs0r171vv1khpdwmb";
+  };
+
+  patches = [
+    # for reproducibility don't generate date stamp
+    ./no-stamp.patch
+  ];
+in
+bash.runCommand "${pname}-${version}" {
+  inherit pname version;
+
+  nativeBuildInputs = [
+    tinycc.compiler
+    gnumake
+    gnupatch
+    gnused
+    gnugrep
+  ];
+
+  passthru.tests.get-version = result:
+    bash.runCommand "${pname}-get-version-${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
+  untar --file gawk.tar
+  rm gawk.tar
+  cd gawk-${version}
+
+  # Patch
+  ${lib.concatMapStringsSep "\n" (f: "patch -Np0 -i ${f}") patches}
+
+  # Configure
+  export CC="tcc -static -B ${tinycc.libs}/lib"
+  export ac_cv_func_getpgrp_void=yes
+  export ac_cv_func_tzset=yes
+  bash ./configure \
+    --build=${buildPlatform.config} \
+    --host=${hostPlatform.config} \
+    --disable-nls \
+    --prefix=$out
+
+  # 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/no-stamp.patch b/pkgs/os-specific/linux/minimal-bootstrap/gawk/no-stamp.patch
new file mode 100644
index 0000000000000..74af25ba21060
--- /dev/null
+++ b/pkgs/os-specific/linux/minimal-bootstrap/gawk/no-stamp.patch
@@ -0,0 +1,10 @@
+--- configure
++++ configure
+@@ -3676,7 +3676,6 @@ cat >> $CONFIG_STATUS <<EOF
+ 
+ EOF
+ cat >> $CONFIG_STATUS <<\EOF
+-date > stamp-h
+ exit 0
+ EOF
+ chmod +x $CONFIG_STATUS
diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gnugrep/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/gnugrep/default.nix
new file mode 100644
index 0000000000000..434b92fafe6fa
--- /dev/null
+++ b/pkgs/os-specific/linux/minimal-bootstrap/gnugrep/default.nix
@@ -0,0 +1,60 @@
+{ lib
+, fetchurl
+, bash
+, tinycc
+, gnumake
+}:
+let
+  pname = "gnugrep";
+  version = "2.4";
+
+  src = fetchurl {
+    url = "mirror://gnu/grep/grep-${version}.tar.gz";
+    sha256 = "05iayw5sfclc476vpviz67hdy03na0pz2kb5csa50232nfx34853";
+  };
+
+  # Thanks to the live-bootstrap project!
+  # See https://github.com/fosslinux/live-bootstrap/blob/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/grep-2.4
+  makefile = fetchurl {
+    url = "https://github.com/fosslinux/live-bootstrap/raw/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/grep-2.4/mk/main.mk";
+    sha256 = "08an9ljlqry3p15w28hahm6swnd3jxizsd2188przvvsj093j91k";
+  };
+in
+bash.runCommand "${pname}-${version}" {
+  inherit pname version;
+
+  nativeBuildInputs = [
+    tinycc.compiler
+    gnumake
+  ];
+
+  passthru.tests.get-version = result:
+    bash.runCommand "${pname}-get-version-${version}" {} ''
+      ${result}/bin/grep --version
+      mkdir ''${out}
+    '';
+
+  meta = with lib; {
+    description = "GNU implementation of the Unix grep command";
+    homepage = "https://www.gnu.org/software/grep";
+    license = licenses.gpl3Plus;
+    maintainers = teams.minimal-bootstrap.members;
+    mainProgram = "grep";
+    platforms = platforms.unix;
+  };
+} ''
+  # Unpack
+  ungz --file ${src} --output grep.tar
+  untar --file grep.tar
+  rm grep.tar
+  cd grep-${version}
+
+  # Configure
+  cp ${makefile} Makefile
+
+  # Build
+  make CC="tcc -static -B ${tinycc.libs}/lib"
+
+  # Install
+  make install PREFIX=$out
+''
diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gnutar/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/gnutar/default.nix
new file mode 100644
index 0000000000000..446f7109eda32
--- /dev/null
+++ b/pkgs/os-specific/linux/minimal-bootstrap/gnutar/default.nix
@@ -0,0 +1,65 @@
+{ lib
+, buildPlatform
+, hostPlatform
+, fetchurl
+, bash
+, tinycc
+, gnumake
+, gnused
+, gnugrep
+}:
+let
+  pname = "gnutar";
+  # >= 1.13 is incompatible with mes-libc
+  version = "1.12";
+
+  src = fetchurl {
+    url = "mirror://gnu/tar/tar-${version}.tar.gz";
+    sha256 = "02m6gajm647n8l9a5bnld6fnbgdpyi4i3i83p7xcwv0kif47xhy6";
+  };
+in
+bash.runCommand "${pname}-${version}" {
+  inherit pname version;
+
+  nativeBuildInputs = [
+    tinycc.compiler
+    gnumake
+    gnused
+    gnugrep
+  ];
+
+  passthru.tests.get-version = result:
+    bash.runCommand "${pname}-get-version-${version}" {} ''
+      ${result}/bin/tar --version
+      mkdir $out
+    '';
+
+  meta = with lib; {
+    description = "GNU implementation of the `tar' archiver";
+    homepage = "https://www.gnu.org/software/tar";
+    license = licenses.gpl3Plus;
+    maintainers = teams.minimal-bootstrap.members;
+    mainProgram = "tar";
+    platforms = platforms.unix;
+  };
+} ''
+  # Unpack
+  ungz --file ${src} --output tar.tar
+  untar --file tar.tar
+  rm tar.tar
+  cd tar-${version}
+
+  # Configure
+  export CC="tcc -static -B ${tinycc.libs}/lib"
+  bash ./configure \
+    --build=${buildPlatform.config} \
+    --host=${hostPlatform.config} \
+    --disable-nls \
+    --prefix=$out
+
+  # Build
+  make AR="tcc -ar"
+
+  # Install
+  make install
+''
diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gzip/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/gzip/default.nix
new file mode 100644
index 0000000000000..b02486b4d1e15
--- /dev/null
+++ b/pkgs/os-specific/linux/minimal-bootstrap/gzip/default.nix
@@ -0,0 +1,58 @@
+{ lib
+, fetchurl
+, bash
+, tinycc
+, gnumake
+, gnused
+, gnugrep
+}:
+let
+  pname = "gzip";
+  version = "1.2.4";
+
+  src = fetchurl {
+    url = "mirror://gnu/gzip/gzip-${version}.tar.gz";
+    sha256 = "0ryr5b00qz3xcdcv03qwjdfji8pasp0007ay3ppmk71wl8c1i90w";
+  };
+in
+bash.runCommand "${pname}-${version}" {
+  inherit pname version;
+
+  nativeBuildInputs = [
+    tinycc.compiler
+    gnumake
+    gnused
+    gnugrep
+  ];
+
+  passthru.tests.get-version = result:
+    bash.runCommand "${pname}-get-version-${version}" {} ''
+      ${result}/bin/gzip --version
+      mkdir $out
+    '';
+
+  meta = with lib; {
+    description = "GNU zip compression program";
+    homepage = "https://www.gnu.org/software/gzip";
+    license = licenses.gpl3Plus;
+    maintainers = teams.minimal-bootstrap.members;
+    platforms = platforms.unix;
+  };
+} ''
+  # Unpack
+  ungz --file ${src} --output gzip.tar
+  untar --file gzip.tar
+  rm gzip.tar
+  cd gzip-${version}
+
+  # Configure
+  export CC="tcc -static -B ${tinycc.libs}/lib -Dstrlwr=unused"
+  bash ./configure --prefix=$out
+
+  # Build
+  make
+
+  # Install
+  mkdir $out
+  make install
+''
diff --git a/pkgs/os-specific/linux/minimal-bootstrap/ln-boot/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/ln-boot/default.nix
index 85f998198aa73..c24504ec00a02 100644
--- a/pkgs/os-specific/linux/minimal-bootstrap/ln-boot/default.nix
+++ b/pkgs/os-specific/linux/minimal-bootstrap/ln-boot/default.nix
@@ -4,7 +4,7 @@
 }:
 let
   pname = "ln-boot";
-  version = "unstable-2023-05-01";
+  version = "unstable-2023-05-22";
 
   src = ./ln.c;
 in
diff --git a/pkgs/os-specific/linux/minimal-bootstrap/ln-boot/ln.c b/pkgs/os-specific/linux/minimal-bootstrap/ln-boot/ln.c
index c8dde76a93648..b7a681f8270cf 100644
--- a/pkgs/os-specific/linux/minimal-bootstrap/ln-boot/ln.c
+++ b/pkgs/os-specific/linux/minimal-bootstrap/ln-boot/ln.c
@@ -8,7 +8,7 @@ int main(int argc, char** argv)
   if (argc != 4 || strcmp(argv[1], "-s")) {
     fputs("Usage: ", stdout);
     fputs(argv[0], stdout);
-    fputs("ln -s TARGET LINK_NAME\n", stdout);
+    fputs(" -s TARGET LINK_NAME\n", stdout);
     exit(EXIT_FAILURE);
   }
 
diff --git a/pkgs/os-specific/linux/minimal-bootstrap/tinycc/common.nix b/pkgs/os-specific/linux/minimal-bootstrap/tinycc/common.nix
index d05ac35a6d992..68fa84fd7ad1a 100644
--- a/pkgs/os-specific/linux/minimal-bootstrap/tinycc/common.nix
+++ b/pkgs/os-specific/linux/minimal-bootstrap/tinycc/common.nix
@@ -1,7 +1,6 @@
 { lib
 , kaem
 , mes-libc
-, ln-boot
 }:
 
 rec {
@@ -57,7 +56,6 @@ rec {
         (["-c" "-D" "TCC_TARGET_I386=1" ] ++ libtccBuildOptions);
       compiler =  kaem.runCommand "${pname}-${version}" {
         inherit pname version meta;
-        nativeBuildInputs = [ ln-boot ];
         passthru.tests = rec {
           get-version = result: kaem.runCommand "${pname}-get-version-${version}" {} ''
             ${result}/bin/tcc -version