From c3e984041f4a8a08c8b73bcc31aaa084aaecab69 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Sun, 25 May 2025 02:28:03 +0200 Subject: [PATCH] uutils-coreutils: 0.0.30 -> 0.1.0 Diff: https://github.com/uutils/coreutils/compare/refs/tags/0.0.30...refs/tags/0.1.0 Changelog: https://github.com/uutils/coreutils/releases/tag/0.1.0 Co-authored-by: r-vdp --- pkgs/by-name/uu/uutils-coreutils/package.nix | 50 +++++++++++++++++-- .../selinux_no_auto_detect.diff | 37 ++++++++++++++ 2 files changed, 84 insertions(+), 3 deletions(-) create mode 100644 pkgs/by-name/uu/uutils-coreutils/selinux_no_auto_detect.diff diff --git a/pkgs/by-name/uu/uutils-coreutils/package.nix b/pkgs/by-name/uu/uutils-coreutils/package.nix index 6c4929e771c4..f02730ad88d1 100644 --- a/pkgs/by-name/uu/uutils-coreutils/package.nix +++ b/pkgs/by-name/uu/uutils-coreutils/package.nix @@ -10,26 +10,46 @@ prefix ? "uutils-", buildMulticallBinary ? true, + + selinuxSupport ? false, + libselinux, + + acl, }: +assert selinuxSupport -> lib.meta.availableOn stdenv.hostPlatform libselinux; + stdenv.mkDerivation (finalAttrs: { pname = "uutils-coreutils"; - version = "0.0.30"; + version = "0.1.0"; src = fetchFromGitHub { owner = "uutils"; repo = "coreutils"; tag = finalAttrs.version; - hash = "sha256-OZ9AsCJmQmn271OzEmqSZtt1OPn7zHTScQiiqvPhqB0="; + hash = "sha256-nKKjc6Bui7k50SR7BY09dRGt3Za1Ch/E+3KiCO5KtOg="; }; cargoDeps = rustPlatform.fetchCargoVendor { inherit (finalAttrs) src; name = "uutils-coreutils-${finalAttrs.version}"; - hash = "sha256-DsVLp2Y15k+KQI7S6A4hylOhJN016MEdEWx9VQIQEgQ="; + hash = "sha256-PTIypl9uqFkp6GrF7Pp40AItbWFlXT2V2x/C8L2J8S0="; }; + patches = [ + ./selinux_no_auto_detect.diff + ]; + + buildInputs = + lib.optionals (lib.meta.availableOn stdenv.hostPlatform acl) [ + acl + ] + ++ lib.optionals selinuxSupport [ + libselinux + ]; + nativeBuildInputs = [ + rustPlatform.bindgenHook rustPlatform.cargoSetupHook python3Packages.sphinx ]; @@ -39,11 +59,35 @@ stdenv.mkDerivation (finalAttrs: { "CARGO=${lib.getExe cargo}" "PREFIX=${placeholder "out"}" "PROFILE=release" + "SELINUX_ENABLED=${if selinuxSupport then "1" else "0"}" "INSTALLDIR_MAN=${placeholder "out"}/share/man/man1" + # Explicitly enable acl, and if requested selinux. + # We cannot rely on SELINUX_ENABLED here since our explicit assignment + # overrides its effect in the makefile. + "BUILD_SPEC_FEATURE=${ + lib.concatStringsSep "," ( + # We can always enable acl, on non-Linux, libc provides the headers, + # only in Linux we need to add the acl lib to buildInputs. + [ + "feat_acl" + ] + ++ (lib.optionals selinuxSupport [ + "feat_selinux" + ]) + ) + }" ] ++ lib.optionals (prefix != null) [ "PROG_PREFIX=${prefix}" ] ++ lib.optionals buildMulticallBinary [ "MULTICALL=y" ]; + env = lib.optionalAttrs selinuxSupport { + SELINUX_INCLUDE_DIR = ''${libselinux.dev}/include''; + SELINUX_LIB_DIR = lib.makeLibraryPath [ + libselinux + ]; + SELINUX_STATIC = "0"; + }; + # too many impure/platform-dependent tests doCheck = false; diff --git a/pkgs/by-name/uu/uutils-coreutils/selinux_no_auto_detect.diff b/pkgs/by-name/uu/uutils-coreutils/selinux_no_auto_detect.diff new file mode 100644 index 000000000000..1ee8a0550bf9 --- /dev/null +++ b/pkgs/by-name/uu/uutils-coreutils/selinux_no_auto_detect.diff @@ -0,0 +1,37 @@ +diff --git a/GNUmakefile b/GNUmakefile +index f46126a82..44be8f13b 100644 +--- a/GNUmakefile ++++ b/GNUmakefile +@@ -57,20 +57,6 @@ TOYBOX_ROOT := $(BASEDIR)/tmp + TOYBOX_VER := 0.8.12 + TOYBOX_SRC := $(TOYBOX_ROOT)/toybox-$(TOYBOX_VER) + +- +-ifdef SELINUX_ENABLED +- override SELINUX_ENABLED := 0 +-# Now check if we should enable it (only on non-Windows) +- ifneq ($(OS),Windows_NT) +- ifeq ($(shell if [ -x /sbin/selinuxenabled ] && /sbin/selinuxenabled 2>/dev/null; then echo 0; else echo 1; fi),0) +- override SELINUX_ENABLED := 1 +-$(info /sbin/selinuxenabled successful) +- else +-$(info SELINUX_ENABLED=1 but /sbin/selinuxenabled failed) +- endif +- endif +-endif +- + # Possible programs + PROGS := \ + base32 \ +@@ -181,8 +167,10 @@ SELINUX_PROGS := \ + + ifneq ($(OS),Windows_NT) + PROGS := $(PROGS) $(UNIX_PROGS) ++ ifeq ($(SELINUX_ENABLED),1) + # Build the selinux command even if not on the system +- PROGS := $(PROGS) $(SELINUX_PROGS) ++ PROGS := $(PROGS) $(SELINUX_PROGS) ++ endif + endif + + UTILS ?= $(PROGS)