summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmily Trau <emily@downunderctf.com>2023-09-17 22:21:18 -0700
committerEmily Trau <emily@downunderctf.com>2023-09-26 22:20:33 -0700
commit477a60351c2a234cce5d6b6df9dfbf3b1ab29dc4 (patch)
treee34f74d51d44f61ab81557a3c7a64b4e0b65374a
parentMerge pull request #242285 from emilytrau/appcleaner (diff)
downloadnixpkgs-477a60351c2a234cce5d6b6df9dfbf3b1ab29dc4.tar.gz
minimal-bootstrap.gnused: replace glibc with musl
-rw-r--r--pkgs/os-specific/linux/minimal-bootstrap/default.nix7
-rw-r--r--pkgs/os-specific/linux/minimal-bootstrap/gnused/common.nix12
-rw-r--r--pkgs/os-specific/linux/minimal-bootstrap/gnused/default.nix72
-rw-r--r--pkgs/os-specific/linux/minimal-bootstrap/gnused/mes.nix59
4 files changed, 94 insertions, 56 deletions
diff --git a/pkgs/os-specific/linux/minimal-bootstrap/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/default.nix
index 44cf8bfdb7b8..7387d3eaa910 100644
--- a/pkgs/os-specific/linux/minimal-bootstrap/default.nix
+++ b/pkgs/os-specific/linux/minimal-bootstrap/default.nix
@@ -108,14 +108,13 @@ lib.makeScope
gnused = callPackage ./gnused {
bash = bash_2_05;
- gcc = gcc2;
- glibc = glibc22;
+ tinycc = tinycc-musl;
+ musl = musl11;
gnused = gnused-mes;
};
- gnused-mes = callPackage ./gnused {
+ gnused-mes = callPackage ./gnused/mes.nix {
bash = bash_2_05;
tinycc = tinycc-mes;
- mesBootstrap = true;
};
gnutar = callPackage ./gnutar {
diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gnused/common.nix b/pkgs/os-specific/linux/minimal-bootstrap/gnused/common.nix
new file mode 100644
index 000000000000..658f05923ac3
--- /dev/null
+++ b/pkgs/os-specific/linux/minimal-bootstrap/gnused/common.nix
@@ -0,0 +1,12 @@
+{ lib }:
+
+{
+ meta = with lib; {
+ description = "GNU sed, a batch stream editor";
+ homepage = "https://www.gnu.org/software/sed";
+ license = licenses.gpl3Plus;
+ maintainers = teams.minimal-bootstrap.members;
+ mainProgram = "sed";
+ platforms = platforms.unix;
+ };
+}
diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gnused/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/gnused/default.nix
index b5647b96ee3c..ee237f016f5b 100644
--- a/pkgs/os-specific/linux/minimal-bootstrap/gnused/default.nix
+++ b/pkgs/os-specific/linux/minimal-bootstrap/gnused/default.nix
@@ -4,41 +4,35 @@
, fetchurl
, bash
, gnumake
-, mesBootstrap ? false, tinycc ? null
-, gcc ? null, glibc ? null, binutils ? null, gnused ? null, linux-headers, gnugrep
+, tinycc
+, musl
+, gnused
+, gnugrep
+, gnutar
+, gzip
}:
-assert mesBootstrap -> tinycc != null;
-assert !mesBootstrap -> gcc != null && glibc != null && binutils != null && gnused != null;
+
let
- pname = "gnused" + lib.optionalString mesBootstrap "-mes";
- # last version that can be compiled with mes-libc
- version = "4.0.9";
+ inherit (import ./common.nix { inherit lib; }) meta;
+ pname = "gnused";
+ # last version that can be bootstrapped with our slightly buggy gnused-mes
+ version = "4.2";
src = fetchurl {
url = "mirror://gnu/sed/sed-${version}.tar.gz";
- sha256 = "0006gk1dw2582xsvgx6y6rzs9zw8b36rhafjwm288zqqji3qfrf3";
- };
-
- # Thanks to the live-bootstrap project!
- # See https://github.com/fosslinux/live-bootstrap/blob/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/sed-4.0.9/sed-4.0.9.kaem
- makefile = fetchurl {
- url = "https://github.com/fosslinux/live-bootstrap/raw/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/sed-4.0.9/mk/main.mk";
- sha256 = "0w1f5ri0g5zla31m6l6xyzbqwdvandqfnzrsw90dd6ak126w3mya";
+ hash = "sha256-20XNY/0BDmUFN9ZdXfznaJplJ0UjZgbl5ceCk3Jn2YM=";
};
in
bash.runCommand "${pname}-${version}" {
- inherit pname version;
+ inherit pname version meta;
nativeBuildInputs = [
gnumake
- ] ++ lib.optionals mesBootstrap [
tinycc.compiler
- ] ++ lib.optionals (!mesBootstrap) [
- gcc
- glibc
- binutils
gnused
gnugrep
+ gnutar
+ gzip
];
passthru.tests.get-version = result:
@@ -46,51 +40,25 @@ bash.runCommand "${pname}-${version}" {
${result}/bin/sed --version
mkdir ''${out}
'';
-
- meta = with lib; {
- description = "GNU sed, a batch stream editor";
- homepage = "https://www.gnu.org/software/sed";
- license = licenses.gpl3Plus;
- maintainers = teams.minimal-bootstrap.members;
- mainProgram = "sed";
- platforms = platforms.unix;
- };
} (''
# Unpack
- ungz --file ${src} --output sed.tar
- untar --file sed.tar
- rm sed.tar
+ tar xzf ${src}
cd sed-${version}
-'' + lib.optionalString mesBootstrap ''
- # Configure
- cp ${makefile} Makefile
- catm config.h
-
- # Build
- make \
- CC="tcc -B ${tinycc.libs}/lib" \
- LIBC=mes
-
-'' + lib.optionalString (!mesBootstrap) ''
# Configure
- export CC="gcc -I${glibc}/include -I${linux-headers}/include"
- export LIBRARY_PATH="${glibc}/lib"
- export LIBS="-lc -lnss_files -lnss_dns -lresolv"
- chmod +x configure
+ export CC="tcc -B ${musl}/lib"
+ export LD=tcc
./configure \
--build=${buildPlatform.config} \
--host=${hostPlatform.config} \
--disable-shared \
--disable-nls \
--disable-dependency-tracking \
- --without-included-regex \
--prefix=$out
# Build
- make
+ make AR="tcc -ar"
-'' + ''
# Install
- make install PREFIX=$out
+ make install
'')
diff --git a/pkgs/os-specific/linux/minimal-bootstrap/gnused/mes.nix b/pkgs/os-specific/linux/minimal-bootstrap/gnused/mes.nix
new file mode 100644
index 000000000000..031b5b5f0db0
--- /dev/null
+++ b/pkgs/os-specific/linux/minimal-bootstrap/gnused/mes.nix
@@ -0,0 +1,59 @@
+{ lib
+, buildPlatform
+, hostPlatform
+, fetchurl
+, bash
+, gnumake
+, tinycc
+}:
+
+let
+ inherit (import ./common.nix { inherit lib; }) meta;
+ pname = "gnused-mes";
+ # last version that can be compiled with mes-libc
+ version = "4.0.9";
+
+ src = fetchurl {
+ url = "mirror://gnu/sed/sed-${version}.tar.gz";
+ sha256 = "0006gk1dw2582xsvgx6y6rzs9zw8b36rhafjwm288zqqji3qfrf3";
+ };
+
+ # Thanks to the live-bootstrap project!
+ # See https://github.com/fosslinux/live-bootstrap/blob/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/sed-4.0.9/sed-4.0.9.kaem
+ makefile = fetchurl {
+ url = "https://github.com/fosslinux/live-bootstrap/raw/1bc4296091c51f53a5598050c8956d16e945b0f5/sysa/sed-4.0.9/mk/main.mk";
+ sha256 = "0w1f5ri0g5zla31m6l6xyzbqwdvandqfnzrsw90dd6ak126w3mya";
+ };
+in
+bash.runCommand "${pname}-${version}" {
+ inherit pname version meta;
+
+ nativeBuildInputs = [
+ gnumake
+ tinycc.compiler
+ ];
+
+ passthru.tests.get-version = result:
+ bash.runCommand "${pname}-get-version-${version}" {} ''
+ ${result}/bin/sed --version
+ mkdir ''${out}
+ '';
+} (''
+ # Unpack
+ ungz --file ${src} --output sed.tar
+ untar --file sed.tar
+ rm sed.tar
+ cd sed-${version}
+
+ # Configure
+ cp ${makefile} Makefile
+ catm config.h
+
+ # Build
+ make \
+ CC="tcc -B ${tinycc.libs}/lib" \
+ LIBC=mes
+
+ # Install
+ make install PREFIX=$out
+'')