>From 018af3e55351a2abf64b542f6220dce2a2e6fea1 Mon Sep 17 00:00:00 2001
From: Ade Lee <alee@redhat.com>
Date: Tue, 20 Nov 2012 23:34:32 -0500
Subject: [PATCH] Link to resteasy-base on rhel systems when running pkispawn

---
 base/deploy/scripts/operations          |  8 +++++++-
 base/deploy/src/scriptlets/pkiconfig.py | 15 +++++++++++++++
 base/deploy/src/scriptlets/pkihelper.py |  1 -
 base/deploy/src/scriptlets/pkijython.py | 24 +++++++++++++-----------
 4 files changed, 35 insertions(+), 13 deletions(-)

diff --git a/base/deploy/scripts/operations b/base/deploy/scripts/operations
index be5053ba25f72d4921b8f5b1388e07b6a52edd46..0a768fb1b2bc381c6f186f411d126e2fa35d8e7b 100644
--- a/base/deploy/scripts/operations
+++ b/base/deploy/scripts/operations
@@ -943,9 +943,15 @@ verify_symlinks()
     # Dogtag 10 Symbolic Link Target Variables
     java_dir="/usr/share/java"
     pki_systemd_service="pki-${PKI_WEB_SERVER_TYPE}d@.service"
-    resteasy_java_dir="/usr/share/java/resteasy"
     systemd_dir="/lib/systemd/system"
 
+    grep "Red Hat Enterprise Linux" /etc/redhat-release
+    if [ $? == 0 ]; then
+        resteasy_java_dir="/usr/share/java/resteasy-base"
+    else
+        resteasy_java_dir="/usr/share/java/resteasy"
+    fi
+
     # Dogtag 10 Symbolic Link Variables
     pki_common_jar_dir="${PKI_INSTANCE_PATH}/common/lib"
     pki_registry_dir="/etc/sysconfig/pki/${PKI_WEB_SERVER_TYPE}/${PKI_INSTANCE_ID}"
diff --git a/base/deploy/src/scriptlets/pkiconfig.py b/base/deploy/src/scriptlets/pkiconfig.py
index e8e65970e76400a1bb20dfdc1c9c211b749ca025..92e46d0459922096861c4e6a4cbd23e0577b0728 100644
--- a/base/deploy/src/scriptlets/pkiconfig.py
+++ b/base/deploy/src/scriptlets/pkiconfig.py
@@ -18,6 +18,17 @@
 # Copyright (C) 2012 Red Hat, Inc.
 # All rights reserved.
 #
+import re
+
+def is_rhel():
+    try:
+        f = open("/etc/redhat-release")
+        for line in f:
+            if re.search("Red Hat Enterprise Linux", line):
+                return True
+    except IOError, e:
+        pass
+    return False
 
 # PKI Deployment Constants
 PKI_DEPLOYMENT_DEFAULT_CLIENT_DIR_PERMISSIONS = 00755
@@ -59,7 +70,11 @@ PKI_DEPLOYMENT_INTERRUPT_BANNER = "-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+"\
 PKI_DEPLOYMENT_JAR_SOURCE_ROOT = "/usr/share/java"
 PKI_DEPLOYMENT_HTTPCOMPONENTS_JAR_SOURCE_ROOT = "/usr/share/java/httpcomponents"
 PKI_DEPLOYMENT_PKI_JAR_SOURCE_ROOT = "/usr/share/java/pki"
+
 PKI_DEPLOYMENT_RESTEASY_JAR_SOURCE_ROOT = "/usr/share/java/resteasy"
+if is_rhel():
+    PKI_DEPLOYMENT_RESTEASY_JAR_SOURCE_ROOT = "/usr/share/java/resteasy-base"
+
 PKI_DEPLOYMENT_SOURCE_ROOT = "/usr/share/pki"
 PKI_DEPLOYMENT_SYSTEMD_ROOT = "/lib/systemd/system"
 PKI_DEPLOYMENT_SYSTEMD_CONFIGURATION_ROOT = "/etc/systemd/system"
diff --git a/base/deploy/src/scriptlets/pkihelper.py b/base/deploy/src/scriptlets/pkihelper.py
index ba67465ef989e9ffcc9a34ff576435a0611282f8..b9526943156c2fe24e99b12d94938d090aa09b67 100644
--- a/base/deploy/src/scriptlets/pkihelper.py
+++ b/base/deploy/src/scriptlets/pkihelper.py
@@ -121,7 +121,6 @@ def pki_copytree(src, dst, symlinks=False, ignore=None):
     if errors:
         raise Error, errors
 
-
 # PKI Deployment Identity Class
 class identity:
     def __add_gid(self, pki_group):
diff --git a/base/deploy/src/scriptlets/pkijython.py b/base/deploy/src/scriptlets/pkijython.py
index 8d027f91a88b11bc79facee17e1dc2999c2fa81d..e6098b01ab6995863b1a07f154c17aa3e7909fbb 100644
--- a/base/deploy/src/scriptlets/pkijython.py
+++ b/base/deploy/src/scriptlets/pkijython.py
@@ -77,6 +77,9 @@ class classPathHacker:
         b = method.invoke(sysloader, jar_a)
         return u
 
+# PKI Python Imports
+import pkiconfig as config
+import pkimessages as log
 
 # Dynamically Load Additional Java Jars ('append' to existing classpath)
 jarLoad = classPathHacker()
@@ -87,13 +90,18 @@ jarLoad.addFile("/usr/share/java/apache-commons-cli.jar")
 jarLoad.addFile("/usr/share/java/apache-commons-codec.jar")
 jarLoad.addFile("/usr/share/java/apache-commons-logging.jar")
 jarLoad.addFile("/usr/share/java/istack-commons-runtime.jar")
+
 #     Resteasy Jars
+RESTEASY_ROOT = "resteasy"
+if config.is_rhel():
+    RESTEASY_ROOT = "resteasy-base"
+
 jarLoad.addFile("/usr/share/java/glassfish-jaxb/jaxb-impl.jar")
-jarLoad.addFile("/usr/share/java/resteasy/jaxrs-api.jar")
-jarLoad.addFile("/usr/share/java/resteasy/resteasy-atom-provider.jar")
-jarLoad.addFile("/usr/share/java/resteasy/resteasy-jaxb-provider.jar")
-jarLoad.addFile("/usr/share/java/resteasy/resteasy-jaxrs.jar")
-jarLoad.addFile("/usr/share/java/resteasy/resteasy-jettison-provider.jar")
+jarLoad.addFile("/usr/share/java/" + RESTEASY_ROOT + "/jaxrs-api.jar")
+jarLoad.addFile("/usr/share/java/" + RESTEASY_ROOT + "/resteasy-atom-provider.jar")
+jarLoad.addFile("/usr/share/java/" + RESTEASY_ROOT + "/resteasy-jaxb-provider.jar")
+jarLoad.addFile("/usr/share/java/" + RESTEASY_ROOT + "/resteasy-jaxrs.jar")
+jarLoad.addFile("/usr/share/java/" + RESTEASY_ROOT + "/resteasy-jettison-provider.jar")
 jarLoad.addFile("/usr/share/java/scannotation.jar")
 #     PKI Jars
 jarLoad.addFile("/usr/share/java/pki/pki-certsrv.jar")
@@ -148,12 +156,6 @@ from com.netscape.certsrv.system import ConfigurationResponse
 from com.netscape.cmsutil.util import Utils
 from netscape.security.x509 import X500Name
 
-
-# PKI Python Imports
-import pkiconfig as config
-import pkimessages as log
-
-
 # PKI Deployment Jython Helper Functions
 def generateCRMFRequest(token, keysize, subjectdn, dualkey):
         kg = token.getKeyPairGenerator(KeyPairAlgorithm.RSA)
-- 
1.7.11.7

