diff --git a/pkgs/os-specific/linux/minimal-bootstrap/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/default.nix index 3e4e9e7f5cb8..9011c45a8fe3 100644 --- a/pkgs/os-specific/linux/minimal-bootstrap/default.nix +++ b/pkgs/os-specific/linux/minimal-bootstrap/default.nix @@ -70,6 +70,12 @@ lib.makeScope tinycc-bootstrappable = lib.recurseIntoAttrs (callPackage ./tinycc/bootstrappable.nix { }); tinycc-mes = lib.recurseIntoAttrs (callPackage ./tinycc/mes.nix { }); + xz = callPackage ./xz { + bash = bash_2_05; + tinycc = tinycc-mes; + inherit (heirloom) sed; + }; + inherit (callPackage ./utils.nix { }) derivationWithMeta writeTextFile writeText; test = kaem.runCommand "minimal-bootstrap-test" {} '' @@ -83,6 +89,7 @@ lib.makeScope echo ${heirloom.tests.get-version} echo ${mes.compiler.tests.get-version} echo ${tinycc-mes.compiler.tests.chain} + echo ${xz.tests.get-version} mkdir ''${out} ''; }) diff --git a/pkgs/os-specific/linux/minimal-bootstrap/xz/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/xz/default.nix new file mode 100644 index 000000000000..92cb240c5f16 --- /dev/null +++ b/pkgs/os-specific/linux/minimal-bootstrap/xz/default.nix @@ -0,0 +1,78 @@ +{ lib +, buildPlatform +, hostPlatform +, fetchurl +, bash +, tinycc +, gnumake +, gnugrep +, gawk +, sed +}: +let + pname = "xz"; + # >=5.2 uses poll.h, unsupported by meslibc + version = "5.0.8"; + + src = fetchurl { + url = "https://tukaani.org/xz/xz-${version}.tar.bz2"; + sha256 = "1nkb68dyrf16xwyqichcy1vhgbfg20dxz459rcsdx85h1gczk1i2"; + }; +in +bash.runCommand "${pname}-${version}" { + inherit pname version; + + nativeBuildInputs = [ + tinycc.compiler + gnumake + gnugrep + gawk + sed + ]; + + passthru.tests.get-version = result: + bash.runCommand "${pname}-get-version-${version}" {} '' + ${result}/bin/xz --version + mkdir $out + ''; + + meta = with lib; { + description = "A general-purpose data compression software, successor of LZMA"; + homepage = "https://tukaani.org/xz"; + license = with licenses; [ gpl2Plus lgpl21Plus ]; + maintainers = teams.minimal-bootstrap.members; + platforms = platforms.unix; + }; +} '' + # Unpack + unbz2 --file ${src} --output xz.tar + untar --file xz.tar + rm xz.tar + cd xz-${version} + + # Configure + export CC="tcc -B ${tinycc.libs}/lib -include${./stubs.h}" + export CPP="tcc -E" + export LD=tcc + export AR="tcc -ar" + export SED=sed + export ac_cv_prog_cc_c99= + export ac_cv_header_fcntl_h=yes + export ac_cv_header_limits_h=yes + export ac_cv_header_sys_time_h=yes + export ac_cv_func_utime=no + bash ./configure \ + --prefix=$out \ + --build=${buildPlatform.config} \ + --host=${hostPlatform.config} \ + --disable-shared \ + --disable-nls \ + --disable-threads \ + --disable-assembler + + # Build + make all + + # Install + make install +'' diff --git a/pkgs/os-specific/linux/minimal-bootstrap/xz/stubs.h b/pkgs/os-specific/linux/minimal-bootstrap/xz/stubs.h new file mode 100644 index 000000000000..cbf6f823299e --- /dev/null +++ b/pkgs/os-specific/linux/minimal-bootstrap/xz/stubs.h @@ -0,0 +1,25 @@ +#define sig_atomic_t int + +#define SSIZE_MAX LONG_MAX + +#define O_NOCTTY 0400 +#define O_NONBLOCK 04000 + +#define S_ISVTX 01000 +#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK) + +int fchmod (int fd, int mode) +{ + return 0; +} + +int fchown (int fd, int owner, int group) +{ + return 0; +} + +#include +int sigfillset (sigset_t * set) +{ + return 0; +}