3
0
Fork 0
forked from mirrors/nixpkgs

samba: add darwin support (#207465)

This commit is contained in:
Weijia Wang 2023-01-03 23:16:35 +01:00 committed by GitHub
parent c4abc231be
commit 5f40e9e178
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 12 deletions

View file

@ -18,7 +18,6 @@
, zlib
, liburing
, gnutls
, libunwind
, systemd
, samba
, jansson
@ -41,6 +40,7 @@
, enableCephFS ? false, ceph
, enableGlusterFS ? false, glusterfs, libuuid
, enableAcl ? (!stdenv.isDarwin), acl
, enableLibunwind ? (!stdenv.isDarwin), libunwind
, enablePam ? (!stdenv.isDarwin), pam
}:
@ -75,11 +75,12 @@ stdenv.mkDerivation rec {
perl.pkgs.ParseYapp
perl.pkgs.JSON
libxslt
buildPackages.stdenv.cc
docbook_xsl
docbook_xml_dtd_45
cmocka
rpcsvc-proto
] ++ optionals stdenv.isLinux [
buildPackages.stdenv.cc
] ++ optional (stdenv.buildPlatform != stdenv.hostPlatform) samba # asn1_compile/compile_et
++ optionals stdenv.isDarwin [
fixDarwinDylibNames
@ -98,7 +99,6 @@ stdenv.mkDerivation rec {
libbsd
libarchive
zlib
libunwind
gnutls
libtasn1
tdb
@ -113,6 +113,7 @@ stdenv.mkDerivation rec {
++ optional (enableCephFS && stdenv.isLinux) (lib.getDev ceph)
++ optionals (enableGlusterFS && stdenv.isLinux) [ glusterfs libuuid ]
++ optional enableAcl acl
++ optional enableLibunwind libunwind
++ optional enablePam pam;
postPatch = ''
@ -133,7 +134,6 @@ stdenv.mkDerivation rec {
wafConfigureFlags = [
"--with-static-modules=NONE"
"--with-shared-modules=ALL"
"--with-libunwind"
"--enable-fhs"
"--sysconfdir=/etc"
"--localstatedir=/var"
@ -143,7 +143,8 @@ stdenv.mkDerivation rec {
++ optionals (!enableLDAP) [
"--without-ldap"
"--without-ads"
] ++ optional enableProfiling "--with-profiling-data"
] ++ optional enableLibunwind "--with-libunwind"
++ optional enableProfiling "--with-profiling-data"
++ optional (!enableAcl) "--without-acl-support"
++ optional (!enablePam) "--without-pam"
++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
@ -175,16 +176,25 @@ stdenv.mkDerivation rec {
# Use find -type f -executable -exec echo {} \; -exec sh -c 'ldd {} | grep "not found"' \;
# Looks like a bug in installer scripts.
postFixup = ''
export SAMBA_LIBS="$(find $out -type f -regex '.*\.so\(\..*\)?' -exec dirname {} \; | sort | uniq)"
export SAMBA_LIBS="$(find $out -type f -regex '.*\${stdenv.hostPlatform.extensions.sharedLibrary}\(\..*\)?' -exec dirname {} \; | sort | uniq)"
read -r -d "" SCRIPT << EOF || true
[ -z "\$SAMBA_LIBS" ] && exit 1;
BIN='{}';
'' + lib.optionalString stdenv.isLinux ''
OLD_LIBS="\$(patchelf --print-rpath "\$BIN" 2>/dev/null | tr ':' '\n')";
ALL_LIBS="\$(echo -e "\$SAMBA_LIBS\n\$OLD_LIBS" | sort | uniq | tr '\n' ':')";
patchelf --set-rpath "\$ALL_LIBS" "\$BIN" 2>/dev/null || exit $?;
patchelf --shrink-rpath "\$BIN";
'' + lib.optionalString stdenv.isDarwin ''
install_name_tool -id \$BIN \$BIN
for old_rpath in \$(otool -L \$BIN | grep /private/tmp/ | awk '{print \$1}'); do
new_rpath=\$(find \$SAMBA_LIBS -name \$(basename \$old_rpath) | head -n 1)
install_name_tool -change \$old_rpath \$new_rpath \$BIN
done
'' + ''
EOF
find $out -type f -regex '.*\.so\(\..*\)?' -exec $SHELL -c "$SCRIPT" \;
find $out -type f -regex '.*\${stdenv.hostPlatform.extensions.sharedLibrary}\(\..*\)?' -exec $SHELL -c "$SCRIPT" \;
find $out/bin -type f -exec $SHELL -c "$SCRIPT" \;
# Fix PYTHONPATH for some tools
wrapPythonPrograms
@ -209,10 +219,7 @@ stdenv.mkDerivation rec {
description = "The standard Windows interoperability suite of programs for Linux and Unix";
license = licenses.gpl3;
platforms = platforms.unix;
# N.B. enableGlusterFS does not build
# TODO: darwin support needs newer SDK for "_futimens" and "_utimensat"
# see https://github.com/NixOS/nixpkgs/issues/101229
broken = stdenv.isDarwin || enableGlusterFS;
broken = enableGlusterFS;
maintainers = with maintainers; [ aneeshusa ];
};
}

View file

@ -24794,7 +24794,7 @@ with pkgs;
deadpixi-sam-unstable = callPackage ../applications/editors/deadpixi-sam { };
samba4 = callPackage ../servers/samba/4.x.nix { };
samba4 = darwin.apple_sdk_11_0.callPackage ../servers/samba/4.x.nix { };
samba = samba4;