From 118e531c2d1b80389a69fce0a24c0258fff2e5a7 Mon Sep 17 00:00:00 2001 From: Ben Wolsieffer Date: Sun, 13 Nov 2022 17:38:56 -0500 Subject: samba: fix cross-compilation The last update mistakenly removed wafHook and the patch required to make cross- compilation work. In addition, the bundled version of heimdal is now too new to work with asn1_compile from the heimdal package in nixpkgs (it isn't out of date, there just hasn't been a release in years and samba uses an unreleased version). To fix the latter issue, the native build of samba saves asn1_compile and compile_et from the bundled heimdal into the dev output, allowing them to be available at build time when cross-compiling. --- pkgs/servers/samba/4.x.nix | 23 +++++- ...pre-built-heimdal-build-tools-in-case-of-.patch | 95 ++++++++++++++++++++++ 2 files changed, 114 insertions(+), 4 deletions(-) create mode 100644 pkgs/servers/samba/build-find-pre-built-heimdal-build-tools-in-case-of-.patch (limited to 'pkgs/servers/samba') diff --git a/pkgs/servers/samba/4.x.nix b/pkgs/servers/samba/4.x.nix index 27c5282fe285d..7faccdba00edd 100644 --- a/pkgs/servers/samba/4.x.nix +++ b/pkgs/servers/samba/4.x.nix @@ -1,12 +1,12 @@ { lib, stdenv , buildPackages , fetchurl +, wafHook , pkg-config , bison , flex , perl , libxslt -, heimdal , docbook_xsl , fixDarwinDylibNames , docbook_xml_dtd_45 @@ -20,9 +20,11 @@ , gnutls , libunwind , systemd +, samba , jansson , libtasn1 , tdb +, libxcrypt , cmocka , rpcsvc-proto , bash @@ -59,10 +61,12 @@ stdenv.mkDerivation rec { ./patch-source3__libads__kerberos_keytab.c.patch ./4.x-no-persistent-install-dynconfig.patch ./4.x-fix-makeflags-parsing.patch + ./build-find-pre-built-heimdal-build-tools-in-case-of-.patch ]; nativeBuildInputs = [ python3Packages.python + wafHook pkg-config bison flex @@ -71,15 +75,17 @@ stdenv.mkDerivation rec { perl.pkgs.JSON libxslt buildPackages.stdenv.cc - heimdal docbook_xsl docbook_xml_dtd_45 cmocka rpcsvc-proto - ] ++ optionals stdenv.isDarwin [ + ] ++ optional (stdenv.buildPlatform != stdenv.hostPlatform) samba # asn1_compile/compile_et + ++ optionals stdenv.isDarwin [ fixDarwinDylibNames ]; + wafPath = "buildtools/bin/waf"; + buildInputs = [ bash python3Packages.wrapPython @@ -95,6 +101,7 @@ stdenv.mkDerivation rec { gnutls libtasn1 tdb + libxcrypt ] ++ optionals stdenv.isLinux [ liburing systemd ] ++ optionals enableLDAP [ openldap.dev python3Packages.markdown ] ++ optional (enablePrinting && stdenv.isLinux) cups @@ -118,9 +125,10 @@ stdenv.mkDerivation rec { preConfigure = '' export PKGCONFIG="$PKG_CONFIG" + export PYTHONHASHSEED=1 ''; - configureFlags = [ + wafConfigureFlags = [ "--with-static-modules=NONE" "--with-shared-modules=ALL" "--enable-fhs" @@ -153,6 +161,13 @@ stdenv.mkDerivation rec { export MAKEFLAGS="-j $NIX_BUILD_CORES" ''; + # Save asn1_compile and compile_et so they are available to run on the build + # platform when cross-compiling + postInstall = optionalString (stdenv.hostPlatform == stdenv.buildPlatform) '' + mkdir -p "$dev/bin" + cp bin/asn1_compile bin/compile_et "$dev/bin" + ''; + # Some libraries don't have /lib/samba in RPATH but need it. # Use find -type f -executable -exec echo {} \; -exec sh -c 'ldd {} | grep "not found"' \; # Looks like a bug in installer scripts. diff --git a/pkgs/servers/samba/build-find-pre-built-heimdal-build-tools-in-case-of-.patch b/pkgs/servers/samba/build-find-pre-built-heimdal-build-tools-in-case-of-.patch new file mode 100644 index 0000000000000..60b215b718f79 --- /dev/null +++ b/pkgs/servers/samba/build-find-pre-built-heimdal-build-tools-in-case-of-.patch @@ -0,0 +1,95 @@ +From 9287fcfc36ed9f2bb936ec2253244f60df80711f Mon Sep 17 00:00:00 2001 +From: Pascal Bach +Date: Wed, 22 Sep 2021 09:42:42 +0200 +Subject: [PATCH] build: find pre-built heimdal build tools in case of embedded + heimdal + +This patch fixes the case of finding asn1_compile and compile_et for +building embedded heimdal, by setting +--bundled-libraries='!asn1_compile,!compile_et' as configure flags. + +The Heimdal build tools compile_et and asn1_compile are needed *only* +if we use the embedded heimdal (otherwise we don't build heimdal and +use headers that have been generated by those tools elsewhere). + +For cross-compilation with embedded heimdal, it is vital to use host build +tools, and so asn1_compile and compile_et must be supplied and not +built. One way of doing this would be to set the COMPILE_ET and +ASN1_COMPILE env vars to the location of supplied binaries. Another way, +which is more commonly used, is to exclude asn1_compile and compile_et +from bundled packages via the switch +-bundled-libraries='!asn1_compile,!compile_et'. When this is done, +the build script searches the path for those tools and sets the +ASN1_COMPILE and COMPILE_ET vars accordingly. (this is admittedly +kind of a round-about way of doing things but this has become the +de-facto standard amongst embedded distro builders). + +In commit 8061983d4882f3ba3f12da71443b035d7b672eec, this process of +finding the binaris has been moved to be carried out only in the +system heimdal case. As explained above, we only need these tools, +and hence the check, in bundled mode. + +BUG: https://bugzilla.samba.org/show_bug.cgi?id=14164 + +Signed-off-by: Uri Simchoni +Signed-off-by: Bernd Kuhls +[Bachp: rebased for version 4.15.0] + +# Conflicts: +# wscript_configure_system_heimdal +--- + wscript_configure_embedded_heimdal | 11 +++++++++++ + wscript_configure_system_heimdal | 11 ----------- + 2 files changed, 11 insertions(+), 11 deletions(-) + +diff --git a/wscript_configure_embedded_heimdal b/wscript_configure_embedded_heimdal +index 6066f2b39d7..e92cabad65f 100644 +--- a/wscript_configure_embedded_heimdal ++++ b/wscript_configure_embedded_heimdal +@@ -6,3 +6,14 @@ if not conf.env['BISON']: + + conf.define('USING_EMBEDDED_HEIMDAL', 1) + conf.RECURSE('third_party/heimdal_build') ++ ++def check_system_heimdal_binary(name): ++ if conf.LIB_MAY_BE_BUNDLED(name): ++ return False ++ if not conf.find_program(name, var=name.upper()): ++ return False ++ conf.define('USING_SYSTEM_%s' % name.upper(), 1) ++ return True ++ ++check_system_heimdal_binary("compile_et") ++check_system_heimdal_binary("asn1_compile") +diff --git a/wscript_configure_system_heimdal b/wscript_configure_system_heimdal +index 6033dad08dc..c0a9bb95e87 100644 +--- a/wscript_configure_system_heimdal ++++ b/wscript_configure_system_heimdal +@@ -37,14 +37,6 @@ def check_system_heimdal_lib(name, functions='', headers='', onlyif=None): + conf.define('USING_SYSTEM_%s' % name.upper(), 1) + return True + +-def check_system_heimdal_binary(name): +- if conf.LIB_MAY_BE_BUNDLED(name): +- return False +- if not conf.find_program(name, var=name.upper()): +- return False +- conf.define('USING_SYSTEM_%s' % name.upper(), 1) +- return True +- + check_system_heimdal_lib("com_err", "com_right_r com_err", "com_err.h") + + if check_system_heimdal_lib("roken", "rk_socket_set_reuseaddr", "roken.h"): +@@ -86,9 +78,6 @@ finally: + #if conf.CHECK_BUNDLED_SYSTEM('tommath', checkfunctions='mp_init', headers='tommath.h'): + # conf.define('USING_SYSTEM_TOMMATH', 1) + +-check_system_heimdal_binary("compile_et") +-check_system_heimdal_binary("asn1_compile") +- + conf.env.KRB5_VENDOR = 'heimdal' + conf.define('USING_SYSTEM_KRB5', 1) + conf.define('USING_SYSTEM_HEIMDAL', 1) +-- +2.37.3 + -- cgit 1.4.1