python312Packages.libpwquality: fix build (#355674)

This commit is contained in:
Aleksana 2024-11-24 21:55:33 +08:00 committed by GitHub
commit 23605324ae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 80 additions and 25 deletions

View File

@ -1,14 +1,15 @@
{ stdenv {
, lib stdenv,
, fetchFromGitHub lib,
, fetchpatch fetchFromGitHub,
, autoreconfHook fetchpatch,
, perl autoreconfHook,
, cracklib perl,
, enablePAM ? stdenv.hostPlatform.isLinux cracklib,
, pam enablePAM ? stdenv.hostPlatform.isLinux,
, enablePython ? false pam,
, python enablePython ? false,
python,
}: }:
# python binding generates a shared library which are unavailable with musl build # python binding generates a shared library which are unavailable with musl build
@ -18,7 +19,12 @@ stdenv.mkDerivation rec {
pname = "libpwquality"; pname = "libpwquality";
version = "1.4.5"; version = "1.4.5";
outputs = [ "out" "dev" "lib" "man" ] ++ lib.optionals enablePython [ "py" ]; outputs = [
"out"
"dev"
"lib"
"man"
] ++ lib.optionals enablePython [ "py" ];
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "libpwquality"; owner = "libpwquality";
@ -27,21 +33,53 @@ stdenv.mkDerivation rec {
sha256 = "sha256-YjvHzd4iEBvg+qHOVJ7/y9HqyeT+QDalNE/jdNM9BNs="; sha256 = "sha256-YjvHzd4iEBvg+qHOVJ7/y9HqyeT+QDalNE/jdNM9BNs=";
}; };
patches = [ patches =
# ensure python site-packages goes in $py output lib.optionals (!enablePython) [
./python-binding-prefix.patch # this patch isn't useful but keeping it to avoid rebuilds on !enablePython
# before 24.11 fully lands
./python-binding-prefix.patch
]
++ [
# remove next release
(fetchpatch {
name = "musl.patch";
url = "https://github.com/libpwquality/libpwquality/commit/b0fcd96954be89e8c318e5328dd27c40b401de96.patch";
hash = "sha256-ykN1hcRKyX3QAqWTH54kUjOxN6+IwRpqQVsujTd9XWs=";
})
]
++ lib.optionals enablePython [
# remove next release
(fetchpatch {
name = "pr-74-use-setuptools-instead-of-distutils.patch";
url = "https://github.com/libpwquality/libpwquality/commit/509b0a744adf533b524daaa65f25dda144a6ff40.patch";
hash = "sha256-AxiynPVxv/gONujyj8y6b1XlsNkKszzW5TT9oINR/oo=";
})
# remove next release
(fetchpatch {
name = "pr-80-respect-pythonsitedir.patch";
url = "https://github.com/libpwquality/libpwquality/commit/f92351b3998542e33d2b243fc446a4dd852dc972.patch";
hash = "sha256-1lmigZX/UiEFe9b0JXmlfw/371UYT4PF7Ev2Hv66v74=";
})
# ensure python site-packages goes in $py output
./python-binding-root.patch
];
(fetchpatch { nativeBuildInputs = [
name = "musl.patch"; autoreconfHook
url = "https://github.com/libpwquality/libpwquality/commit/b0fcd96954be89e8c318e5328dd27c40b401de96.patch"; perl
hash = "sha256-ykN1hcRKyX3QAqWTH54kUjOxN6+IwRpqQVsujTd9XWs="; ] ++ lib.optionals enablePython [ (python.withPackages (ps: with ps; [ setuptools ])) ];
})
];
nativeBuildInputs = [ autoreconfHook perl ] ++ lib.optionals enablePython [ (python.withPackages (ps: with ps; [ distutils ])) ];
buildInputs = [ cracklib ] ++ lib.optionals enablePAM [ pam ]; buildInputs = [ cracklib ] ++ lib.optionals enablePAM [ pam ];
configureFlags = lib.optionals (!enablePython) [ "--disable-python-bindings" ]; configureFlags =
if enablePython then
[
"--enable-python-bindings=yes"
"--with-pythonsitedir=\"${python.sitePackages}\""
]
else
# change to `--enable-python-bindings=no` in the future
# leave for now to avoid rebuilds on !enablePython before 24.11 fully lands
[ "--disable-python-bindings" ];
meta = with lib; { meta = with lib; {
homepage = "https://github.com/libpwquality/libpwquality"; homepage = "https://github.com/libpwquality/libpwquality";
@ -57,7 +95,11 @@ stdenv.mkDerivation rec {
function and PAM module that can be used instead of pam_cracklib. The function and PAM module that can be used instead of pam_cracklib. The
module supports all the options of pam_cracklib. module supports all the options of pam_cracklib.
''; '';
license = with licenses; [ bsd3 /* or */ gpl2Plus ]; license = with licenses; [
bsd3
# or
gpl2Plus
];
maintainers = with maintainers; [ jk ]; maintainers = with maintainers; [ jk ];
platforms = platforms.unix; platforms = platforms.unix;
}; };

View File

@ -0,0 +1,13 @@
diff --git a/python/Makefile.am b/python/Makefile.am
index 64d3892..365dc8e 100644
--- a/python/Makefile.am
+++ b/python/Makefile.am
@@ -14,7 +14,7 @@ all-local:
CFLAGS="${CFLAGS} -fno-strict-aliasing" @PYTHONBINARY@ setup.py build --build-base py$(PYTHONREV)
install-exec-local:
- CFLAGS="${CFLAGS} -fno-strict-aliasing" @PYTHONBINARY@ setup.py build --build-base py$(PYTHONREV) install --root ${DESTDIR} --prefix=${prefix} --install-lib=$(pythonsitedir)
+ CFLAGS="${CFLAGS} -fno-strict-aliasing" @PYTHONBINARY@ setup.py build --build-base py$(PYTHONREV) install --root ${py} --install-lib=$(pythonsitedir)
clean-local:
rm -rf py$(PYTHONREV)