From 3f8b8fc35798beebd75d221e96dae22621386ff4 Mon Sep 17 00:00:00 2001 From: markt Date: Fri, 1 Jul 2011 17:35:09 +0000 Subject: [PATCH] Build server.xml for the installer by search and replace rather than combining fragments. No ore work to keep the original and the fragments in sync and esy to expand to add additional search/replace as well as insertions etc. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1142001 13f79535-47bb-0310-9956-ffa450edef68 --- build.xml | 1 - res/confinstall/server_1.xml | 70 -------------------------------------------- res/confinstall/server_2.xml | 22 -------------- res/confinstall/server_3.xml | 52 -------------------------------- res/tomcat.nsi | 60 ++++++++++++++++++------------------- 5 files changed, 30 insertions(+), 175 deletions(-) delete mode 100644 res/confinstall/server_1.xml delete mode 100644 res/confinstall/server_2.xml delete mode 100644 res/confinstall/server_3.xml diff --git a/build.xml b/build.xml index 4cedb634b..01acd5c01 100644 --- a/build.xml +++ b/build.xml @@ -438,7 +438,6 @@ - diff --git a/res/confinstall/server_1.xml b/res/confinstall/server_1.xml deleted file mode 100644 index 061e08026..000000000 --- a/res/confinstall/server_1.xml +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/res/tomcat.nsi b/res/tomcat.nsi index 3a5595e63..d31731bee 100644 --- a/res/tomcat.nsi +++ b/res/tomcat.nsi @@ -154,9 +154,6 @@ Var ServiceInstallLog ReserveFile "${NSISDIR}\Plugins\System.dll" ReserveFile "${NSISDIR}\Plugins\nsDialogs.dll" - ReserveFile confinstall\server_1.xml - ReserveFile confinstall\server_2.xml - ReserveFile confinstall\server_3.xml ReserveFile confinstall\tomcat-users_1.xml ReserveFile confinstall\tomcat-users_2.xml @@ -802,8 +799,36 @@ FunctionEnd ; Writes server.xml and tomcat-users.xml ; Function configure - StrCpy $R4 'port="$TomcatPortHttp"' - StrCpy $R6 'port="$TomcatPortAjp"' + ; Build final server.xml + DetailPrint "Creating server.xml.new" + + FileOpen $R1 "$INSTDIR\conf\server.xml" r + FileOpen $R2 "$INSTDIR\conf\server.xml.new" w + + SERVER_XML_LOOP: + FileRead $R1 $R3 + IfErrors SERVER_XML_LEAVELOOP + ${StrRep} $R4 $R3 "8080" "$TomcatPortHttp" + ${StrRep} $R3 $R4 "8009" "$TomcatPortAjp" + FileWrite $R2 $R3 + Goto SERVER_XML_LOOP + SERVER_XML_LEAVELOOP: + + FileClose $R1 + FileClose $R2 + + ; Replace server.xml with server.xml.new + Delete "$INSTDIR\conf\server.xml" + FileOpen $R9 "$INSTDIR\conf\server.xml" w + Push "$INSTDIR\conf\server.xml.new" + Call copyFile + FileClose $R9 + Delete "$INSTDIR\conf\server.xml.new" + + DetailPrint 'HTTP/1.1 Connector configured on port "$TomcatPortHttp"' + DetailPrint 'AJP/1.3 Connector configured on port "$TomcatPortAjp"' + DetailPrint "server.xml written" + StrCpy $R5 '' ${If} $TomcatAdminEnable == "1" @@ -824,36 +849,14 @@ Function configure DetailPrint 'Admin user added: "$TomcatAdminUsername"' ${EndIf} - DetailPrint 'HTTP/1.1 Connector configured on port "$TomcatPortHttp"' - DetailPrint 'AJP/1.3 Connector configured on port "$TomcatPortAjp"' ; Extract these fragments to $PLUGINSDIR. That is a temporary directory, ; that is automatically deleted when the installer exits. InitPluginsDir SetOutPath $PLUGINSDIR - File confinstall\server_1.xml - File confinstall\server_2.xml - File confinstall\server_3.xml File confinstall\tomcat-users_1.xml File confinstall\tomcat-users_2.xml - ; Build final server.xml - Delete "$INSTDIR\conf\server.xml" - DetailPrint "Writing server.xml" - FileOpen $R9 "$INSTDIR\conf\server.xml" w - - Push "$PLUGINSDIR\server_1.xml" - Call copyFile - FileWrite $R9 $R4 - Push "$PLUGINSDIR\server_2.xml" - Call copyFile - FileWrite $R9 $R6 - Push "$PLUGINSDIR\server_3.xml" - Call copyFile - - FileClose $R9 - DetailPrint "server.xml written" - ; Build final tomcat-users.xml Delete "$INSTDIR\conf\tomcat-users.xml" DetailPrint "Writing tomcat-users.xml" @@ -875,9 +878,6 @@ Function configure FileClose $R9 DetailPrint "tomcat-users.xml written" - Delete "$PLUGINSDIR\server_1.xml" - Delete "$PLUGINSDIR\server_2.xml" - Delete "$PLUGINSDIR\server_3.xml" Delete "$PLUGINSDIR\tomcat-users_1.xml" Delete "$PLUGINSDIR\tomcat-users_2.xml" FunctionEnd -- 2.11.0