diff options
author | Emily Trau <emily@downunderctf.com> | 2023-05-18 09:20:59 +1000 |
---|---|---|
committer | Emily Trau <emily@downunderctf.com> | 2023-05-18 18:37:44 +1000 |
commit | 8f616ec0ac621f08c54f8ae8621ed80f2acc2fa0 (patch) | |
tree | 27ced15d3d6cab62711db731b35bc1eef0032b2d /pkgs | |
parent | 3caff70464e9c6900620f4a8c0f6dbeb019f8ce3 (diff) | |
download | nixpkgs-8f616ec0ac621f08c54f8ae8621ed80f2acc2fa0.tar nixpkgs-8f616ec0ac621f08c54f8ae8621ed80f2acc2fa0.tar.gz nixpkgs-8f616ec0ac621f08c54f8ae8621ed80f2acc2fa0.tar.bz2 nixpkgs-8f616ec0ac621f08c54f8ae8621ed80f2acc2fa0.tar.lz nixpkgs-8f616ec0ac621f08c54f8ae8621ed80f2acc2fa0.tar.xz nixpkgs-8f616ec0ac621f08c54f8ae8621ed80f2acc2fa0.tar.zst nixpkgs-8f616ec0ac621f08c54f8ae8621ed80f2acc2fa0.zip |
minimal-bootstrap.coreutils: init at 5.0
Diffstat (limited to 'pkgs')
-rw-r--r-- | pkgs/os-specific/linux/minimal-bootstrap/coreutils/default.nix | 112 | ||||
-rw-r--r-- | pkgs/os-specific/linux/minimal-bootstrap/default.nix | 2 |
2 files changed, 114 insertions, 0 deletions
diff --git a/pkgs/os-specific/linux/minimal-bootstrap/coreutils/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/coreutils/default.nix new file mode 100644 index 00000000000..b7876b0939f --- /dev/null +++ b/pkgs/os-specific/linux/minimal-bootstrap/coreutils/default.nix @@ -0,0 +1,112 @@ +{ lib +, fetchurl +, kaem +, tinycc +, gnumake +, gnupatch +}: +let + pname = "coreutils"; + version = "5.0"; + + src = fetchurl { + url = "mirror://gnu/coreutils/coreutils-${version}.tar.gz"; + sha256 = "10wq6k66i8adr4k08p0xmg87ff4ypiazvwzlmi7myib27xgffz62"; + }; + + # Thanks to the live-bootstrap project! + # See https://github.com/fosslinux/live-bootstrap/blob/e86db47b6ee40d68e26866dd15e8637f64d6d778/sysa/coreutils-5.0/coreutils-5.0.kaem + liveBootstrap = "https://github.com/fosslinux/live-bootstrap/raw/e86db47b6ee40d68e26866dd15e8637f64d6d778/sysa/coreutils-5.0"; + + makefile = fetchurl { + url = "${liveBootstrap}/mk/main.mk"; + sha256 = "0njg4xccxfqrslrmlb8ls7h6hlnfmdx42nvxwmca8flvczwrplfd"; + }; + + patches = [ + # modechange.h uses functions defined in sys/stat.h, so we need to move it to + # after sys/stat.h include. + (fetchurl { + url = "${liveBootstrap}/patches/modechange.patch"; + sha256 = "04xa4a5w2syjs3xs6qhh8kdzqavxnrxpxwyhc3qqykpk699p3ms5"; + }) + # mbstate_t is a struct that is required. However, it is not defined by mes libc. + (fetchurl { + url = "${liveBootstrap}/patches/mbstate.patch"; + sha256 = "0rz3c0sflgxjv445xs87b83i7gmjpl2l78jzp6nm3khdbpcc53vy"; + }) + # strcoll() does not exist in mes libc, change it to strcmp. + (fetchurl { + url = "${liveBootstrap}/patches/ls-strcmp.patch"; + sha256 = "0lx8rz4sxq3bvncbbr6jf0kyn5bqwlfv9gxyafp0541dld6l55p6"; + }) + # getdate.c is pre-compiled from getdate.y + # At this point we don't have bison yet and in any case getdate.y does not + # compile when generated with modern bison. + (fetchurl { + url = "${liveBootstrap}/patches/touch-getdate.patch"; + sha256 = "1xd3z57lvkj7r8vs5n0hb9cxzlyp58pji7d335snajbxzwy144ma"; + }) + # touch: add -h to change symlink timestamps, where supported + (fetchurl { + url = "${liveBootstrap}/patches/touch-dereference.patch"; + sha256 = "0wky5r3k028xwyf6g6ycwqxzc7cscgmbymncjg948vv4qxsxlfda"; + }) + # strcoll() does not exist in mes libc, change it to strcmp. + (fetchurl { + url = "${liveBootstrap}/patches/expr-strcmp.patch"; + sha256 = "19f31lfsm1iwqzvp2fyv97lmqg4730prfygz9zip58651jf739a9"; + }) + # strcoll() does not exist in mes libc, change it to strcmp. + # hard_LC_COLLATE is used but not declared when HAVE_SETLOCALE is unset. + (fetchurl { + url = "${liveBootstrap}/patches/sort-locale.patch"; + sha256 = "0bdch18mpyyxyl6gyqfs0wb4pap9flr11izqdyxccx1hhz0a2i6c"; + }) + ]; +in +kaem.runCommand "${pname}-${version}" { + inherit pname version; + + nativeBuildInputs = [ + tinycc.compiler + gnumake + gnupatch + ]; + + meta = with lib; { + description = "The GNU Core Utilities"; + homepage = "https://www.gnu.org/software/coreutils"; + license = licenses.gpl3Plus; + maintainers = teams.minimal-bootstrap.members; + platforms = platforms.unix; + }; +} '' + # Unpack + ungz --file ${src} --output coreutils.tar + untar --file coreutils.tar + rm coreutils.tar + cd coreutils-${version} + + # Patch + ${lib.concatMapStringsSep "\n" (f: "patch -Np0 -i ${f}") patches} + + # Configure + catm config.h + cp lib/fnmatch_.h lib/fnmatch.h + cp lib/ftw_.h lib/ftw.h + cp lib/search_.h lib/search.h + rm src/dircolors.h + + # Build + make -f ${makefile} \ + CC="tcc -B ${tinycc.libs}/lib" \ + PREFIX=''${out} + + # Check + ./src/echo "Hello coreutils!" + + # Install + ./src/mkdir -p ''${out}/bin + make -f ${makefile} install PREFIX=''${out} +'' diff --git a/pkgs/os-specific/linux/minimal-bootstrap/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/default.nix index 5907cdb4cda..f4f81a70fac 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/default.nix @@ -11,6 +11,8 @@ lib.makeScope (extra: lib.callPackageWith ({ inherit lib config buildPlatform hostPlatform; } // extra)) (self: with self; { + coreutils = callPackage ./coreutils { tinycc = tinycc-mes; }; + gnupatch = callPackage ./gnupatch { tinycc = tinycc-mes; }; gnumake = callPackage ./gnumake { tinycc = tinycc-mes; }; |