From c906794c20c67e023a512dcc37398a274cbc99ed Mon Sep 17 00:00:00 2001
From: "Endi S. Dewata" <edewata@redhat.com>
Date: Mon, 25 Nov 2013 12:43:03 -0500
Subject: [PATCH] Added option to build without server packages.

The build scripts have been modified to accept an optional parameter
to build pki-core without the server packages.
---
 CMakeLists.txt                    |  4 ++--
 base/CMakeLists.txt               | 29 +++++++++++++++--------------
 scripts/compose_functions         | 28 +++++++++++++++++-----------
 scripts/compose_pki_core_packages |  6 +++++-
 specs/pki-console.spec            |  6 +++++-
 specs/pki-core.spec               | 27 +++++++++++++++++++++++++--
 specs/pki-tps.spec                |  6 +++++-
 7 files changed, 74 insertions(+), 32 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7e679d06eefd2edcf795022d5a7e29ab06d3e59e..2748a51d1391d99f41c12cb649264c402c0dc427 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,8 +14,8 @@ string(REGEX REPLACE "^([0-9]+).*" "\\1" APPLICATION_VERSION_MAJOR ${VERSION})
 string(REGEX REPLACE "^[0-9]+\\.([0-9]+).*" "\\1" APPLICATION_VERSION_MINOR ${VERSION})
 string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" APPLICATION_VERSION_PATCH ${VERSION})
 
-option(WITH_JAVADOC "Build with Javadoc" ON)
-option(BUILD_PKI_SELINUX "Build pki-selinux" OFF)
+option(WITH_JAVADOC "Build Javadoc" ON)
+option(WITH_SERVER "Build Server" ON)
 
 if (BUILD_IPA_PKI_THEME)
     set(APPLICATION_FLAVOR_IPA_PKI_THEME TRUE)
diff --git a/base/CMakeLists.txt b/base/CMakeLists.txt
index 0dc513666425607f5ce6ff86346cc03518912187..3410ed876f7ca488661b1d080dfb58dbc18455bf 100644
--- a/base/CMakeLists.txt
+++ b/base/CMakeLists.txt
@@ -3,26 +3,27 @@ project(base)
 # The order is important!
 if (APPLICATION_FLAVOR_PKI_CORE)
     add_subdirectory(test)
-    add_subdirectory(setup)
     add_subdirectory(symkey)
     add_subdirectory(util)
     add_subdirectory(common)
     add_subdirectory(native-tools)
     add_subdirectory(java-tools)
-    add_subdirectory(server)
-    if(BUILD_PKI_SELINUX)
-        add_subdirectory(selinux)
-    endif(BUILD_PKI_SELINUX)
-    add_subdirectory(ca)
-    add_subdirectory(kra)
-    add_subdirectory(ocsp)
-    add_subdirectory(tks)
-    add_subdirectory(tps)
-    add_subdirectory(silent)
 
-    if(WITH_JAVADOC)
-        add_subdirectory(javadoc)
-    endif(WITH_JAVADOC)
+    if(WITH_SERVER)
+        add_subdirectory(server)
+        add_subdirectory(ca)
+        add_subdirectory(kra)
+        add_subdirectory(ocsp)
+        add_subdirectory(tks)
+        add_subdirectory(tps)
+        add_subdirectory(setup)
+        add_subdirectory(silent)
+
+        if(WITH_JAVADOC)
+            add_subdirectory(javadoc)
+        endif(WITH_JAVADOC)
+
+    endif(WITH_SERVER)
 
     configure_file(
         ${CMAKE_CURRENT_SOURCE_DIR}/VERSION
diff --git a/scripts/compose_functions b/scripts/compose_functions
index d5996ae1bdc6717e170aca5b718992da4d22dd1d..6996c741270234548ac053c5bdd4da815b0787a7 100644
--- a/scripts/compose_functions
+++ b/scripts/compose_functions
@@ -109,9 +109,10 @@ Usage()
 	printf "                           ${MESSAGE}\n\n"
 	printf "Options:\n"
 	printf "  --without-javadoc        do not build Javadoc RPMS\n\n"
-        printf "  --createrepo=<repository_location_details_file> create a \n"
-        printf "                           repository with the rpms built."
-        printf "                           Provide the configuration file with the details. \n\n"
+	printf "  --without-server         do not build server RPMS\n\n"
+	printf "  --createrepo=<repository_config> create a \n"
+	printf "                           repository with the rpms built."
+	printf "                           Provide the configuration file with the details. \n\n"
 }
 
 
@@ -307,7 +308,7 @@ Create_repo_after_build()
 ## Check for command line argument validity
 ##
 
-GETOPT=`getopt -o '' -l without-javadoc,work-dir:,createrepo: -n "$0" -- "$@"`
+GETOPT=`getopt -o '' -l without-javadoc,without-server,work-dir:,createrepo: -n "$0" -- "$@"`
 
 if [ $? != 0 ] ; then
     Usage
@@ -318,7 +319,8 @@ eval set -- "$GETOPT"
 
 while true ; do
     case "$1" in
-        --without-javadoc) JAVADOC="--without javadoc" ; shift ;;
+        --without-javadoc) WITHOUT_JAVADOCS="--without javadoc" ; shift ;;
+        --without-server) WITHOUT_SERVER="--without server" ; shift ;;
         --work-dir) WORK_DIR="$2" ; shift 2 ;;
         --createrepo) CREATEREPO="Y" ; REPO_CFG_FILE="$2" ; shift 2 ;;
         --) shift ; break ;;
@@ -331,32 +333,36 @@ if [ $# -ne 1 ] ; then
 	exit 255
 fi
 
+OPTIONS="--define \"_topdir \`pwd\`\" $WITHOUT_JAVADOCS $WITHOUT_SERVER"
+
 if	[ $1 = "srpm" ] ; then
-	RPMBUILD_CMD="rpmbuild --define \"_topdir \`pwd\`\" $JAVADOC -bs"
+	OPTIONS="$OPTIONS -bs"
 	FETCH_SOURCE_TARBALL=0
 	FETCH_PATCH_FILES=0
 elif [ $1 = "hybrid_srpm" ] ; then
-	RPMBUILD_CMD="rpmbuild --define \"_topdir \`pwd\`\" $JAVADOC -bs"
+	OPTIONS="$OPTIONS -bs"
 	FETCH_SOURCE_TARBALL=0
 	FETCH_PATCH_FILES=1
 elif [ $1 = "patched_srpm" ] ; then
-	RPMBUILD_CMD="rpmbuild --define \"_topdir \`pwd\`\" $JAVADOC -bs"
+	OPTIONS="$OPTIONS -bs"
 	FETCH_SOURCE_TARBALL=1
 	FETCH_PATCH_FILES=1
 elif [ $1 = "rpms" ] ; then
-	RPMBUILD_CMD="rpmbuild --define \"_topdir \`pwd\`\" $JAVADOC -ba"
+	OPTIONS="$OPTIONS -ba"
 	FETCH_SOURCE_TARBALL=0
 	FETCH_PATCH_FILES=0
 elif [ $1 = "hybrid_rpms" ] ; then
-	RPMBUILD_CMD="rpmbuild --define \"_topdir \`pwd\`\" $JAVADOC -ba"
+	OPTIONS="$OPTIONS -ba"
 	FETCH_SOURCE_TARBALL=0
 	FETCH_PATCH_FILES=1
 elif [ $1 = "patched_rpms" ] ; then
-	RPMBUILD_CMD="rpmbuild --define \"_topdir \`pwd\`\" $JAVADOC -ba"
+	OPTIONS="$OPTIONS -ba"
 	FETCH_SOURCE_TARBALL=1
 	FETCH_PATCH_FILES=1
 else
 	Usage
 	exit 255
 fi
+
+RPMBUILD_CMD="rpmbuild $OPTIONS"
 export RPMBUILD_CMD
diff --git a/scripts/compose_pki_core_packages b/scripts/compose_pki_core_packages
index 23d58e0d0e4f4faeff43a4141e97f33c067bcdfb..28059fac9a7f2d55100afbb7f8b366c10cba099f 100755
--- a/scripts/compose_pki_core_packages
+++ b/scripts/compose_pki_core_packages
@@ -38,12 +38,16 @@ PKI_CORE_VERSION="10.2.0"
 ##
 
 PKI_SPECS_FILE="${PKI_DIR}/specs/${PKI_CORE}.spec"
-PKI_COMPONENT_LIST="test setup symkey util common native-tools java-tools server selinux ca kra ocsp tks tps-tomcat silent"
+PKI_COMPONENT_LIST="test symkey util common native-tools java-tools selinux"
 
 if [ "$WITHOUT_JAVADOC" = "" ]; then
     PKI_COMPONENT_LIST="$PKI_COMPONENT_LIST javadoc"
 fi
 
+if [ "$WITHOUT_SERVER" = "" ]; then
+    PKI_COMPONENT_LIST="$PKI_COMPONENT_LIST server ca kra ocsp tks tps-tomcat setup silent"
+fi
+
 ##
 ## Establish the TARGET files/directories of the 'pki-core' source/spec files
 ##
diff --git a/specs/pki-console.spec b/specs/pki-console.spec
index 38394098f8f213bd0725e7a9b14e5990daaa4667..c7827b8cf4b64aaff4fac0339c699c598bc159ed 100644
--- a/specs/pki-console.spec
+++ b/specs/pki-console.spec
@@ -6,6 +6,8 @@ URL:              http://pki.fedoraproject.org/
 License:          GPLv2
 Group:            System Environment/Base
 
+%bcond_without    javadoc
+
 BuildArch:        noarch
 
 BuildRoot:        %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@@ -61,7 +63,9 @@ cd build
 	-DVAR_INSTALL_DIR:PATH=/var \
     -DBUILD_PKI_CONSOLE:BOOL=ON \
     -DJAVA_LIB_INSTALL_DIR=%{_jnidir} \
-    %{?_without_javadoc:-DWITH_JAVADOC:BOOL=OFF} \
+%if ! %{with javadoc}
+    -DWITH_JAVADOC:BOOL=OFF \
+%endif
     ..
 %{__make} VERBOSE=1 %{?_smp_mflags}
 
diff --git a/specs/pki-core.spec b/specs/pki-core.spec
index 9b4171547b7784b5ec17d14a9c5522015c1514dc..28781a32881993ea329ae4ecda1de2be2cfbab24 100644
--- a/specs/pki-core.spec
+++ b/specs/pki-core.spec
@@ -11,6 +11,9 @@ URL:              http://pki.fedoraproject.org/
 License:          GPLv2
 Group:            System Environment/Daemons
 
+%bcond_without    server
+%bcond_without    javadoc
+
 BuildRoot:        %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
 BuildRequires:    cmake >= 2.8.9-1
@@ -498,7 +501,12 @@ cd build
 %else
 	-DRESTEASY_LIB=/usr/share/java/resteasy \
 %endif
-	%{?_without_javadoc:-DWITH_JAVADOC:BOOL=OFF} \
+%if ! %{with server}
+	-DWITH_SERVER:BOOL=OFF \
+%endif
+%if ! %{with javadoc}
+	-DWITH_JAVADOC:BOOL=OFF \
+%endif
 	..
 %{__make} VERBOSE=1 %{?_smp_mflags} all
 # %{__make} VERBOSE=1 %{?_smp_mflags} test
@@ -509,6 +517,8 @@ cd build
 cd build
 %{__make} install DESTDIR=%{buildroot} INSTALL="install -p"
 
+%if %{with server}
+
 # Scanning the python code with pylint. A return value of 0 represents there are no
 # errors or warnings reported by pylint.
 sh ../pylint-build-scan.sh %{buildroot} `pwd`
@@ -537,6 +547,9 @@ if [ -d /etc/sysconfig/pki/%i ]; then                                        \
   done                                                                       \
 fi                                                                           \
 )
+
+%endif # %{with server}
+
 %{__mkdir_p} %{buildroot}%{_localstatedir}/log/pki
 %{__mkdir_p} %{buildroot}%{_sharedstatedir}/pki
 
@@ -590,6 +603,8 @@ then
     rm -f %{_sysconfdir}/pki/pki.version
 fi
 
+%if %{with server}
+
 %post -n pki-ca
 # Attempt to update ALL old "CA" instances to "systemd"
 if [ -d /etc/sysconfig/pki/ca ]; then
@@ -791,6 +806,9 @@ fi
 ##        from EITHER 'sysVinit' OR previous 'systemd' processes to the new
 ##        PKI deployment process
 
+%endif # %{with server}
+
+
 %files -n pki-symkey
 %defattr(-,root,root,-)
 %doc base/symkey/LICENSE
@@ -854,6 +872,8 @@ fi
 %{_mandir}/man1/pki.1.gz
 
 
+%if %{with server}
+
 %files -n pki-server
 %defattr(-,root,root,-)
 %doc base/common/THIRD_PARTY_LICENSES
@@ -895,6 +915,7 @@ fi
 %{_datadir}/pki/setup/
 %{_datadir}/pki/server/
 
+
 %files -n pki-ca
 %defattr(-,root,root,-)
 %doc base/ca/LICENSE
@@ -958,16 +979,18 @@ fi
 %{_datadir}/pki/tps/setup/
 %{_datadir}/pki/tps/webapps/
 
-%if %{?_without_javadoc:0}%{!?_without_javadoc:1}
+%if %{with javadoc}
 %files -n pki-javadoc
 %defattr(-,root,root,-)
 %{_javadocdir}/pki-%{version}/
 %endif
 
+%endif # %{with server}
 
 %changelog
 * Fri Nov 22 2013 Dogtag Team <pki-devel@redhat.com> 10.2.0-0.1
 - Updated version number to 10.2.0-0.1.
+- Added option to build without server packages.
 
 * Fri Nov 15 2013 Ade Lee <alee@redhat.com> 10.1.0-1
 - Trac Ticket 788 - Clean up spec files
diff --git a/specs/pki-tps.spec b/specs/pki-tps.spec
index 19a29981b050a5c4fe2ac30a5d1202cbadd8aaca..a788394433ec6efc7eaf07663c06382f561162e8 100644
--- a/specs/pki-tps.spec
+++ b/specs/pki-tps.spec
@@ -6,6 +6,8 @@ URL:              http://pki.fedoraproject.org/
 License:          LGPLv2
 Group:            System Environment/Daemons
 
+%bcond_without    javadoc
+
 BuildRoot:        %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
 BuildRequires:    cmake >= 2.8.9-1
@@ -128,7 +130,9 @@ cd build
 %else
 	-DRESTEASY_LIB=/usr/share/java/resteasy \
 %endif
-	%{?_without_javadoc:-DWITH_JAVADOC:BOOL=OFF} \
+%if ! %{with javadoc}
+	-DWITH_JAVADOC:BOOL=OFF \
+%endif
 	..
 %{__make} VERBOSE=1 %{?_smp_mflags}
 
-- 
1.8.4.2

