Merge pull request #244970 from emilytrau/minimal-sed-glibc

minimal-bootstrap.bash: init at 5.2.15
This commit is contained in:
John Ericson 2023-07-23 09:18:40 -04:00 committed by GitHub
commit 4179372632
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 155 additions and 6 deletions

View file

@ -0,0 +1,98 @@
{ lib
, buildPlatform
, hostPlatform
, fetchurl
, bootBash
, gnumake
, gnused
, gnugrep
, gnutar
, gawk
, gzip
, gcc
, glibc
, binutils
, linux-headers
, derivationWithMeta
, bash
, coreutils
}:
let
pname = "bash";
version = "5.2.15";
src = fetchurl {
url = "mirror://gnu/bash/bash-${version}.tar.gz";
sha256 = "132qng0jy600mv1fs95ylnlisx2wavkkgpb19c6kmz7lnmjhjwhk";
};
in
bootBash.runCommand "${pname}-${version}" {
inherit pname version;
nativeBuildInputs = [
gcc
binutils
gnumake
gnused
gnugrep
gnutar
gawk
gzip
];
passthru.runCommand = name: env: buildCommand:
derivationWithMeta ({
inherit name buildCommand;
builder = "${bash}/bin/bash";
args = [
"-e"
(builtins.toFile "bash-builder.sh" ''
export CONFIG_SHELL=$SHELL
bash -eux $buildCommandPath
'')
];
passAsFile = [ "buildCommand" ];
SHELL = "${bash}/bin/bash";
PATH = lib.makeBinPath ((env.nativeBuildInputs or []) ++ [
bash
coreutils
]);
} // (builtins.removeAttrs env [ "nativeBuildInputs" ]));
passthru.tests.get-version = result:
bootBash.runCommand "${pname}-get-version-${version}" {} ''
${result}/bin/bash --version
mkdir $out
'';
meta = with lib; {
description = "GNU Bourne-Again Shell, the de facto standard shell on Linux";
homepage = "https://www.gnu.org/software/bash";
license = licenses.gpl3Plus;
maintainers = teams.minimal-bootstrap.members;
platforms = platforms.unix;
};
} ''
# Unpack
tar xzf ${src}
cd bash-${version}
# Configure
export CC="gcc -I${glibc}/include -I${linux-headers}/include"
export LIBRARY_PATH="${glibc}/lib"
export LIBS="-lc -lnss_files -lnss_dns -lresolv"
export ac_cv_func_dlopen=no
bash ./configure \
--prefix=$out \
--build=${buildPlatform.config} \
--host=${hostPlatform.config} \
--disable-nls \
--disable-net-redirections
# Build
make SHELL=bash
# Install
make install
''

View file

@ -15,6 +15,12 @@ lib.makeScope
bash_2_05 = callPackage ./bash/2.nix { tinycc = tinycc-mes; };
bash = callPackage ./bash {
bootBash = bash_2_05;
gcc = gcc2;
glibc = glibc22;
};
binutils = callPackage ./binutils {
bash = bash_2_05;
gcc = gcc2;
@ -39,6 +45,7 @@ lib.makeScope
gawk = callPackage ./gawk {
bash = bash_2_05;
tinycc = tinycc-mes;
gnused = gnused-mes;
};
gcc2 = callPackage ./gcc/2.nix {
@ -56,6 +63,7 @@ lib.makeScope
inherit (callPackage ./glibc {
bash = bash_2_05;
gnused = gnused-mes;
}) glibc22;
gnugrep = callPackage ./gnugrep {
@ -68,18 +76,27 @@ lib.makeScope
gnupatch = callPackage ./gnupatch { tinycc = tinycc-mes; };
gnused = callPackage ./gnused {
bash = bash_2_05;
gcc = gcc2;
glibc = glibc22;
gnused = gnused-mes;
};
gnused-mes = callPackage ./gnused {
bash = bash_2_05;
tinycc = tinycc-mes;
mesBootstrap = true;
};
gnutar = callPackage ./gnutar {
bash = bash_2_05;
tinycc = tinycc-mes;
gnused = gnused-mes;
};
gzip = callPackage ./gzip {
bash = bash_2_05;
tinycc = tinycc-mes;
gnused = gnused-mes;
};
heirloom = callPackage ./heirloom {
@ -112,6 +129,7 @@ lib.makeScope
inherit (callPackage ./utils.nix { }) derivationWithMeta writeTextFile writeText;
test = kaem.runCommand "minimal-bootstrap-test" {} ''
echo ${bash.tests.get-version}
echo ${bash_2_05.tests.get-version}
echo ${binutils.tests.get-version}
echo ${binutils-mes.tests.get-version}
@ -121,6 +139,7 @@ lib.makeScope
echo ${gcc2-mes.tests.get-version}
echo ${gnugrep.tests.get-version}
echo ${gnused.tests.get-version}
echo ${gnused-mes.tests.get-version}
echo ${gnutar.tests.get-version}
echo ${gzip.tests.get-version}
echo ${heirloom.tests.get-version}

View file

@ -131,8 +131,8 @@ bash.runCommand "${pname}-${version}" {
${lib.optionalString mesBootstrap "ar x ${tinycc.libs}/lib/libtcc1.a"}
ar r $out/lib/gcc-lib/${hostPlatform.config}/${version}/libgcc.a *.o
cd ..
cp gcc/libgcc2.a $out/lib/libgcc2.a
${lib.optionalString mesBootstrap ''
cp gcc/libgcc2.a $out/lib/libgcc2.a
ar x ${tinycc.libs}/lib/libtcc1.a
ar x ${tinycc.libs}/lib/libc.a
ar r $out/lib/gcc-lib/${hostPlatform.config}/${version}/libc.a libc.o libtcc1.o

View file

@ -1,11 +1,16 @@
{ lib
, buildPlatform
, hostPlatform
, fetchurl
, bash
, tinycc
, gnumake
, mesBootstrap ? false, tinycc ? null
, gcc ? null, glibc ? null, binutils ? null, gnused ? null, linux-headers, gnugrep
}:
assert mesBootstrap -> tinycc != null;
assert !mesBootstrap -> gcc != null && glibc != null && binutils != null && gnused != null;
let
pname = "gnused";
pname = "gnused" + lib.optionalString mesBootstrap "-mes";
# last version that can be compiled with mes-libc
version = "4.0.9";
@ -25,8 +30,15 @@ bash.runCommand "${pname}-${version}" {
inherit pname version;
nativeBuildInputs = [
tinycc.compiler
gnumake
] ++ lib.optionals mesBootstrap [
tinycc.compiler
] ++ lib.optionals (!mesBootstrap) [
gcc
glibc
binutils
gnused
gnugrep
];
passthru.tests.get-version = result:
@ -43,13 +55,14 @@ bash.runCommand "${pname}-${version}" {
mainProgram = "sed";
platforms = platforms.unix;
};
} ''
} (''
# Unpack
ungz --file ${src} --output sed.tar
untar --file sed.tar
rm sed.tar
cd sed-${version}
'' + lib.optionalString mesBootstrap ''
# Configure
cp ${makefile} Makefile
catm config.h
@ -59,6 +72,25 @@ bash.runCommand "${pname}-${version}" {
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
./configure \
--build=${buildPlatform.config} \
--host=${hostPlatform.config} \
--disable-shared \
--disable-nls \
--disable-dependency-tracking \
--without-included-regex \
--prefix=$out
# Build
make
'' + ''
# Install
make install PREFIX=$out
''
'')