From b42679cc61cdf31772ba17f9779c87310cd8d9b9 Mon Sep 17 00:00:00 2001
From: Endi Sukma Dewata <edewata@redhat.com>
Date: Tue, 21 Aug 2012 13:15:34 -0500
Subject: [PATCH] Moved WAR creation code into CMake scripts.

The code to generate the WAR files has been moved from the RPM
spec file into the CMake scripts for each subsystem to allow better
control.

Ticket #89
---
 base/ca/CMakeLists.txt                  |  1 +
 base/ca/shared/webapps/CMakeLists.txt   | 21 +++++++++++++++++++++
 base/kra/CMakeLists.txt                 |  1 +
 base/kra/shared/webapps/CMakeLists.txt  | 21 +++++++++++++++++++++
 base/ocsp/CMakeLists.txt                |  1 +
 base/ocsp/shared/webapps/CMakeLists.txt | 21 +++++++++++++++++++++
 base/tks/CMakeLists.txt                 |  1 +
 base/tks/shared/webapps/CMakeLists.txt  | 21 +++++++++++++++++++++
 specs/pki-core.spec                     | 20 ++++----------------
 9 files changed, 92 insertions(+), 16 deletions(-)
 create mode 100644 base/ca/shared/webapps/CMakeLists.txt
 create mode 100644 base/kra/shared/webapps/CMakeLists.txt
 create mode 100644 base/ocsp/shared/webapps/CMakeLists.txt
 create mode 100644 base/tks/shared/webapps/CMakeLists.txt

diff --git a/base/ca/CMakeLists.txt b/base/ca/CMakeLists.txt
index 153208c2da88b52cd633e3a0df2f5abbc807edc4..4d70c19f07fdd4c015a7069872a4df688f86a1e5 100644
--- a/base/ca/CMakeLists.txt
+++ b/base/ca/CMakeLists.txt
@@ -3,6 +3,7 @@ project(ca Java)
 add_subdirectory(src)
 add_subdirectory(setup)
 add_subdirectory(shared/conf)
+add_subdirectory(shared/webapps)
 
 # install systemd scripts
 install(
diff --git a/base/ca/shared/webapps/CMakeLists.txt b/base/ca/shared/webapps/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..d71495cd0e31f82116840f7f81b039f3c5fabeba
--- /dev/null
+++ b/base/ca/shared/webapps/CMakeLists.txt
@@ -0,0 +1,21 @@
+project(ca-webapps Java)
+
+jar(ca-war
+    CREATE
+        ${CMAKE_BINARY_DIR}/dist/ca.war
+    OPTIONS
+        M
+    INPUT_DIR
+        ${SHARE_INSTALL_PREFIX}/pki/common-ui
+        ${SHARE_INSTALL_PREFIX}/pki/ca-ui/webapps/ca
+        ${CMAKE_CURRENT_SOURCE_DIR}/ca
+)
+
+file(MAKE_DIRECTORY ${SHARE_INSTALL_PREFIX}/pki/ca/war)
+
+install(
+     FILES
+        ${CMAKE_BINARY_DIR}/dist/ca.war
+    DESTINATION
+        ${SHARE_INSTALL_PREFIX}/pki/ca/war
+)
\ No newline at end of file
diff --git a/base/kra/CMakeLists.txt b/base/kra/CMakeLists.txt
index 0e15b2d52e671e6d71c1a478ced0b35751467985..5501538d816ba141ec8bf0d2e705992f5adee9ca 100644
--- a/base/kra/CMakeLists.txt
+++ b/base/kra/CMakeLists.txt
@@ -3,6 +3,7 @@ project(kra Java)
 add_subdirectory(src)
 add_subdirectory(setup)
 add_subdirectory(shared/conf)
+add_subdirectory(shared/webapps)
 
 # install systemd scripts
 install(
diff --git a/base/kra/shared/webapps/CMakeLists.txt b/base/kra/shared/webapps/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..296efa6e9cbf0c756377e287a9ead1dda277046d
--- /dev/null
+++ b/base/kra/shared/webapps/CMakeLists.txt
@@ -0,0 +1,21 @@
+project(kra-webapps Java)
+
+jar(kra-war
+    CREATE
+        ${CMAKE_BINARY_DIR}/dist/kra.war
+    OPTIONS
+        M
+    INPUT_DIR
+        ${SHARE_INSTALL_PREFIX}/pki/common-ui
+        ${SHARE_INSTALL_PREFIX}/pki/kra-ui/webapps/kra
+        ${CMAKE_CURRENT_SOURCE_DIR}/kra
+)
+
+file(MAKE_DIRECTORY ${SHARE_INSTALL_PREFIX}/pki/kra/war)
+
+install(
+     FILES
+        ${CMAKE_BINARY_DIR}/dist/kra.war
+    DESTINATION
+        ${SHARE_INSTALL_PREFIX}/pki/kra/war
+)
\ No newline at end of file
diff --git a/base/ocsp/CMakeLists.txt b/base/ocsp/CMakeLists.txt
index c8e22ea1e65a1093c82a2fef357c58a48830c477..17a00ec93d0815fc9c0714790880722bc56c825b 100644
--- a/base/ocsp/CMakeLists.txt
+++ b/base/ocsp/CMakeLists.txt
@@ -3,6 +3,7 @@ project(ocsp Java)
 add_subdirectory(src)
 add_subdirectory(setup)
 add_subdirectory(shared/conf)
+add_subdirectory(shared/webapps)
 
 # install systemd scripts
 install(
diff --git a/base/ocsp/shared/webapps/CMakeLists.txt b/base/ocsp/shared/webapps/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..c545c40122cc91ce671501936e929d99d77d6a66
--- /dev/null
+++ b/base/ocsp/shared/webapps/CMakeLists.txt
@@ -0,0 +1,21 @@
+project(ocsp-webapps Java)
+
+jar(ocsp-war
+    CREATE
+        ${CMAKE_BINARY_DIR}/dist/ocsp.war
+    OPTIONS
+        M
+    INPUT_DIR
+        ${SHARE_INSTALL_PREFIX}/pki/common-ui
+        ${SHARE_INSTALL_PREFIX}/pki/ocsp-ui/webapps/ocsp
+        ${CMAKE_CURRENT_SOURCE_DIR}/ocsp
+)
+
+file(MAKE_DIRECTORY ${SHARE_INSTALL_PREFIX}/pki/ocsp/war)
+
+install(
+     FILES
+        ${CMAKE_BINARY_DIR}/dist/ocsp.war
+    DESTINATION
+        ${SHARE_INSTALL_PREFIX}/pki/ocsp/war
+)
\ No newline at end of file
diff --git a/base/tks/CMakeLists.txt b/base/tks/CMakeLists.txt
index fd9246948e4798455467444583b696acacd476df..9152316aa168a7a6320732f5843f0d4693156162 100644
--- a/base/tks/CMakeLists.txt
+++ b/base/tks/CMakeLists.txt
@@ -3,6 +3,7 @@ project(tks Java)
 add_subdirectory(src)
 add_subdirectory(setup)
 add_subdirectory(shared/conf)
+add_subdirectory(shared/webapps)
 
 # install systemd scripts
 install(
diff --git a/base/tks/shared/webapps/CMakeLists.txt b/base/tks/shared/webapps/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..e5f49be56bfeebceefed9ea0c4a5996f905ad9fb
--- /dev/null
+++ b/base/tks/shared/webapps/CMakeLists.txt
@@ -0,0 +1,21 @@
+project(tks-webapps Java)
+
+jar(tks-war
+    CREATE
+        ${CMAKE_BINARY_DIR}/dist/tks.war
+    OPTIONS
+        M
+    INPUT_DIR
+        ${SHARE_INSTALL_PREFIX}/pki/common-ui
+        ${SHARE_INSTALL_PREFIX}/pki/tks-ui/webapps/tks
+        ${CMAKE_CURRENT_SOURCE_DIR}/tks
+)
+
+file(MAKE_DIRECTORY ${SHARE_INSTALL_PREFIX}/pki/tks/war)
+
+install(
+     FILES
+        ${CMAKE_BINARY_DIR}/dist/tks.war
+    DESTINATION
+        ${SHARE_INSTALL_PREFIX}/pki/tks/war
+)
\ No newline at end of file
diff --git a/specs/pki-core.spec b/specs/pki-core.spec
index a132d4ed760dd05d50c8158706fd0888a8ecef17..35a9f2facf3392ca7914575a5e17dca2732f6492 100644
--- a/specs/pki-core.spec
+++ b/specs/pki-core.spec
@@ -14,7 +14,7 @@ distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
 
 Name:             pki-core
 Version:          10.0.0
-Release:          %{?relprefix}26%{?prerel}%{?dist}
+Release:          %{?relprefix}27%{?prerel}%{?dist}
 Summary:          Certificate System - PKI Core Components
 URL:              http://pki.fedoraproject.org/
 License:          GPLv2
@@ -788,21 +788,6 @@ if [ -d /etc/sysconfig/pki/%i ]; then                                        \
 fi                                                                           \
 )
 
-# Create PKI subsystem "war" files
-for subsystem in ca kra ocsp tks; do
-    echo "Constructing '${subsystem}.war' . . ."
-    %{__mkdir_p} %{buildroot}%{_datadir}/pki/${subsystem}/war
-    %{__cp} -r %{_datadir}/pki/common-ui/admin %{buildroot}%{_datadir}/pki/${subsystem}/war
-    %{__cp} -r %{_datadir}/pki/common-ui/css %{buildroot}%{_datadir}/pki/${subsystem}/war
-    %{__cp} -r %{_datadir}/pki/common-ui/img %{buildroot}%{_datadir}/pki/${subsystem}/war
-    %{__cp} -r %{_datadir}/pki/${subsystem}-ui/webapps/${subsystem}/* %{buildroot}%{_datadir}/pki/${subsystem}/war
-    %{__cp} -r %{buildroot}%{_datadir}/pki/${subsystem}/webapps/${subsystem}/WEB-INF %{buildroot}%{_datadir}/pki/${subsystem}/war
-    cd %{buildroot}%{_datadir}/pki/${subsystem}/war
-    jar -cvMf ../${subsystem}.war *
-    %{__rm} -rf %{buildroot}%{_datadir}/pki/${subsystem}/war/*
-    %{__mv} ../${subsystem}.war %{buildroot}%{_datadir}/pki/${subsystem}/war
-done
-
 %pre -n pki-selinux
 %saveFileContext targeted
 
@@ -1372,6 +1357,9 @@ fi
 
 
 %changelog
+* Tue Aug 21 2012 Endi S. Dewata <edewata@redhat.com> 10.0.0-0.27.a1
+- Moved WAR creation code into CMake scripts.
+
 * Mon Aug 20 2012 Endi S. Dewata <edewata@redhat.com> 10.0.0-0.26.a1
 - Split pki-client.jar into pki-certsrv.jar and pki-tools.jar.
 
-- 
1.7.11.2

