about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJohn Ericson <git@JohnEricson.me>2023-06-24 13:31:18 -0400
committerGitHub <noreply@github.com>2023-06-24 13:31:18 -0400
commit5467f89ede9a7c285ce2005ac7351c9a6662cf94 (patch)
tree2748fb0e33e26d931a879ae59e31c82df70d647c
parenta5a0c781424adf81fddba96234db072d667bec13 (diff)
parent43f5975c69bde0bb10ae6e966b806e404071c5d4 (diff)
Merge pull request #237870 from emilytrau/minimal-xz
minimal-bootstrap.xz: init at 5.0.8
-rw-r--r--pkgs/os-specific/linux/minimal-bootstrap/default.nix7
-rw-r--r--pkgs/os-specific/linux/minimal-bootstrap/xz/default.nix78
-rw-r--r--pkgs/os-specific/linux/minimal-bootstrap/xz/stubs.h25
3 files changed, 110 insertions, 0 deletions
diff --git a/pkgs/os-specific/linux/minimal-bootstrap/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/default.nix
index 3e4e9e7f5cb81..9011c45a8fe37 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 0000000000000..92cb240c5f164
--- /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 0000000000000..cbf6f823299e1
--- /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 <signal.h>
+int sigfillset (sigset_t * set)
+{
+  return 0;
+}