summary refs log tree commit diff
path: root/pkgs/os-specific/linux/minimal-bootstrap/bzip2/default.nix
diff options
context:
space:
mode:
authorEmily Trau <emily@downunderctf.com>2023-05-22 14:58:11 +1000
committerEmily Trau <emily@downunderctf.com>2023-05-22 22:42:26 +1000
commit27cba6ca2e190acd655f2abd77a81c9ccfdbf383 (patch)
tree5373e909745b82016f6b35920ef507c39dca75ec /pkgs/os-specific/linux/minimal-bootstrap/bzip2/default.nix
parentd8e94638d1082e9d8c78e2b548b26fef2d46638c (diff)
downloadnixpkgs-27cba6ca2e190acd655f2abd77a81c9ccfdbf383.tar
nixpkgs-27cba6ca2e190acd655f2abd77a81c9ccfdbf383.tar.gz
nixpkgs-27cba6ca2e190acd655f2abd77a81c9ccfdbf383.tar.bz2
nixpkgs-27cba6ca2e190acd655f2abd77a81c9ccfdbf383.tar.lz
nixpkgs-27cba6ca2e190acd655f2abd77a81c9ccfdbf383.tar.xz
nixpkgs-27cba6ca2e190acd655f2abd77a81c9ccfdbf383.tar.zst
nixpkgs-27cba6ca2e190acd655f2abd77a81c9ccfdbf383.zip
minimal-bootstrap.bzip2: init at 1.0.8
Diffstat (limited to 'pkgs/os-specific/linux/minimal-bootstrap/bzip2/default.nix')
-rw-r--r--pkgs/os-specific/linux/minimal-bootstrap/bzip2/default.nix70
1 files changed, 70 insertions, 0 deletions
diff --git a/pkgs/os-specific/linux/minimal-bootstrap/bzip2/default.nix b/pkgs/os-specific/linux/minimal-bootstrap/bzip2/default.nix
new file mode 100644
index 00000000000..cce36a22950
--- /dev/null
+++ b/pkgs/os-specific/linux/minimal-bootstrap/bzip2/default.nix
@@ -0,0 +1,70 @@
+{ lib
+, fetchurl
+, bash
+, tinycc
+, gnumake
+, gnupatch
+, gzip
+}:
+let
+  pname = "bzip2";
+  version = "1.0.8";
+
+  src = fetchurl {
+    url = "https://sourceware.org/pub/bzip2/bzip2-${version}.tar.gz";
+    sha256 = "0s92986cv0p692icqlw1j42y9nld8zd83qwhzbqd61p1dqbh6nmb";
+  };
+
+  patches = [
+    # mes libc has no time support, so we remove that.
+    # It also does not have fch{own,mod}, which we don't care about in the bootstrap
+    # anyway, so we can null-op those calls.
+    (fetchurl {
+      url = "https://github.com/fosslinux/live-bootstrap/raw/87e9d7db9d22b400d1c05247254ac39ee2577e80/sysa/bzip2-1.0.8/patches/mes-libc.patch";
+      sha256 = "14dciwib28h413skzfkh7samzh8x87dmwhldyxxphff04pvl1j3c";
+    })
+  ];
+in
+bash.runCommand "${pname}-${version}" {
+  inherit pname version;
+
+  nativeBuildInputs = [
+    tinycc.compiler
+    gnumake
+    gnupatch
+    gzip
+  ];
+
+  passthru.tests.get-version = result:
+    bash.runCommand "${pname}-get-version-${version}" {} ''
+      ${result}/bin/bzip2 --version --help
+      mkdir $out
+    '';
+
+  meta = with lib; {
+    description = "High-quality data compression program";
+    homepage = "https://www.sourceware.org/bzip2";
+    license = licenses.bsdOriginal;
+    maintainers = teams.minimal-bootstrap.members;
+    platforms = platforms.unix;
+  };
+} ''
+  # Unpack
+  cp ${src} bzip2.tar.gz
+  gunzip bzip2.tar.gz
+  untar --file bzip2.tar
+  rm bzip2.tar
+  cd bzip2-${version}
+
+  # Patch
+  ${lib.concatMapStringsSep "\n" (f: "patch -Np0 -i ${f}") patches}
+
+  # Build
+  make \
+    CC="tcc -static -B ${tinycc.libs}/lib -I ." \
+    AR="tcc -ar" \
+    bzip2 bzip2recover
+
+  # Install
+  make install PREFIX=$out
+''