0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-13 13:40:28 +03:00

Merge pull request #263550 from anthonyroussel/updates/axis2

axis2: 1.7.9 -> 1.8.2, tomcat10: 10.0.27 -> 10.1.15, tomcat9: 9.0.75 -> 9.0.82
This commit is contained in:
Mario Rodas 2023-11-19 09:39:19 -05:00 committed by GitHub
commit d3deaacfb4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 103 additions and 112 deletions

View file

@ -1,7 +1,5 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.services.tomcat; cfg = config.services.tomcat;
@ -9,30 +7,20 @@ let
in in
{ {
meta = { meta = {
maintainers = with maintainers; [ danbst ]; maintainers = with lib.maintainers; [ danbst ];
}; };
###### interface ###### interface
options = { options = {
services.tomcat = { services.tomcat = {
enable = mkEnableOption (lib.mdDoc "Apache Tomcat"); enable = lib.mkEnableOption (lib.mdDoc "Apache Tomcat");
package = mkOption { package = lib.mkPackageOptionMD pkgs "tomcat9" { };
type = types.package;
default = pkgs.tomcat9;
defaultText = literalExpression "pkgs.tomcat9";
example = lib.literalExpression "pkgs.tomcat9";
description = lib.mdDoc ''
Which tomcat package to use.
'';
};
purifyOnStart = mkOption { purifyOnStart = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = lib.mdDoc '' description = lib.mdDoc ''
On startup, the `baseDir` directory is populated with various files, On startup, the `baseDir` directory is populated with various files,
@ -43,7 +31,7 @@ in
''; '';
}; };
baseDir = mkOption { baseDir = lib.mkOption {
type = lib.types.path; type = lib.types.path;
default = "/var/tomcat"; default = "/var/tomcat";
description = lib.mdDoc '' description = lib.mdDoc ''
@ -53,64 +41,64 @@ in
''; '';
}; };
logDirs = mkOption { logDirs = lib.mkOption {
default = []; default = [ ];
type = types.listOf types.path; type = lib.types.listOf lib.types.path;
description = lib.mdDoc "Directories to create in baseDir/logs/"; description = lib.mdDoc "Directories to create in baseDir/logs/";
}; };
extraConfigFiles = mkOption { extraConfigFiles = lib.mkOption {
default = []; default = [ ];
type = types.listOf types.path; type = lib.types.listOf lib.types.path;
description = lib.mdDoc "Extra configuration files to pull into the tomcat conf directory"; description = lib.mdDoc "Extra configuration files to pull into the tomcat conf directory";
}; };
extraEnvironment = mkOption { extraEnvironment = lib.mkOption {
type = types.listOf types.str; type = lib.types.listOf lib.types.str;
default = []; default = [ ];
example = [ "ENVIRONMENT=production" ]; example = [ "ENVIRONMENT=production" ];
description = lib.mdDoc "Environment Variables to pass to the tomcat service"; description = lib.mdDoc "Environment Variables to pass to the tomcat service";
}; };
extraGroups = mkOption { extraGroups = lib.mkOption {
default = []; default = [ ];
type = types.listOf types.str; type = lib.types.listOf lib.types.str;
example = [ "users" ]; example = [ "users" ];
description = lib.mdDoc "Defines extra groups to which the tomcat user belongs."; description = lib.mdDoc "Defines extra groups to which the tomcat user belongs.";
}; };
user = mkOption { user = lib.mkOption {
type = types.str; type = lib.types.str;
default = "tomcat"; default = "tomcat";
description = lib.mdDoc "User account under which Apache Tomcat runs."; description = lib.mdDoc "User account under which Apache Tomcat runs.";
}; };
group = mkOption { group = lib.mkOption {
type = types.str; type = lib.types.str;
default = "tomcat"; default = "tomcat";
description = lib.mdDoc "Group account under which Apache Tomcat runs."; description = lib.mdDoc "Group account under which Apache Tomcat runs.";
}; };
javaOpts = mkOption { javaOpts = lib.mkOption {
type = types.either (types.listOf types.str) types.str; type = lib.types.either (lib.types.listOf lib.types.str) lib.types.str;
default = ""; default = "";
description = lib.mdDoc "Parameters to pass to the Java Virtual Machine which spawns Apache Tomcat"; description = lib.mdDoc "Parameters to pass to the Java Virtual Machine which spawns Apache Tomcat";
}; };
catalinaOpts = mkOption { catalinaOpts = lib.mkOption {
type = types.either (types.listOf types.str) types.str; type = lib.types.either (lib.types.listOf lib.types.str) lib.types.str;
default = ""; default = "";
description = lib.mdDoc "Parameters to pass to the Java Virtual Machine which spawns the Catalina servlet container"; description = lib.mdDoc "Parameters to pass to the Java Virtual Machine which spawns the Catalina servlet container";
}; };
sharedLibs = mkOption { sharedLibs = lib.mkOption {
type = types.listOf types.str; type = lib.types.listOf lib.types.str;
default = []; default = [ ];
description = lib.mdDoc "List containing JAR files or directories with JAR files which are libraries shared by the web applications"; description = lib.mdDoc "List containing JAR files or directories with JAR files which are libraries shared by the web applications";
}; };
serverXml = mkOption { serverXml = lib.mkOption {
type = types.lines; type = lib.types.lines;
default = ""; default = "";
description = lib.mdDoc '' description = lib.mdDoc ''
Verbatim server.xml configuration. Verbatim server.xml configuration.
@ -118,87 +106,74 @@ in
''; '';
}; };
commonLibs = mkOption { commonLibs = lib.mkOption {
type = types.listOf types.str; type = lib.types.listOf lib.types.str;
default = []; default = [ ];
description = lib.mdDoc "List containing JAR files or directories with JAR files which are libraries shared by the web applications and the servlet container"; description = lib.mdDoc "List containing JAR files or directories with JAR files which are libraries shared by the web applications and the servlet container";
}; };
webapps = mkOption { webapps = lib.mkOption {
type = types.listOf types.path; type = lib.types.listOf lib.types.path;
default = [ tomcat.webapps ]; default = [ tomcat.webapps ];
defaultText = literalExpression "[ config.services.tomcat.package.webapps ]"; defaultText = lib.literalExpression "[ config.services.tomcat.package.webapps ]";
description = lib.mdDoc "List containing WAR files or directories with WAR files which are web applications to be deployed on Tomcat"; description = lib.mdDoc "List containing WAR files or directories with WAR files which are web applications to be deployed on Tomcat";
}; };
virtualHosts = mkOption { virtualHosts = lib.mkOption {
type = types.listOf (types.submodule { type = lib.types.listOf (lib.types.submodule {
options = { options = {
name = mkOption { name = lib.mkOption {
type = types.str; type = lib.types.str;
description = lib.mdDoc "name of the virtualhost"; description = lib.mdDoc "name of the virtualhost";
}; };
aliases = mkOption { aliases = lib.mkOption {
type = types.listOf types.str; type = lib.types.listOf lib.types.str;
description = lib.mdDoc "aliases of the virtualhost"; description = lib.mdDoc "aliases of the virtualhost";
default = []; default = [ ];
}; };
webapps = mkOption { webapps = lib.mkOption {
type = types.listOf types.path; type = lib.types.listOf lib.types.path;
description = lib.mdDoc '' description = lib.mdDoc ''
List containing web application WAR files and/or directories containing List containing web application WAR files and/or directories containing
web applications and configuration files for the virtual host. web applications and configuration files for the virtual host.
''; '';
default = []; default = [ ];
}; };
}; };
}); });
default = []; default = [ ];
description = lib.mdDoc "List consisting of a virtual host name and a list of web applications to deploy on each virtual host"; description = lib.mdDoc "List consisting of a virtual host name and a list of web applications to deploy on each virtual host";
}; };
logPerVirtualHost = mkOption { logPerVirtualHost = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = lib.mdDoc "Whether to enable logging per virtual host."; description = lib.mdDoc "Whether to enable logging per virtual host.";
}; };
jdk = mkOption { jdk = lib.mkPackageOptionMD pkgs "jdk" { };
type = types.package;
default = pkgs.jdk;
defaultText = literalExpression "pkgs.jdk";
description = lib.mdDoc "Which JDK to use.";
};
axis2 = { axis2 = {
enable = lib.mkEnableOption "Apache Axis2 container";
enable = mkOption { services = lib.mkOption {
default = false; default = [ ];
type = types.bool; type = lib.types.listOf lib.types.str;
description = lib.mdDoc "Whether to enable an Apache Axis2 container";
};
services = mkOption {
default = [];
type = types.listOf types.str;
description = lib.mdDoc "List containing AAR files or directories with AAR files which are web services to be deployed on Axis2"; description = lib.mdDoc "List containing AAR files or directories with AAR files which are web services to be deployed on Axis2";
}; };
}; };
}; };
}; };
###### implementation ###### implementation
config = mkIf config.services.tomcat.enable { config = lib.mkIf config.services.tomcat.enable {
users.groups.tomcat.gid = config.ids.gids.tomcat; users.groups.tomcat.gid = config.ids.gids.tomcat;
users.users.tomcat = users.users.tomcat =
{ uid = config.ids.uids.tomcat; {
uid = config.ids.uids.tomcat;
description = "Tomcat user"; description = "Tomcat user";
home = "/homeless-shelter"; home = "/homeless-shelter";
group = "tomcat"; group = "tomcat";
@ -234,7 +209,7 @@ in
ln -sfn ${tomcat}/conf/$i ${cfg.baseDir}/conf/`basename $i` ln -sfn ${tomcat}/conf/$i ${cfg.baseDir}/conf/`basename $i`
done done
${optionalString (cfg.extraConfigFiles != []) '' ${lib.optionalString (cfg.extraConfigFiles != []) ''
for i in ${toString cfg.extraConfigFiles}; do for i in ${toString cfg.extraConfigFiles}; do
ln -sfn $i ${cfg.baseDir}/conf/`basename $i` ln -sfn $i ${cfg.baseDir}/conf/`basename $i`
done done
@ -253,32 +228,32 @@ in
hostElementForVirtualHost = virtualHost: '' hostElementForVirtualHost = virtualHost: ''
<Host name="${virtualHost.name}" appBase="virtualhosts/${virtualHost.name}/webapps" <Host name="${virtualHost.name}" appBase="virtualhosts/${virtualHost.name}/webapps"
unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"> unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
'' + concatStrings (innerElementsForVirtualHost virtualHost) + '' '' + lib.concatStrings (innerElementsForVirtualHost virtualHost) + ''
</Host> </Host>
''; '';
innerElementsForVirtualHost = virtualHost: innerElementsForVirtualHost = virtualHost:
(map (alias: '' (map (alias: ''
<Alias>${alias}</Alias> <Alias>${alias}</Alias>
'') virtualHost.aliases) '') virtualHost.aliases)
++ (optional cfg.logPerVirtualHost '' ++ (lib.optional cfg.logPerVirtualHost ''
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs/${virtualHost.name}" <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs/${virtualHost.name}"
prefix="${virtualHost.name}_access_log." pattern="combined" resolveHosts="false"/> prefix="${virtualHost.name}_access_log." pattern="combined" resolveHosts="false"/>
''); '');
hostElementsString = concatMapStringsSep "\n" hostElementForVirtualHost cfg.virtualHosts; hostElementsString = lib.concatMapStringsSep "\n" hostElementForVirtualHost cfg.virtualHosts;
hostElementsSedString = replaceStrings ["\n"] ["\\\n"] hostElementsString; hostElementsSedString = lib.replaceStrings ["\n"] ["\\\n"] hostElementsString;
in '' in ''
# Create a modified server.xml which also includes all virtual hosts # Create a modified server.xml which also includes all virtual hosts
sed -e "/<Engine name=\"Catalina\" defaultHost=\"localhost\">/a\\"${escapeShellArg hostElementsSedString} \ sed -e "/<Engine name=\"Catalina\" defaultHost=\"localhost\">/a\\"${lib.escapeShellArg hostElementsSedString} \
${tomcat}/conf/server.xml > ${cfg.baseDir}/conf/server.xml ${tomcat}/conf/server.xml > ${cfg.baseDir}/conf/server.xml
'' ''
} }
${optionalString (cfg.logDirs != []) '' ${lib.optionalString (cfg.logDirs != []) ''
for i in ${toString cfg.logDirs}; do for i in ${toString cfg.logDirs}; do
mkdir -p ${cfg.baseDir}/logs/$i mkdir -p ${cfg.baseDir}/logs/$i
chown ${cfg.user}:${cfg.group} ${cfg.baseDir}/logs/$i chown ${cfg.user}:${cfg.group} ${cfg.baseDir}/logs/$i
done done
''} ''}
${optionalString cfg.logPerVirtualHost (toString (map (h: '' ${lib.optionalString cfg.logPerVirtualHost (toString (map (h: ''
mkdir -p ${cfg.baseDir}/logs/${h.name} mkdir -p ${cfg.baseDir}/logs/${h.name}
chown ${cfg.user}:${cfg.group} ${cfg.baseDir}/logs/${h.name} chown ${cfg.user}:${cfg.group} ${cfg.baseDir}/logs/${h.name}
'') cfg.virtualHosts))} '') cfg.virtualHosts))}
@ -345,7 +320,7 @@ in
# Symlink all the given web applications files or paths into the webapps/ directory # Symlink all the given web applications files or paths into the webapps/ directory
# of this virtual host # of this virtual host
for i in "${optionalString (virtualHost ? webapps) (toString virtualHost.webapps)}"; do for i in "${lib.optionalString (virtualHost ? webapps) (toString virtualHost.webapps)}"; do
if [ -f $i ]; then if [ -f $i ]; then
# If the given web application is a file, symlink it into the webapps/ directory # If the given web application is a file, symlink it into the webapps/ directory
ln -sfn $i ${cfg.baseDir}/virtualhosts/${virtualHost.name}/webapps/`basename $i` ln -sfn $i ${cfg.baseDir}/virtualhosts/${virtualHost.name}/webapps/`basename $i`
@ -368,7 +343,7 @@ in
done done
'') cfg.virtualHosts)} '') cfg.virtualHosts)}
${optionalString cfg.axis2.enable '' ${lib.optionalString cfg.axis2.enable ''
# Copy the Axis2 web application # Copy the Axis2 web application
cp -av ${pkgs.axis2}/webapps/axis2 ${cfg.baseDir}/webapps cp -av ${pkgs.axis2}/webapps/axis2 ${cfg.baseDir}/webapps
@ -405,10 +380,10 @@ in
serviceConfig = { serviceConfig = {
Type = "forking"; Type = "forking";
PermissionsStartOnly = true; PermissionsStartOnly = true;
PIDFile="/run/tomcat/tomcat.pid"; PIDFile = "/run/tomcat/tomcat.pid";
RuntimeDirectory = "tomcat"; RuntimeDirectory = "tomcat";
User = cfg.user; User = cfg.user;
Environment=[ Environment = [
"CATALINA_BASE=${cfg.baseDir}" "CATALINA_BASE=${cfg.baseDir}"
"CATALINA_PID=/run/tomcat/tomcat.pid" "CATALINA_PID=/run/tomcat/tomcat.pid"
"JAVA_HOME='${cfg.jdk}'" "JAVA_HOME='${cfg.jdk}'"

View file

@ -1,21 +1,26 @@
import ./make-test-python.nix ({ pkgs, ... }: import ./make-test-python.nix ({ pkgs, ... }: {
{
name = "tomcat"; name = "tomcat";
nodes.machine = { pkgs, ... }: { nodes.machine = { pkgs, ... }: {
services.tomcat.enable = true; services.tomcat = {
enable = true;
axis2.enable = true;
};
}; };
testScript = '' testScript = ''
machine.wait_for_unit("tomcat.service") machine.wait_for_unit("tomcat.service")
machine.wait_for_open_port(8080) machine.wait_for_open_port(8080)
machine.wait_for_file("/var/tomcat/webapps/examples"); machine.wait_for_file("/var/tomcat/webapps/examples");
machine.succeed( machine.succeed(
"curl --fail http://localhost:8080/examples/servlets/servlet/HelloWorldExample | grep 'Hello World!'" "curl -sS --fail http://localhost:8080/examples/servlets/servlet/HelloWorldExample | grep 'Hello World!'"
) )
machine.succeed( machine.succeed(
"curl --fail http://localhost:8080/examples/jsp/jsp2/simpletag/hello.jsp | grep 'Hello, world!'" "curl -sS --fail http://localhost:8080/examples/jsp/jsp2/simpletag/hello.jsp | grep 'Hello, world!'"
)
machine.succeed(
"curl -sS --fail http://localhost:8080/axis2/axis2-web/HappyAxis.jsp | grep 'Found Axis2'"
) )
''; '';
}) })

View file

@ -2,11 +2,11 @@
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "axis2"; pname = "axis2";
version = "1.7.9"; version = "1.8.2";
src = fetchurl { src = fetchurl {
url = "http://apache.proserve.nl/axis/axis2/java/core/${version}/${pname}-${version}-bin.zip"; url = "mirror://apache/axis/axis2/java/core/${version}/${pname}-${version}-bin.zip";
sha256 = "0dh0s9bfh95wmmw8nyf2yw95biq7d9zmrbg8k4vzcyz1if228lac"; hash = "sha256-oilPVFFpl3F61nVDxcYx/bc81FopS5fzoIdXzeP8brk=";
}; };
nativeBuildInputs = [ unzip ]; nativeBuildInputs = [ unzip ];
@ -15,6 +15,9 @@ stdenv.mkDerivation rec {
meta = { meta = {
description = "Web Services / SOAP / WSDL engine, the successor to the widely used Apache Axis SOAP stack"; description = "Web Services / SOAP / WSDL engine, the successor to the widely used Apache Axis SOAP stack";
homepage = "https://axis.apache.org/axis2/java/core/";
changelog = "https://axis.apache.org/axis2/java/core/release-notes/${version}.html";
maintainers = [ lib.maintainers.anthonyroussel ];
platforms = lib.platforms.unix; platforms = lib.platforms.unix;
sourceProvenance = with lib.sourceTypes; [ binaryBytecode ]; sourceProvenance = with lib.sourceTypes; [ binaryBytecode ];
license = lib.licenses.asl20; license = lib.licenses.asl20;

View file

@ -1,13 +1,13 @@
{ stdenv, lib, fetchurl }: { stdenv, lib, fetchurl, nixosTests, testers, jre }:
let let
common = { versionMajor, versionMinor, sha256 }: stdenv.mkDerivation (rec { common = { versionMajor, versionMinor, sha256 }: stdenv.mkDerivation (finalAttrs: {
pname = "apache-tomcat"; pname = "apache-tomcat";
version = "${versionMajor}.${versionMinor}"; version = "${versionMajor}.${versionMinor}";
src = fetchurl { src = fetchurl {
url = "mirror://apache/tomcat/tomcat-${versionMajor}/v${version}/bin/${pname}-${version}.tar.gz"; url = "mirror://apache/tomcat/tomcat-${versionMajor}/v${finalAttrs.version}/bin/${finalAttrs.pname}-${finalAttrs.version}.tar.gz";
inherit sha256; inherit sha256;
}; };
@ -20,11 +20,19 @@ let
mv $out/webapps $webapps/ mv $out/webapps $webapps/
''; '';
passthru.tests = {
inherit (nixosTests) tomcat;
version = testers.testVersion {
package = finalAttrs.finalPackage;
command = "JAVA_HOME=${jre} ${finalAttrs.finalPackage}/bin/version.sh";
};
};
meta = with lib; { meta = with lib; {
homepage = "https://tomcat.apache.org/"; homepage = "https://tomcat.apache.org/";
description = "An implementation of the Java Servlet and JavaServer Pages technologies"; description = "An implementation of the Java Servlet and JavaServer Pages technologies";
platforms = platforms.all; platforms = platforms.all;
maintainers = [ ]; maintainers = with maintainers; [ anthonyroussel ];
license = [ licenses.asl20 ]; license = [ licenses.asl20 ];
sourceProvenance = with sourceTypes; [ binaryBytecode ]; sourceProvenance = with sourceTypes; [ binaryBytecode ];
}; };
@ -33,13 +41,13 @@ let
in { in {
tomcat9 = common { tomcat9 = common {
versionMajor = "9"; versionMajor = "9";
versionMinor = "0.75"; versionMinor = "0.82";
sha256 = "sha256-VWfKg789z+ns1g3hDsCZFYQ+PsdqUEBeBHCihkGZelk="; sha256 = "sha256-xvRGXDUkYaHFYacUPg81Xf0xyTbdsc1XP/PmqMR8bQc=";
}; };
tomcat10 = common { tomcat10 = common {
versionMajor = "10"; versionMajor = "10";
versionMinor = "0.27"; versionMinor = "1.15";
sha256 = "sha256-N2atmOdhVrGx88eXOc9Wziq8kn7IWzTeFyFpir/5HLc="; sha256 = "sha256-cqQW3Dc3sC/1zoidMIGDBNw4G5bnxYvhmHz7U7K6Djg=";
}; };
} }