Alon Bar-Lev has uploaded a new change for review.

Change subject: packaging: setup: cleanup jasper interaction
......................................................................

packaging: setup: cleanup jasper interaction

1. enforce java use of setup.

2. enforce java.io.tmpdir other than default to avoid cache conflict.

3. collapse ant call into a function.

Change-Id: I06cbc6266821ba537a5111be984c929bd57f0725
Signed-off-by: Alon Bar-Lev <[email protected]>
---
M ovirt-engine-reports.spec.in
M 
packaging/setup/plugins/ovirt-engine-setup/ovirt-engine-reports/jasper/deploy.py
2 files changed, 72 insertions(+), 88 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-reports refs/changes/14/24114/1

diff --git a/ovirt-engine-reports.spec.in b/ovirt-engine-reports.spec.in
index 1889a06..30d5efd 100644
--- a/ovirt-engine-reports.spec.in
+++ b/ovirt-engine-reports.spec.in
@@ -54,7 +54,7 @@
 %endif
 Requires:      %{name}-setup >= %{version}-%{release}
 Requires:      jasperreports-server < 5.6.0
-Requires:      jasperreports-server >= 5.5.0-5
+Requires:      jasperreports-server >= 5.5.0-6
 Requires:      java-1.7.0-openjdk
 Requires:      jpackage-utils
 Requires:      m2crypto
diff --git 
a/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine-reports/jasper/deploy.py
 
b/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine-reports/jasper/deploy.py
index 0479f4c..6519c46 100644
--- 
a/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine-reports/jasper/deploy.py
+++ 
b/packaging/setup/plugins/ovirt-engine-setup/ovirt-engine-reports/jasper/deploy.py
@@ -201,6 +201,60 @@
                 if os.path.exists(entry['dst']):
                     shutil.rmtree(entry['dst'])
 
+    def _buildJs(self, cmd, config):
+        try:
+            myumask = os.umask(0o022)
+
+            rc, stdout, stderr = self.execute(
+                args=(
+                    './js-ant',
+                    '-DmasterPropsSource=%s' % config,
+                    cmd
+                ),
+                envAppend={
+                    'JAVA_HOME': self.environment[
+                        osetupcons.ConfigEnv.JAVA_HOME
+                    ],
+                    'ANT_OPTS': '-Djava.io.tmpdir=%s' % self._javatmp,
+                },
+                cwd=os.path.join(
+                    self.environment[
+                        oreportscons.ConfigEnv.JASPER_HOME
+                    ],
+                    'buildomatic',
+                ),
+            )
+
+            # FIXME: this is a temp WA for an issue in JS
+            # running js-install always returns 0
+            if 'BUILD FAILED' in '\n'.join(stdout + stderr):
+                raise RuntimeError(
+                    _("Cannot build Jasper '{command}'").format(
+                        command=cmd,
+                    )
+                )
+        finally:
+            os.umask(myumask)
+
+            #
+            # foomatic config
+            # contains sensitive information
+            # for some reason jasper recreate
+            # it, so we cannot be fully secured while
+            # running.
+            #
+            if os.path.exists(
+                oreportscons.FileLocations.
+                OVIRT_ENGINE_REPORTS_FOOMATIC_CONFIG
+            ):
+                os.chmod(
+                    (
+                        oreportscons.FileLocations.
+                        OVIRT_ENGINE_REPORTS_FOOMATIC_CONFIG
+                    ),
+                    0o700,
+                )
+
     def _exportJs(self, what, args):
         dest = os.path.join(
             self._temproot,
@@ -218,6 +272,10 @@
                 'buildomatic',
             ),
             envAppend={
+                'JAVA_HOME': self.environment[
+                    osetupcons.ConfigEnv.JAVA_HOME
+                ],
+                'JAVA_OPTS': '-Djava.io.tmpdir=%s' % self._javatmp,
                 'ADDITIONAL_CONFIG_DIR': (
                     oreportscons.FileLocations.
                     OVIRT_ENGINE_REPORTS_FOOMATIC_CONFIG
@@ -240,6 +298,10 @@
                 'buildomatic',
             ),
             envAppend={
+                'JAVA_HOME': self.environment[
+                    osetupcons.ConfigEnv.JAVA_HOME
+                ],
+                'JAVA_OPTS': '-Djava.io.tmpdir=%s' % self._javatmp,
                 'ADDITIONAL_CONFIG_DIR': (
                     oreportscons.FileLocations.
                     OVIRT_ENGINE_REPORTS_FOOMATIC_CONFIG
@@ -449,6 +511,8 @@
     )
     def _init(self):
         self._temproot = tempfile.mkdtemp()
+        self._javatmp = os.path.join(self._temproot, 'tmp')
+        os.mkdir(self._javatmp)
 
     @plugin.event(
         stage=plugin.Stages.STAGE_VALIDATION,
@@ -537,38 +601,7 @@
                 _("Regenerating Jasper's build configuration files")
             )
 
-            try:
-                myumask = os.umask(0o022)
-
-                rc, stdout, stderr = self.execute(
-                    args=(
-                        './js-ant',
-                        '-DmasterPropsSource=%s' % config,
-                        'gen-config',
-                    ),
-                    cwd=os.path.join(
-                        self.environment[
-                            oreportscons.ConfigEnv.JASPER_HOME
-                        ],
-                        'buildomatic',
-                    ),
-                )
-
-                # FIXME: this is a temp WA for an issue in JS
-                # running js-install always returns 0
-                if 'BUILD FAILED' in '\n'.join(stdout + stderr):
-                    raise RuntimeError(
-                        _('Could not regenerate build configuration')
-                    )
-            finally:
-                os.umask(myumask)
-                os.chmod(
-                    (
-                        oreportscons.FileLocations.
-                        OVIRT_ENGINE_REPORTS_FOOMATIC_CONFIG
-                    ),
-                    0o700,
-                )
+            self._buildJs(config=config, cmd='gen-config')
         else:
             raise RuntimeError(
                 _('Could not detect Jasper war folder')
@@ -629,49 +662,12 @@
         os.symlink('..', os.path.join(standalone, 'deployments'))
 
         self.logger.info(_('Deploying Jasper'))
-
-        try:
-            myumask = os.umask(0o022)
-
-            for cmd in (
-                'init-js-db-ce',
-                'import-minimal-ce',
-                'deploy-webapp-ce',
-            ):
-                rc, stdout, stderr = self.execute(
-                    args=(
-                        './js-ant',
-                        '-DmasterPropsSource=%s' % config,
-                        cmd
-                    ),
-                    cwd=os.path.join(
-                        self.environment[
-                            oreportscons.ConfigEnv.JASPER_HOME
-                        ],
-                        'buildomatic',
-                    ),
-                )
-
-                # FIXME: this is a temp WA for an issue in JS
-                # running js-install always returns 0
-                if 'BUILD FAILED' in '\n'.join(stdout + stderr):
-                    raise RuntimeError(
-                        _('Cannot deploy Jasper')
-                    )
-        finally:
-            os.umask(myumask)
-
-        #
-        # foomatic config
-        # contains sensitive information
-        # for some reason jasper recreate
-        # it, so we cannot be fully secured while
-        # running.
-        #
-        os.chmod(
-            oreportscons.FileLocations.OVIRT_ENGINE_REPORTS_FOOMATIC_CONFIG,
-            0o700,
-        )
+        for cmd in (
+            'init-js-db-ce',
+            'import-minimal-ce',
+            'deploy-webapp-ce',
+        ):
+            self._buildJs(config=config, cmd=cmd)
 
         if os.path.exists(standalone):
             shutil.rmtree(standalone)
@@ -877,18 +873,6 @@
                 ),
             )
             os.chmod(f, 0o600)
-
-        #
-        # jasper uses constant temp path
-        # and it does not clean it correctly
-        # so if we touch something as root
-        # service will be unable to touch it
-        # remove these now
-        #
-        for d in ('jasperserver', 'dataSnapshots'):
-            d = os.path.join('/tmp', d)
-            if os.path.exists(d):
-                shutil.rmtree(d)
 
     @plugin.event(
         stage=plugin.Stages.STAGE_CLOSEUP,


-- 
To view, visit http://gerrit.ovirt.org/24114
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I06cbc6266821ba537a5111be984c929bd57f0725
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-reports
Gerrit-Branch: master
Gerrit-Owner: Alon Bar-Lev <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to