From 7cdce1bbc1d24182b4e63845f64d51f20b376230 Mon Sep 17 00:00:00 2001
From: "Endi S. Dewata" <edewata@redhat.com>
Date: Tue, 16 Jul 2013 17:47:18 -0400
Subject: [PATCH] Reorganized deployment tools.

The pkispawn and pkidestroy scripts have been moved into sbin folder.
The Python deployment library and the scriptlets were moved into
pki.server.deployment and pki.server.deployment.scriptlets packages,
respectively.
---
 base/server/CMakeLists.txt                         | 52 ++--------------------
 .../python/pki/server/deployment/__init__.py       |  0
 .../pki/server/deployment}/pkiconfig.py            |  0
 .../pki/server/deployment}/pkihelper.py            |  0
 .../pki/server/deployment}/pkilogging.py           |  0
 .../pki/server/deployment}/pkimanifest.py          |  0
 .../pki/server/deployment}/pkimessages.py          |  0
 .../pki/server/deployment}/pkiparser.py            |  0
 .../pki/server/deployment}/pkiscriptlet.py         |  0
 .../pki/server/deployment/scriptlets/__init__.py   |  0
 .../server/deployment}/scriptlets/configuration.py |  6 +--
 .../server/deployment}/scriptlets/finalization.py  |  8 ++--
 .../scriptlets/infrastructure_layout.py            |  6 +--
 .../deployment}/scriptlets/initialization.py       |  6 +--
 .../deployment}/scriptlets/instance_layout.py      |  6 +--
 .../deployment}/scriptlets/security_databases.py   |  6 +--
 .../server/deployment}/scriptlets/selinux_setup.py |  8 ++--
 .../deployment}/scriptlets/slot_substitution.py    |  6 +--
 .../deployment}/scriptlets/subsystem_layout.py     |  6 +--
 .../deployment}/scriptlets/webapp_deployment.py    |  6 +--
 base/server/{src => sbin}/pkidestroy               | 12 ++---
 base/server/{src => sbin}/pkispawn                 | 12 ++---
 specs/pki-core.spec                                |  6 ++-
 23 files changed, 51 insertions(+), 95 deletions(-)
 create mode 100644 base/server/python/pki/server/deployment/__init__.py
 rename base/server/{src/engine => python/pki/server/deployment}/pkiconfig.py (100%)
 rename base/server/{src/engine => python/pki/server/deployment}/pkihelper.py (100%)
 rename base/server/{src/engine => python/pki/server/deployment}/pkilogging.py (100%)
 rename base/server/{src/engine => python/pki/server/deployment}/pkimanifest.py (100%)
 rename base/server/{src/engine => python/pki/server/deployment}/pkimessages.py (100%)
 rename base/server/{src/engine => python/pki/server/deployment}/pkiparser.py (100%)
 rename base/server/{src/engine => python/pki/server/deployment}/pkiscriptlet.py (100%)
 create mode 100644 base/server/python/pki/server/deployment/scriptlets/__init__.py
 rename base/server/{src => python/pki/server/deployment}/scriptlets/configuration.py (98%)
 rename base/server/{src => python/pki/server/deployment}/scriptlets/finalization.py (97%)
 rename base/server/{src => python/pki/server/deployment}/scriptlets/infrastructure_layout.py (98%)
 rename base/server/{src => python/pki/server/deployment}/scriptlets/initialization.py (98%)
 rename base/server/{src => python/pki/server/deployment}/scriptlets/instance_layout.py (99%)
 rename base/server/{src => python/pki/server/deployment}/scriptlets/security_databases.py (98%)
 rename base/server/{src => python/pki/server/deployment}/scriptlets/selinux_setup.py (98%)
 rename base/server/{src => python/pki/server/deployment}/scriptlets/slot_substitution.py (98%)
 rename base/server/{src => python/pki/server/deployment}/scriptlets/subsystem_layout.py (98%)
 rename base/server/{src => python/pki/server/deployment}/scriptlets/webapp_deployment.py (98%)
 rename base/server/{src => sbin}/pkidestroy (96%)
 rename base/server/{src => sbin}/pkispawn (97%)

diff --git a/base/server/CMakeLists.txt b/base/server/CMakeLists.txt
index 89fa033a82de0e27c6886de0c3e5b51b14991534..ddacbc1ad38fe69fa1e58738d38bd59abab950c0 100644
--- a/base/server/CMakeLists.txt
+++ b/base/server/CMakeLists.txt
@@ -79,23 +79,11 @@ install(
 
 # install executables
 install(
-    FILES
-        src/pkispawn
-        src/pkidestroy
+    DIRECTORY
+        sbin/
     DESTINATION
         ${SBIN_INSTALL_DIR}
-    PERMISSIONS
-        OWNER_EXECUTE OWNER_WRITE OWNER_READ
-        GROUP_EXECUTE GROUP_READ
-        WORLD_EXECUTE WORLD_READ
-)
-
-install(
-    FILES
-        sbin/pki-server-upgrade
-    DESTINATION
-        ${SBIN_INSTALL_DIR}
-    PERMISSIONS
+    FILE_PERMISSIONS
         OWNER_EXECUTE OWNER_WRITE OWNER_READ
         GROUP_EXECUTE GROUP_READ
         WORLD_EXECUTE WORLD_READ
@@ -160,40 +148,6 @@ install(
         ${SYSCONF_INSTALL_DIR}/pki
 )
 
-install(
-    FILES
-        src/engine/pkiconfig.py
-        src/engine/pkihelper.py
-        src/engine/pkilogging.py
-        src/engine/pkimanifest.py
-        src/engine/pkimessages.py
-        src/engine/pkiparser.py
-        src/engine/pkiscriptlet.py
-        src/scriptlets/configuration.py
-        src/scriptlets/finalization.py
-        src/scriptlets/infrastructure_layout.py
-        src/scriptlets/initialization.py
-        src/scriptlets/instance_layout.py
-        src/scriptlets/security_databases.py
-        src/scriptlets/selinux_setup.py
-        src/scriptlets/slot_substitution.py
-        src/scriptlets/subsystem_layout.py
-        src/scriptlets/webapp_deployment.py
-    DESTINATION
-        ${PYTHON_SITE_PACKAGES}/pki/deployment
-    PERMISSIONS
-        OWNER_WRITE OWNER_READ
-        GROUP_READ
-        WORLD_READ
-)
-install(
-    CODE
-        "execute_process(
-            COMMAND
-                ${CMAKE_COMMAND} -E touch
-                \"\$ENV{DESTDIR}${PYTHON_SITE_PACKAGES}/pki/deployment/__init__.py\")"
-)
-
 # install empty directories
 install(CODE "file(MAKE_DIRECTORY \$ENV{DESTDIR}${VAR_INSTALL_DIR}/lock/pki)")
 install(CODE "file(MAKE_DIRECTORY \$ENV{DESTDIR}${VAR_INSTALL_DIR}/run/pki)")
diff --git a/base/server/python/pki/server/deployment/__init__.py b/base/server/python/pki/server/deployment/__init__.py
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/base/server/src/engine/pkiconfig.py b/base/server/python/pki/server/deployment/pkiconfig.py
similarity index 100%
rename from base/server/src/engine/pkiconfig.py
rename to base/server/python/pki/server/deployment/pkiconfig.py
diff --git a/base/server/src/engine/pkihelper.py b/base/server/python/pki/server/deployment/pkihelper.py
similarity index 100%
rename from base/server/src/engine/pkihelper.py
rename to base/server/python/pki/server/deployment/pkihelper.py
diff --git a/base/server/src/engine/pkilogging.py b/base/server/python/pki/server/deployment/pkilogging.py
similarity index 100%
rename from base/server/src/engine/pkilogging.py
rename to base/server/python/pki/server/deployment/pkilogging.py
diff --git a/base/server/src/engine/pkimanifest.py b/base/server/python/pki/server/deployment/pkimanifest.py
similarity index 100%
rename from base/server/src/engine/pkimanifest.py
rename to base/server/python/pki/server/deployment/pkimanifest.py
diff --git a/base/server/src/engine/pkimessages.py b/base/server/python/pki/server/deployment/pkimessages.py
similarity index 100%
rename from base/server/src/engine/pkimessages.py
rename to base/server/python/pki/server/deployment/pkimessages.py
diff --git a/base/server/src/engine/pkiparser.py b/base/server/python/pki/server/deployment/pkiparser.py
similarity index 100%
rename from base/server/src/engine/pkiparser.py
rename to base/server/python/pki/server/deployment/pkiparser.py
diff --git a/base/server/src/engine/pkiscriptlet.py b/base/server/python/pki/server/deployment/pkiscriptlet.py
similarity index 100%
rename from base/server/src/engine/pkiscriptlet.py
rename to base/server/python/pki/server/deployment/pkiscriptlet.py
diff --git a/base/server/python/pki/server/deployment/scriptlets/__init__.py b/base/server/python/pki/server/deployment/scriptlets/__init__.py
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/base/server/src/scriptlets/configuration.py b/base/server/python/pki/server/deployment/scriptlets/configuration.py
similarity index 98%
rename from base/server/src/scriptlets/configuration.py
rename to base/server/python/pki/server/deployment/scriptlets/configuration.py
index d32437f0bc5316cd9f1357aa930636a15a1f7f09..004d8c28d0a9fe398acd36bea4f2a45deda1c24c 100644
--- a/base/server/src/scriptlets/configuration.py
+++ b/base/server/python/pki/server/deployment/scriptlets/configuration.py
@@ -22,9 +22,9 @@
 import json
 
 # PKI Deployment Imports
-from . import pkiconfig as config
-from . import pkimessages as log
-from . import pkiscriptlet
+from .. import pkiconfig as config
+from .. import pkimessages as log
+from .. import pkiscriptlet
 import pki.system
 import pki.encoder
 
diff --git a/base/server/src/scriptlets/finalization.py b/base/server/python/pki/server/deployment/scriptlets/finalization.py
similarity index 97%
rename from base/server/src/scriptlets/finalization.py
rename to base/server/python/pki/server/deployment/scriptlets/finalization.py
index 0d937584a5b513415ab05e966b4d9492969b4087..0573c24ef98b59c8bce74ec2228d5ffe1e9759de 100644
--- a/base/server/src/scriptlets/finalization.py
+++ b/base/server/python/pki/server/deployment/scriptlets/finalization.py
@@ -20,10 +20,10 @@
 #
 
 # PKI Deployment Imports
-from . import pkiconfig as config
-from . import pkimanifest as manifest
-from . import pkimessages as log
-from . import pkiscriptlet
+from .. import pkiconfig as config
+from .. import pkimanifest as manifest
+from .. import pkimessages as log
+from .. import pkiscriptlet
 
 
 # PKI Deployment Finalization Scriptlet
diff --git a/base/server/src/scriptlets/infrastructure_layout.py b/base/server/python/pki/server/deployment/scriptlets/infrastructure_layout.py
similarity index 98%
rename from base/server/src/scriptlets/infrastructure_layout.py
rename to base/server/python/pki/server/deployment/scriptlets/infrastructure_layout.py
index e4d32bb0bae506cf5ac05bbcac7246e6e566e028..5427eebcae4470a01717c12eaaf3fd3a3ba81aa2 100644
--- a/base/server/src/scriptlets/infrastructure_layout.py
+++ b/base/server/python/pki/server/deployment/scriptlets/infrastructure_layout.py
@@ -20,9 +20,9 @@
 #
 
 # PKI Deployment Imports
-from . import pkiconfig as config
-from . import pkimessages as log
-from . import pkiscriptlet
+from .. import pkiconfig as config
+from .. import pkimessages as log
+from .. import pkiscriptlet
 
 
 # PKI Deployment Top-Level Infrastructure Layout Scriptlet
diff --git a/base/server/src/scriptlets/initialization.py b/base/server/python/pki/server/deployment/scriptlets/initialization.py
similarity index 98%
rename from base/server/src/scriptlets/initialization.py
rename to base/server/python/pki/server/deployment/scriptlets/initialization.py
index 55b984693ee5c0f95fb04a99c38a02e81f3d75b1..54349fc01efbe6622f6ceed053bffa6f664dd684 100644
--- a/base/server/src/scriptlets/initialization.py
+++ b/base/server/python/pki/server/deployment/scriptlets/initialization.py
@@ -20,9 +20,9 @@
 #
 
 # PKI Deployment Imports
-from . import pkiconfig as config
-from . import pkimessages as log
-from . import pkiscriptlet
+from .. import pkiconfig as config
+from .. import pkimessages as log
+from .. import pkiscriptlet
 
 
 # PKI Deployment Initialization Scriptlet
diff --git a/base/server/src/scriptlets/instance_layout.py b/base/server/python/pki/server/deployment/scriptlets/instance_layout.py
similarity index 99%
rename from base/server/src/scriptlets/instance_layout.py
rename to base/server/python/pki/server/deployment/scriptlets/instance_layout.py
index fe02a9f9d6b23eba8ce8439c4f9089e8c8129586..081d6402916650ab526484713e227ea62571c2ea 100644
--- a/base/server/src/scriptlets/instance_layout.py
+++ b/base/server/python/pki/server/deployment/scriptlets/instance_layout.py
@@ -24,9 +24,9 @@ import os
 
 
 # PKI Deployment Imports
-from . import pkiconfig as config
-from . import pkimessages as log
-from . import pkiscriptlet
+from .. import pkiconfig as config
+from .. import pkimessages as log
+from .. import pkiscriptlet
 
 
 # PKI Deployment Instance Layout Scriptlet
diff --git a/base/server/src/scriptlets/security_databases.py b/base/server/python/pki/server/deployment/scriptlets/security_databases.py
similarity index 98%
rename from base/server/src/scriptlets/security_databases.py
rename to base/server/python/pki/server/deployment/scriptlets/security_databases.py
index aa522ce043e51f3cbdc91efdb228a67c2fcbc5e7..3d3193cefe6a39fc1c655a7049e00391bd6dd5cc 100644
--- a/base/server/src/scriptlets/security_databases.py
+++ b/base/server/python/pki/server/deployment/scriptlets/security_databases.py
@@ -20,9 +20,9 @@
 #
 
 # PKI Deployment Imports
-from . import pkiconfig as config
-from . import pkimessages as log
-from . import pkiscriptlet
+from .. import pkiconfig as config
+from .. import pkimessages as log
+from .. import pkiscriptlet
 
 
 # PKI Deployment Security Databases Scriptlet
diff --git a/base/server/src/scriptlets/selinux_setup.py b/base/server/python/pki/server/deployment/scriptlets/selinux_setup.py
similarity index 98%
rename from base/server/src/scriptlets/selinux_setup.py
rename to base/server/python/pki/server/deployment/scriptlets/selinux_setup.py
index 9f9ad8b8bd29a6017c313889b0b4dfd5715961cd..177233afc10c0d21880d0b7505eb3bf721f29881 100644
--- a/base/server/src/scriptlets/selinux_setup.py
+++ b/base/server/python/pki/server/deployment/scriptlets/selinux_setup.py
@@ -25,10 +25,10 @@ if selinux.is_selinux_enabled():
     import seobject
 
 # PKI Deployment Imports
-from . import pkiconfig as config
-from .pkiconfig import pki_selinux_config_ports as ports
-from . import pkimessages as log
-from . import pkiscriptlet
+from .. import pkiconfig as config
+from ..pkiconfig import pki_selinux_config_ports as ports
+from .. import pkimessages as log
+from .. import pkiscriptlet
 
 
 # PKI Deployment Selinux Setup Scriptlet
diff --git a/base/server/src/scriptlets/slot_substitution.py b/base/server/python/pki/server/deployment/scriptlets/slot_substitution.py
similarity index 98%
rename from base/server/src/scriptlets/slot_substitution.py
rename to base/server/python/pki/server/deployment/scriptlets/slot_substitution.py
index 2bb888dfd2e28fcf2ed2e54c5b2d3eec04d0ce22..726b6dfc09dd5a05b774e358857c4017c9525cc2 100644
--- a/base/server/src/scriptlets/slot_substitution.py
+++ b/base/server/python/pki/server/deployment/scriptlets/slot_substitution.py
@@ -20,9 +20,9 @@
 #
 
 # PKI Deployment Imports
-from . import pkiconfig as config
-from . import pkimessages as log
-from . import pkiscriptlet
+from .. import pkiconfig as config
+from .. import pkimessages as log
+from .. import pkiscriptlet
 
 
 # PKI Deployment Slot Substitution Scriptlet
diff --git a/base/server/src/scriptlets/subsystem_layout.py b/base/server/python/pki/server/deployment/scriptlets/subsystem_layout.py
similarity index 98%
rename from base/server/src/scriptlets/subsystem_layout.py
rename to base/server/python/pki/server/deployment/scriptlets/subsystem_layout.py
index 81dedf68c9aaff78c7990eec290897807ec1f989..8aae3f6c614db9f2b64b3e5becfdfafcff6389ce 100644
--- a/base/server/src/scriptlets/subsystem_layout.py
+++ b/base/server/python/pki/server/deployment/scriptlets/subsystem_layout.py
@@ -20,9 +20,9 @@
 #
 
 # PKI Deployment Imports
-from . import pkiconfig as config
-from . import pkimessages as log
-from . import pkiscriptlet
+from .. import pkiconfig as config
+from .. import pkimessages as log
+from .. import pkiscriptlet
 
 
 # PKI Deployment Subsystem Layout Scriptlet
diff --git a/base/server/src/scriptlets/webapp_deployment.py b/base/server/python/pki/server/deployment/scriptlets/webapp_deployment.py
similarity index 98%
rename from base/server/src/scriptlets/webapp_deployment.py
rename to base/server/python/pki/server/deployment/scriptlets/webapp_deployment.py
index 4a37b6df9651c816f27144447ae5fdcaca92297e..ccbf4ea906c0de2ed951f66f22c51b5b183355ac 100644
--- a/base/server/src/scriptlets/webapp_deployment.py
+++ b/base/server/python/pki/server/deployment/scriptlets/webapp_deployment.py
@@ -23,9 +23,9 @@
 import os
 
 # PKI Deployment Imports
-from . import pkiconfig as config
-from . import pkimessages as log
-from . import pkiscriptlet
+from .. import pkiconfig as config
+from .. import pkimessages as log
+from .. import pkiscriptlet
 
 
 # PKI Web Application Deployment Scriptlet
diff --git a/base/server/src/pkidestroy b/base/server/sbin/pkidestroy
similarity index 96%
rename from base/server/src/pkidestroy
rename to base/server/sbin/pkidestroy
index 5438075632f00054a85697768c8531401bb6a896..e61b3fabedd674a2272059bbcc6617c253934d9f 100755
--- a/base/server/src/pkidestroy
+++ b/base/server/sbin/pkidestroy
@@ -34,11 +34,11 @@ try:
     import subprocess
     import time
     from time import strftime as date
-    from pki.deployment import pkiconfig as config
-    from pki.deployment.pkiparser import PKIConfigParser
-    from pki.deployment import pkilogging
-    from pki.deployment import pkimessages as log
-    import pki.deployment.pkihelper as util
+    from pki.server.deployment import pkiconfig as config
+    from pki.server.deployment.pkiparser import PKIConfigParser
+    from pki.server.deployment import pkilogging
+    from pki.server.deployment import pkimessages as log
+    import pki.server.deployment.pkihelper as util
 except ImportError:
     print >> sys.stderr, """\
 There was a problem importing one of the required Python modules. The
@@ -243,7 +243,7 @@ def main(argv):
     deployer = util.PKIDeployer(parser.pki_master_dict)
     rv = 0
     for pki_scriptlet in pki_subsystem_scriptlets:
-        scriptlet = __import__("pki.deployment." +
+        scriptlet = __import__("pki.server.deployment.scriptlets." +
                                pki_scriptlet,
                                fromlist = [pki_scriptlet])
         instance = scriptlet.PkiScriptlet()
diff --git a/base/server/src/pkispawn b/base/server/sbin/pkispawn
similarity index 97%
rename from base/server/src/pkispawn
rename to base/server/sbin/pkispawn
index 706e44cdff6ad9f555119576b9d0f0605798cd54..fd65fa2f3116f164fc9b31d0c38c3c2ebd3997ba 100755
--- a/base/server/src/pkispawn
+++ b/base/server/sbin/pkispawn
@@ -37,11 +37,11 @@ try:
     import time
     import traceback
     from time import strftime as date
-    from pki.deployment import pkiconfig as config
-    from pki.deployment.pkiparser import PKIConfigParser
-    from pki.deployment import pkilogging
-    from pki.deployment import pkimessages as log
-    import pki.deployment.pkihelper as util
+    from pki.server.deployment import pkiconfig as config
+    from pki.server.deployment.pkiparser import PKIConfigParser
+    from pki.server.deployment import pkilogging
+    from pki.server.deployment import pkimessages as log
+    import pki.server.deployment.pkihelper as util
 except ImportError:
     print >> sys.stderr, """\
 There was a problem importing one of the required Python modules. The
@@ -364,7 +364,7 @@ def main(argv):
     deployer = util.PKIDeployer(parser.pki_master_dict, parser.pki_slots_dict)
     rv = 0
     for pki_scriptlet in pki_subsystem_scriptlets:
-        scriptlet = __import__("pki.deployment." +
+        scriptlet = __import__("pki.server.deployment.scriptlets." +
                                pki_scriptlet,
                                fromlist=[pki_scriptlet])
         instance = scriptlet.PkiScriptlet()
diff --git a/specs/pki-core.spec b/specs/pki-core.spec
index fe0564563b7b08d153aacf20a74ecf515a4db425..31754f54b7cefe1b3e7bd0adda0fcb0ed2ee9b1d 100644
--- a/specs/pki-core.spec
+++ b/specs/pki-core.spec
@@ -5,7 +5,7 @@ distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
 
 Name:             pki-core
 Version:          10.1.0
-Release:          0.4%{?dist}
+Release:          0.5%{?dist}
 Summary:          Certificate System - PKI Core Components
 URL:              http://pki.fedoraproject.org/
 License:          GPLv2
@@ -944,7 +944,6 @@ fi
 %{_sbindir}/pkidestroy
 %{_sbindir}/pki-server-upgrade
 #%{_bindir}/pki-setup-proxy
-%{python_sitelib}/pki/deployment/
 %{python_sitelib}/pki/server/
 %dir %{_datadir}/pki/deployment
 %{_datadir}/pki/deployment/config/
@@ -1088,6 +1087,9 @@ fi
 
 
 %changelog
+* Tue Jul 16 2013 Endi S. Dewata <edewata@redhat.com> 10.1.0-0.5
+- Reorganized deployment tools.
+
 * Tue Jul 9 2013 Ade Lee <alee@redhat.com> 10.1.0-0.4
 - Bugzilla Bug 973224 -  resteasy-base must be split into subpackages
   to simplify dependencies
-- 
1.8.1.4

