Gaetan Lepage
2025-05-28 00:46:46 +02:00
co-authored by r-vdp
parent 0d247fe769
commit c3e984041f
2 changed files with 84 additions and 3 deletions
+47 -3
View File
@@ -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;
@@ -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)