at 23.11-beta 117 lines 3.7 kB view raw
1{ lib 2, fetchurl 3, kaem 4, tinycc 5, gnumake 6, gnupatch 7}: 8let 9 pname = "bootstrap-coreutils"; 10 version = "5.0"; 11 12 src = fetchurl { 13 url = "mirror://gnu/coreutils/coreutils-${version}.tar.gz"; 14 sha256 = "10wq6k66i8adr4k08p0xmg87ff4ypiazvwzlmi7myib27xgffz62"; 15 }; 16 17 # Thanks to the live-bootstrap project! 18 # See https://github.com/fosslinux/live-bootstrap/blob/a8752029f60217a5c41c548b16f5cdd2a1a0e0db/sysa/coreutils-5.0/coreutils-5.0.kaem 19 liveBootstrap = "https://github.com/fosslinux/live-bootstrap/raw/a8752029f60217a5c41c548b16f5cdd2a1a0e0db/sysa/coreutils-5.0"; 20 21 makefile = fetchurl { 22 url = "${liveBootstrap}/mk/main.mk"; 23 sha256 = "0njg4xccxfqrslrmlb8ls7h6hlnfmdx42nvxwmca8flvczwrplfd"; 24 }; 25 26 patches = [ 27 # modechange.h uses functions defined in sys/stat.h, so we need to move it to 28 # after sys/stat.h include. 29 (fetchurl { 30 url = "${liveBootstrap}/patches/modechange.patch"; 31 sha256 = "04xa4a5w2syjs3xs6qhh8kdzqavxnrxpxwyhc3qqykpk699p3ms5"; 32 }) 33 # mbstate_t is a struct that is required. However, it is not defined by mes libc. 34 (fetchurl { 35 url = "${liveBootstrap}/patches/mbstate.patch"; 36 sha256 = "0rz3c0sflgxjv445xs87b83i7gmjpl2l78jzp6nm3khdbpcc53vy"; 37 }) 38 # strcoll() does not exist in mes libc, change it to strcmp. 39 (fetchurl { 40 url = "${liveBootstrap}/patches/ls-strcmp.patch"; 41 sha256 = "0lx8rz4sxq3bvncbbr6jf0kyn5bqwlfv9gxyafp0541dld6l55p6"; 42 }) 43 # getdate.c is pre-compiled from getdate.y 44 # At this point we don't have bison yet and in any case getdate.y does not 45 # compile when generated with modern bison. 46 (fetchurl { 47 url = "${liveBootstrap}/patches/touch-getdate.patch"; 48 sha256 = "1xd3z57lvkj7r8vs5n0hb9cxzlyp58pji7d335snajbxzwy144ma"; 49 }) 50 # touch: add -h to change symlink timestamps, where supported 51 (fetchurl { 52 url = "${liveBootstrap}/patches/touch-dereference.patch"; 53 sha256 = "0wky5r3k028xwyf6g6ycwqxzc7cscgmbymncjg948vv4qxsxlfda"; 54 }) 55 # strcoll() does not exist in mes libc, change it to strcmp. 56 (fetchurl { 57 url = "${liveBootstrap}/patches/expr-strcmp.patch"; 58 sha256 = "19f31lfsm1iwqzvp2fyv97lmqg4730prfygz9zip58651jf739a9"; 59 }) 60 # strcoll() does not exist in mes libc, change it to strcmp. 61 # hard_LC_COLLATE is used but not declared when HAVE_SETLOCALE is unset. 62 (fetchurl { 63 url = "${liveBootstrap}/patches/sort-locale.patch"; 64 sha256 = "0bdch18mpyyxyl6gyqfs0wb4pap9flr11izqdyxccx1hhz0a2i6c"; 65 }) 66 # don't assume fopen cannot return stdin or stdout. 67 (fetchurl { 68 url = "${liveBootstrap}/patches/uniq-fopen.patch"; 69 sha256 = "0qs6shyxl9j4h34v5j5sgpxrr4gjfljd2hxzw416ghwc3xzv63fp"; 70 }) 71 ]; 72in 73kaem.runCommand "${pname}-${version}" { 74 inherit pname version; 75 76 nativeBuildInputs = [ 77 tinycc.compiler 78 gnumake 79 gnupatch 80 ]; 81 82 meta = with lib; { 83 description = "The GNU Core Utilities"; 84 homepage = "https://www.gnu.org/software/coreutils"; 85 license = licenses.gpl3Plus; 86 maintainers = teams.minimal-bootstrap.members; 87 platforms = platforms.unix; 88 }; 89} '' 90 # Unpack 91 ungz --file ${src} --output coreutils.tar 92 untar --file coreutils.tar 93 rm coreutils.tar 94 cd coreutils-${version} 95 96 # Patch 97 ${lib.concatMapStringsSep "\n" (f: "patch -Np0 -i ${f}") patches} 98 99 # Configure 100 catm config.h 101 cp lib/fnmatch_.h lib/fnmatch.h 102 cp lib/ftw_.h lib/ftw.h 103 cp lib/search_.h lib/search.h 104 rm src/dircolors.h 105 106 # Build 107 make -f ${makefile} \ 108 CC="tcc -B ${tinycc.libs}/lib" \ 109 PREFIX=''${out} 110 111 # Check 112 ./src/echo "Hello coreutils!" 113 114 # Install 115 ./src/mkdir -p ''${out}/bin 116 make -f ${makefile} install PREFIX=''${out} 117''