Merge pull request #133768 from stigtsp/package/perl-mod_perl2-2.0.11-patch1

perlPackages.mod_perl2: fix build on perl-5.34.0, add nixos test
This commit is contained in:
Stig 2021-08-16 12:20:59 +02:00 committed by GitHub
commit 7d5b6f0fa2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 84 additions and 1 deletions

View file

@ -259,6 +259,7 @@ in
miniflux = handleTest ./miniflux.nix {};
minio = handleTest ./minio.nix {};
misc = handleTest ./misc.nix {};
mod_perl = handleTest ./mod_perl.nix {};
moinmoin = handleTest ./moinmoin.nix {};
mongodb = handleTest ./mongodb.nix {};
moodle = handleTest ./moodle.nix {};

53
nixos/tests/mod_perl.nix Normal file
View file

@ -0,0 +1,53 @@
import ./make-test-python.nix ({ pkgs, lib, ... }: {
name = "mod_perl";
meta = with pkgs.lib.maintainers; {
maintainers = [ sgo ];
};
machine = { config, lib, pkgs, ... }: {
services.httpd = {
enable = true;
adminAddr = "admin@localhost";
virtualHosts."modperl" =
let
inc = pkgs.writeTextDir "ModPerlTest.pm" ''
package ModPerlTest;
use strict;
use Apache2::RequestRec ();
use Apache2::RequestIO ();
use Apache2::Const -compile => qw(OK);
sub handler {
my $r = shift;
$r->content_type('text/plain');
print "Hello mod_perl!\n";
return Apache2::Const::OK;
}
1;
'';
startup = pkgs.writeScript "startup.pl" ''
use lib "${inc}",
split ":","${with pkgs.perl.pkgs; makeFullPerlPath ([ mod_perl2 ])}";
1;
'';
in
{
extraConfig = ''
PerlRequire ${startup}
'';
locations."/modperl" = {
extraConfig = ''
SetHandler perl-script
PerlResponseHandler ModPerlTest
'';
};
};
enablePerl = true;
};
};
testScript = { ... }: ''
machine.wait_for_unit("httpd.service")
response = machine.succeed("curl -fvvv -s http://127.0.0.1:80/modperl")
assert "Hello mod_perl!" in response, "/modperl handler did not respond"
'';
})

View file

@ -0,0 +1,13 @@
From https://github.com/Perl/perl5/issues/18617#issuecomment-822056978 by Leont
--- a/src/modules/perl/modperl_perl.c
+++ a/src/modules/perl/modperl_perl.c
@@ -268,7 +268,7 @@
#ifdef MP_NEED_HASH_SEED_FIXUP
if (MP_init_hash_seed_set) {
#if MP_PERL_VERSION_AT_LEAST(5, 17, 6)
- memcpy(&PL_hash_seed, &MP_init_hash_seed,
+ memcpy(PL_hash_seed, &MP_init_hash_seed,
sizeof(PL_hash_seed) > sizeof(MP_init_hash_seed) ?
sizeof(MP_init_hash_seed) : sizeof(PL_hash_seed));
PL_hash_seed_set = MP_init_hash_seed_set;

View file

@ -1,4 +1,4 @@
{ stdenv, fetchurl, apacheHttpd, perl }:
{ stdenv, fetchurl, apacheHttpd, perl, nixosTests }:
stdenv.mkDerivation rec {
pname = "mod_perl";
@ -9,6 +9,11 @@ stdenv.mkDerivation rec {
sha256 = "0x3gq4nz96y202cymgrf56n8spm7bffkd1p74dh9q3zrrlc9wana";
};
patches = [
# Fix build on perl-5.34.0, https://github.com/Perl/perl5/issues/18617
../../../../development/perl-modules/mod_perl2-PL_hash_seed.patch
];
buildInputs = [ apacheHttpd perl ];
buildPhase = ''
perl Makefile.PL \
@ -23,4 +28,6 @@ stdenv.mkDerivation rec {
mv $out${perl}/* $out
rm $out/nix -rf
'';
passthru.tests = nixosTests.mod_perl;
}

View file

@ -9,6 +9,7 @@
, stdenv, lib, buildPackages, pkgs
, fetchurl, fetchgit, fetchpatch, fetchFromGitHub
, perl, overrides, buildPerl, shortenPerlShebang
, nixosTests
}:
# cpan2nix assumes that perl-packages.nix will be used only with perl 5.30.3 or above
@ -13721,6 +13722,12 @@ let
url = "mirror://cpan/authors/id/S/SH/SHAY/mod_perl-2.0.11.tar.gz";
sha256 = "0x3gq4nz96y202cymgrf56n8spm7bffkd1p74dh9q3zrrlc9wana";
};
patches = [
# Fix build on perl-5.34.0, https://github.com/Perl/perl5/issues/18617
../development/perl-modules/mod_perl2-PL_hash_seed.patch
];
makeMakerFlags = "MP_AP_DESTDIR=$out";
buildInputs = [ pkgs.apacheHttpd ];
doCheck = false; # would try to start Apache HTTP server
@ -13728,6 +13735,8 @@ let
description = "Embed a Perl interpreter in the Apache HTTP server";
license = lib.licenses.asl20;
};
passthru.tests = nixosTests.mod_perl;
};
Mojolicious = buildPerlPackage {