[thermostat/f19] Upgrade to upstream 0.9.0

jerboaa jerboaa at fedoraproject.org
Fri May 24 17:19:49 UTC 2013


commit fd83556a1936dc176d8d390500bf6b4f08dc6ac0
Author: Severin Gehwolf <sgehwolf at redhat.com>
Date:   Fri May 24 19:00:13 2013 +0200

    Upgrade to upstream 0.9.0

 .gitignore                   |    1 +
 fix_natives.patch            |   73 ++++++++++++
 init_layout_new.patch        |  251 ++++++++++++++++++++++++++++++++++++++++++
 per-user-home.patch          |  109 ------------------
 source_setup_user_home.patch |   16 +++
 sources                      |    2 +-
 systemd_fixes.patch          |   22 ++++
 thermostat-sysconfig         |    7 +
 thermostat.spec              |  142 +++++++++++++++++++-----
 username_util.patch          |   88 +++++++++++++++
 10 files changed, 574 insertions(+), 137 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 5a5484b..bb5f3d9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,3 +8,4 @@
 /thermostat-d6145521e208.tar.bz2
 /thermostat-0.6.0.tar.gz
 /thermostat-97e66ed2e4ae.tar.bz2
+/thermostat-0.9.0.tar.gz
diff --git a/fix_natives.patch b/fix_natives.patch
index 3a7fc33..0310c56 100644
--- a/fix_natives.patch
+++ b/fix_natives.patch
@@ -19,6 +19,58 @@ diff --git a/agent/core/src/main/java/com/redhat/thermostat/utils/hostname/HostN
      }
      
      public static String getLocalHostName() {
+diff --git a/agent/core/src/main/java/com/redhat/thermostat/utils/username/internal/UserNameUtilImpl.java b/agent/core/src/main/java/com/redhat/thermostat/utils/username/internal/UserNameUtilImpl.java
+--- a/agent/core/src/main/java/com/redhat/thermostat/utils/username/internal/UserNameUtilImpl.java
++++ b/agent/core/src/main/java/com/redhat/thermostat/utils/username/internal/UserNameUtilImpl.java
+@@ -36,6 +36,7 @@
+ 
+ package com.redhat.thermostat.utils.username.internal;
+ 
++import java.io.File;
+ import java.io.IOException;
+ 
+ import com.redhat.thermostat.utils.username.UserNameUtil;
+@@ -43,11 +44,8 @@
+ public class UserNameUtilImpl implements UserNameUtil {
+     
+     static {
+-        /*
+-         * TODO Change to System.load
+-         * http://icedtea.classpath.org/pipermail/thermostat/2013-May/006657.html
+-         */
+-        System.loadLibrary("UserNameUtilWrapper");
++        String home = System.getenv("THERMOSTAT_HOME");
++        System.load(home + File.separatorChar + "libs" + File.separatorChar + "native" + File.separatorChar + "libUserNameUtilWrapper.so");
+     }
+     
+     public String getUserName(long uid) throws IOException {
+diff --git a/distribution/scripts/thermostat b/distribution/scripts/thermostat
+--- a/distribution/scripts/thermostat
++++ b/distribution/scripts/thermostat
+@@ -51,7 +51,6 @@
+ 
+ # plus the main services we use and export
+ SERVICE_CLASSPATH="${THERMOSTAT_LIBS}/*"
+-SERVICE_NATIVE="${THERMOSTAT_LIBS}/native"
+ 
+ SERVICE_CLASSPATH="${TOOLS_JAR}:${SERVICE_CLASSPATH}"
+ THERMOSTAT_MAIN="com.redhat.thermostat.main.Thermostat"
+@@ -100,13 +99,13 @@
+     if [ x"$PID_FILE" = "x" ]; then
+         usage 
+     else
+-        ${JAVA} "${JAVA_ARGS[@]}" -Djava.library.path=${SERVICE_NATIVE} -cp ${SERVICE_CLASSPATH} ${THERMOSTAT_MAIN} "${ARGS[@]}" &
++        ${JAVA} "${JAVA_ARGS[@]}" -cp ${SERVICE_CLASSPATH} ${THERMOSTAT_MAIN} "${ARGS[@]}" &
+         retval=$?
+         echo $! > $PID_FILE
+         retval=$(( $retval + $? ))
+     fi
+ else
+-    ${JAVA} "${JAVA_ARGS[@]}" -Djava.library.path=${SERVICE_NATIVE} -cp ${SERVICE_CLASSPATH} ${THERMOSTAT_MAIN} "${ARGS[@]}"
++    ${JAVA} "${JAVA_ARGS[@]}" -cp ${SERVICE_CLASSPATH} ${THERMOSTAT_MAIN} "${ARGS[@]}"
+     retval=$?
+ fi
+ exit $retval
 diff --git a/keyring/src/main/java/com/redhat/thermostat/utils/keyring/GnomeKeyringLibraryNative.java b/keyring/src/main/java/com/redhat/thermostat/utils/keyring/GnomeKeyringLibraryNative.java
 --- a/keyring/src/main/java/com/redhat/thermostat/utils/keyring/GnomeKeyringLibraryNative.java
 +++ b/keyring/src/main/java/com/redhat/thermostat/utils/keyring/GnomeKeyringLibraryNative.java
@@ -37,3 +89,24 @@ diff --git a/keyring/src/main/java/com/redhat/thermostat/utils/keyring/GnomeKeyr
      }
      
      public GnomeKeyringLibraryNative() {
+diff --git a/laf-utils/src/main/java/com/redhat/thermostat/internal/utils/laf/gtk/GTKThemeUtils.java b/laf-utils/src/main/java/com/redhat/thermostat/internal/utils/laf/gtk/GTKThemeUtils.java
+--- a/laf-utils/src/main/java/com/redhat/thermostat/internal/utils/laf/gtk/GTKThemeUtils.java
++++ b/laf-utils/src/main/java/com/redhat/thermostat/internal/utils/laf/gtk/GTKThemeUtils.java
+@@ -37,6 +37,7 @@
+ package com.redhat.thermostat.internal.utils.laf.gtk;
+ 
+ import java.awt.Color;
++import java.io.File;
+ import java.lang.reflect.Constructor;
+ import java.lang.reflect.Method;
+ 
+@@ -48,7 +49,8 @@
+     private static boolean initialized;
+     static {
+         try {
+-            System.loadLibrary("GTKThemeUtils");
++            String home = System.getenv("THERMOSTAT_HOME");
++            System.load(home + File.separatorChar + "libs" + File.separatorChar + "native" + File.separatorChar + "libGTKThemeUtils.so");
+             initialized = init();
+         } catch (UnsatisfiedLinkError ignore) {}
+     }
diff --git a/init_layout_new.patch b/init_layout_new.patch
new file mode 100644
index 0000000..5bbb3a2
--- /dev/null
+++ b/init_layout_new.patch
@@ -0,0 +1,251 @@
+diff -r c6ad4123876e -r a04145c9a5d3 distribution/scripts/thermostat
+--- a/distribution/scripts/thermostat	Thu May 23 11:12:20 2013 -0400
++++ b/distribution/scripts/thermostat	Fri May 24 16:12:14 2013 +0200
+@@ -40,9 +40,12 @@
+ JAVA_DIR="@java.dir@"
+ JAVA="@java.home@/bin/java"
+ 
+-if [ x"$THERMOSTAT_HOME" = x ] ; then
+-  THERMOSTAT_HOME="@thermostat.home@"
++if [ x"$THERMOSTAT_INSTALL_DIR" = x ] ; then
++  THERMOSTAT_INSTALL_DIR="@thermostat.home@"
+ fi
++# Not always are installation directory and thermostat home one and
++# the same location.
++THERMOSTAT_HOME=${THERMOSTAT_INSTALL_DIR}
+ export THERMOSTAT_HOME
+ THERMOSTAT_LIBS="${THERMOSTAT_HOME}/libs"
+ 
+diff -r c6ad4123876e -r a04145c9a5d3 distribution/scripts/thermostat-init-layout
+--- a/distribution/scripts/thermostat-init-layout	Thu May 23 11:12:20 2013 -0400
++++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
+@@ -1,99 +0,0 @@
+-#!/bin/bash
+-#
+-# Copyright 2012, 2013 Red Hat, Inc.
+-#
+-# This file is part of Thermostat.
+-#
+-# Thermostat is free software; you can redistribute it and/or modify
+-# it under the terms of the GNU General Public License as published
+-# by the Free Software Foundation; either version 2, or (at your
+-# option) any later version.
+-#
+-# Thermostat is distributed in the hope that it will be useful, but
+-# WITHOUT ANY WARRANTY; without even the implied warranty of
+-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+-# General Public License for more details.
+-#
+-# You should have received a copy of the GNU General Public License
+-# along with Thermostat; see the file COPYING.  If not see
+-# <http://www.gnu.org/licenses/>.
+-#
+-# Linking this code with other modules is making a combined work
+-# based on this code.  Thus, the terms and conditions of the GNU
+-# General Public License cover the whole combination.
+-#
+-# As a special exception, the copyright holders of this code give
+-# you permission to link this code with independent modules to
+-# produce an executable, regardless of the license terms of these
+-# independent modules, and to copy and distribute the resulting
+-# executable under terms of your choice, provided that you also
+-# meet, for each linked independent module, the terms and conditions
+-# of the license of that module.  An independent module is a module
+-# which is not derived from or based on this code.  If you modify
+-# this code, you may extend this exception to your version of the
+-# library, but you are not obligated to do so.  If you do not wish
+-# to do so, delete this exception statement from your version.
+-#
+-#####################################################################
+-#
+-# Some necessary variables.
+-if [ "$THERMOSTAT_HOME" = "" ]; then
+-    echo "THERMOSTAT_HOME not set!"
+-
+-else
+-    THERMOSTAT_STORAGE="${THERMOSTAT_HOME}/storage/db"
+-    THERMOSTAT_LOG="${THERMOSTAT_HOME}/storage/logs"
+-    THERMOSTAT_PID="${THERMOSTAT_HOME}/storage/run"
+-    THERMOSTAT_BIN="${THERMOSTAT_HOME}/bin"
+-    THERMOSTAT_AGENT_LOG="${THERMOSTAT_HOME}/agent/logs"
+-    THERMOSTAT_AGENT_RUN="${THERMOSTAT_HOME}/agent/run"
+-    THEMROSTAT_CLIENT="${THERMOSTAT_HOME}/client"
+-    THERMOSTAT_LIBS="${THERMOSTAT_HOME}/libs/native"
+-    THERMOSTAT_OSGI_CACHE="${THERMOSTAT_HOME}/osgi-cache"
+-
+-    if [ ! -d "${THERMOSTAT_STORAGE}" ] ; then
+-        echo "creating ${THERMOSTAT_STORAGE}"
+-        mkdir -p ${THERMOSTAT_STORAGE}
+-    fi
+-    
+-    if [ ! -d "${THERMOSTAT_LOG}" ] ; then
+-        echo "creating ${THERMOSTAT_LOG}"
+-        mkdir -p ${THERMOSTAT_LOG}
+-    fi
+-    
+-    if [ ! -d "${THERMOSTAT_PID}" ] ; then
+-        echo "creating ${THERMOSTAT_PID}"
+-        mkdir -p ${THERMOSTAT_PID}
+-    fi
+-    
+-    if [ ! -e "${THERMOSTAT_BIN}" ] ; then
+-        echo "creating ${THERMOSTAT_BIN}"
+-        mkdir -p ${THERMOSTAT_BIN}
+-    fi
+-    
+-    if [ ! -d "${THERMOSTAT_AGENT_LOG}" ] ; then
+-        echo "creating ${THERMOSTAT_AGENT_LOG}"
+-        mkdir -p ${THERMOSTAT_AGENT_LOG}
+-    fi
+-    
+-    if [ ! -d "${THERMOSTAT_AGENT_RUN}" ] ; then
+-        echo "creating ${THERMOSTAT_AGENT_RUN}"
+-        mkdir -p ${THERMOSTAT_AGENT_RUN}
+-    fi
+-
+-    if [ ! -d "${THERMOSTAT_CLIENT}" ] ; then
+-        echo "creating ${THERMOSTAT_CLIENT}"
+-        mkdir -p "${THERMOSTAT_CLIENT}"
+-    fi
+-
+-    if [ ! -d "${THERMOSTAT_LIBS}" ] ; then
+-        echo "creating ${THERMOSTAT_LIBS}"
+-        mkdir -p ${THERMOSTAT_LIBS}
+-    fi
+-
+-    if [ ! -d "${THERMOSTAT_OSGI_CACHE}" ] ; then
+-        echo "creating ${THERMOSTAT_OSGI_CACHE}"
+-        mkdir -p ${THERMOSTAT_OSGI_CACHE}
+-    fi
+-fi
+-
+diff -r c6ad4123876e -r a04145c9a5d3 distribution/scripts/thermostat-setup-user-home
+--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
++++ b/distribution/scripts/thermostat-setup-user-home	Fri May 24 16:12:14 2013 +0200
+@@ -0,0 +1,126 @@
++#!/bin/bash
++#
++# Copyright 2012, 2013 Red Hat, Inc.
++#
++# This file is part of Thermostat.
++#
++# Thermostat is free software; you can redistribute it and/or modify
++# it under the terms of the GNU General Public License as published
++# by the Free Software Foundation; either version 2, or (at your
++# option) any later version.
++#
++# Thermostat is distributed in the hope that it will be useful, but
++# WITHOUT ANY WARRANTY; without even the implied warranty of
++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++# General Public License for more details.
++#
++# You should have received a copy of the GNU General Public License
++# along with Thermostat; see the file COPYING.  If not see
++# <http://www.gnu.org/licenses/>.
++#
++# Linking this code with other modules is making a combined work
++# based on this code.  Thus, the terms and conditions of the GNU
++# General Public License cover the whole combination.
++#
++# As a special exception, the copyright holders of this code give
++# you permission to link this code with independent modules to
++# produce an executable, regardless of the license terms of these
++# independent modules, and to copy and distribute the resulting
++# executable under terms of your choice, provided that you also
++# meet, for each linked independent module, the terms and conditions
++# of the license of that module.  An independent module is a module
++# which is not derived from or based on this code.  If you modify
++# this code, you may extend this exception to your version of the
++# library, but you are not obligated to do so.  If you do not wish
++# to do so, delete this exception statement from your version.
++#
++#####################################################################
++#
++# Some necessary variables.
++if [ "${THERMOSTAT_INSTALL_DIR}_" == "_" ]; then
++    echo "THERMOSTAT_INSTALL_DIR not set!" 1>&2
++    exit 1
++fi
++
++# If run as unprivilged user, copy/symlink files from system install
++if [ "${THERMOSTAT_HOME}_" == "_" ]; then
++    # Thermostat run as regular user (no systemd)
++    THERMOSTAT_HOME="${HOME}/.thermostat"
++
++    # Set up structure for users
++    THERMOSTAT_STORAGE="${THERMOSTAT_HOME}/storage/db"
++    THERMOSTAT_LOG="${THERMOSTAT_HOME}/storage/logs"
++    THERMOSTAT_PID="${THERMOSTAT_HOME}/storage/run"
++    THERMOSTAT_BIN="${THERMOSTAT_HOME}/bin"
++    THERMOSTAT_AGENT_LOG="${THERMOSTAT_HOME}/agent/logs"
++    THERMOSTAT_AGENT_RUN="${THERMOSTAT_HOME}/agent/run"
++    THERMOSTAT_CLIENT="${THERMOSTAT_HOME}/client"
++    THERMOSTAT_LIBS="${THERMOSTAT_HOME}/libs"
++    THERMOSTAT_PLUGINS="${THERMOSTAT_HOME}/plugins"
++    THERMOSTAT_ETC="${THERMOSTAT_HOME}/etc"
++    THERMOSTAT_OSGI_CACHE="${THERMOSTAT_HOME}/osgi-cache"
++
++    if [ ! -d "${THERMOSTAT_STORAGE}" ] ; then
++        echo "creating ${THERMOSTAT_STORAGE}"
++        mkdir -p ${THERMOSTAT_STORAGE}
++    fi
++
++    if [ ! -e  "${THERMOSTAT_HOME}/storage/db.properties" ] ; then
++        echo "copying over ${THERMOSTAT_HOME}/storage/db.properties"
++        cp "${THERMOSTAT_INSTALL_DIR}/storage/db.properties" "${THERMOSTAT_HOME}/storage"
++    fi
++
++    if [ ! -d "${THERMOSTAT_LOG}" ] ; then
++        echo "creating ${THERMOSTAT_LOG}"
++        mkdir -p ${THERMOSTAT_LOG}
++    fi
++    
++    if [ ! -d "${THERMOSTAT_PID}" ] ; then
++        echo "creating ${THERMOSTAT_PID}"
++        mkdir -p ${THERMOSTAT_PID}
++    fi
++    
++    if [ ! -e "${THERMOSTAT_BIN}" ] ; then
++        echo "creating ${THERMOSTAT_BIN}"
++        mkdir -p ${THERMOSTAT_BIN}
++    fi
++    
++    if [ ! -d "${THERMOSTAT_AGENT_LOG}" ] ; then
++        echo "creating ${THERMOSTAT_AGENT_LOG}"
++        mkdir -p ${THERMOSTAT_AGENT_LOG}
++    fi
++    
++    if [ ! -d "${THERMOSTAT_AGENT_RUN}" ] ; then
++        echo "creating ${THERMOSTAT_AGENT_RUN}"
++        mkdir -p ${THERMOSTAT_AGENT_RUN}
++    fi
++
++    if [ ! -e "${THERMOSTAT_HOME}/agent/agent.properties" ] ; then
++        cp "${THERMOSTAT_INSTALL_DIR}"/agent/agent.properties "${THERMOSTAT_HOME}"/agent/agent.properties
++    fi
++
++    if [ ! -d "${THERMOSTAT_CLIENT}" ] ; then
++        echo "creating ${THERMOSTAT_CLIENT}"
++        mkdir -p "${THERMOSTAT_CLIENT}"
++    fi
++
++    if [ ! -d "${THERMOSTAT_LIBS}" ] ; then
++        echo "creating ${THERMOSTAT_LIBS}"
++        ln -s "${THERMOSTAT_INSTALL_DIR}"/libs "${THERMOSTAT_LIBS}"
++    fi
++
++    if [ ! -d "${THERMOSTAT_PLUGINS}" ] ; then
++        echo "creating ${THERMOSTAT_PLUGINS}"
++        ln -s "${THERMOSTAT_INSTALL_DIR}"/plugins "${THERMOSTAT_PLUGINS}"
++    fi
++
++    if [ ! -d "${THERMOSTAT_ETC}" ] ; then
++        echo "creating ${THERMOSTAT_ETC}"
++        cp -r "${THERMOSTAT_INSTALL_DIR}"/etc "${THERMOSTAT_ETC}"
++    fi
++
++    if [ ! -d "${THERMOSTAT_OSGI_CACHE}" ] ; then
++        echo "creating ${THERMOSTAT_OSGI_CACHE}"
++        mkdir -p ${THERMOSTAT_OSGI_CACHE}
++    fi
++fi
diff --git a/source_setup_user_home.patch b/source_setup_user_home.patch
new file mode 100644
index 0000000..0705097
--- /dev/null
+++ b/source_setup_user_home.patch
@@ -0,0 +1,16 @@
+diff --git a/distribution/scripts/thermostat b/distribution/scripts/thermostat
+--- a/distribution/scripts/thermostat
++++ b/distribution/scripts/thermostat
+@@ -43,9 +43,9 @@
+ if [ x"$THERMOSTAT_INSTALL_DIR" = x ] ; then
+   THERMOSTAT_INSTALL_DIR="@thermostat.home@"
+ fi
+-# Not always are installation directory and thermostat home one and
+-# the same location.
+-THERMOSTAT_HOME=${THERMOSTAT_INSTALL_DIR}
++
++. ${THERMOSTAT_INSTALL_DIR}/bin/thermostat-setup-user-home
++
+ export THERMOSTAT_HOME
+ THERMOSTAT_LIBS="${THERMOSTAT_HOME}/libs"
+ 
diff --git a/sources b/sources
index f7ebce1..800e131 100644
--- a/sources
+++ b/sources
@@ -1 +1 @@
-4b77c7f8e7ffdb6d856bd65edc2c89c1  thermostat-97e66ed2e4ae.tar.bz2
+595043310e01c34ea7e8a488ce39e2a4  thermostat-0.9.0.tar.gz
diff --git a/systemd_fixes.patch b/systemd_fixes.patch
new file mode 100644
index 0000000..08f35cf
--- /dev/null
+++ b/systemd_fixes.patch
@@ -0,0 +1,22 @@
+diff --git a/distribution/systemd/thermostat-agent.service b/distribution/systemd/thermostat-agent.service
+--- a/distribution/systemd/thermostat-agent.service
++++ b/distribution/systemd/thermostat-agent.service
+@@ -45,6 +45,7 @@
+ 
+ [Service]
+ Type=forking
++EnvironmentFile=-/etc/sysconfig/thermostat
+ ExecStart=@thermostat.home@/bin/thermostat-agent-sysd start
+ ExecStop=@thermostat.home@/bin/thermostat-agent-sysd stop
+ PIDFile=@thermostat.home@/agent/run/thermostat-agent.pid
+diff --git a/distribution/systemd/thermostat-storage.service b/distribution/systemd/thermostat-storage.service
+--- a/distribution/systemd/thermostat-storage.service
++++ b/distribution/systemd/thermostat-storage.service
+@@ -45,6 +45,7 @@
+ 
+ [Service]
+ Type=forking
++EnvironmentFile=-/etc/sysconfig/thermostat
+ ExecStart=@thermostat.home@/bin/thermostat storage --start
+ ExecStop=@thermostat.home@/bin/thermostat storage --stop
+ PIDFile=@thermostat.home@/storage/run/db.pid
diff --git a/thermostat-sysconfig b/thermostat-sysconfig
new file mode 100644
index 0000000..09f8264
--- /dev/null
+++ b/thermostat-sysconfig
@@ -0,0 +1,7 @@
+# This file is "sourced" for systemd services only
+#
+# If thermostat {storage,agent} is run via systemd,
+# data directories are in /usr/share/thermostat
+#
+# Do not change this unless you know what you are doing
+THERMOSTAT_HOME=/usr/share/thermostat/
diff --git a/thermostat.spec b/thermostat.spec
index 7ad83e6..5aa594f 100644
--- a/thermostat.spec
+++ b/thermostat.spec
@@ -1,33 +1,49 @@
+# Global directory definitions
+%global system_datadir %{_var}/lib/%{name}/storage
+%global system_cachedir %{_var}/cache/%{name}/osgi-cache
+%global system_logdir %{_var}/log/%{name}
+%global system_statedir %{_localstatedir}/run/%{name}
 # Uncomment to build from snapshot out of hg.  See also Release and Source0
-%global hgrev 97e66ed2e4ae
+#%global hgrev 97e66ed2e4ae
 
 Name:       thermostat
-Version:    0.8.0
+Version:    0.9.0
 # If building from snapshot out of hg, uncomment and adjust below value as appropriate
-Release:    0.1.20130521hg%{hgrev}%{?dist}
-#Release:    17%{?dist}
+#Release:    0.1.20130521hg%{hgrev}%{?dist}
+Release:    1%{?dist}
 Summary:    A monitoring and serviceability tool for OpenJDK
 License:    GPLv2+ with exceptions
 URL:        http://icedtea.classpath.org/thermostat/
 # This is the source URL to be used for released versions
-#Source0:    http://icedtea.classpath.org/download/%{name}/%{name}-%{version}.tar.gz
+Source0:    http://icedtea.classpath.org/download/%{name}/%{name}-%{version}.tar.gz
 # This is the source to be used for hg snapshot versions
 #wget -O thermostat-%{hgrev}.tar.bz2 http://icedtea.classpath.org/hg/%{name}/archive/%{hgrev}.tar.bz2
-Source0:    thermostat-%{hgrev}.tar.bz2
-Patch0:     per-user-home.patch
+#Source0:    thermostat-%{hgrev}.tar.bz2
+# This is not suitable for upstream as it is *very* Fedora specific
+Source1:    thermostat-sysconfig
+# This has been proposed upstream. Should get removed next release.
+Patch0:     init_layout_new.patch
+# This is not suitable for upstream. Distribution specific workings.
+Patch1:     source_setup_user_home.patch
+# Fix JNI class UserNameUtilImpl (proposed upstream remove next release).
+Patch2:     username_util.patch
 # Use System.load() over System.loadLibrary() as per Java packaging guidelines.
 # Should be upstream-able.
-Patch1:     fix_natives.patch
+Patch3:     fix_natives.patch
 # jfreechart isn't a bundle upstream. Also some httpclient* related bundles
 # include transitive deps, which is properly done in Fedora.
-Patch2:     fix_bundle_loading.patch
+Patch4:     fix_bundle_loading.patch
 # There seems to be a problem when using class vs. class name.
 # Proposed upstream. Remove once pushed upstream.
-Patch3:     fix_jmx_compilation_error.patch
+Patch5:     fix_jmx_compilation_error.patch
 # Extending webservice command (which won't exist after a fedora build) fix.
-Patch4:     extend_webservice_fix.patch
-# Only suitable for packaged hg versions (sets log level to WARNING).
-Patch5:     fix_loglevel.patch
+Patch6:     extend_webservice_fix.patch
+# Sets the default log level to something reasonable (if during release procedure
+# it was forgotten to set it). Not upstream-able.
+Patch7:     fix_loglevel.patch
+# systemd files need to source for THERMOSTAT_HOME. Proposed upstream. Should get
+# removed for the next upstream release.
+Patch8:     systemd_fixes.patch
 
 BuildRequires:  java-devel >= 1:1.7.0
 BuildRequires:  jpackage-utils
@@ -50,6 +66,8 @@ BuildRequires: libgnome-keyring-devel
 BuildRequires: felix-framework
 BuildRequires: fusesource-pom
 BuildRequires: jansi
+# laf-utils JNI need pkconfig files for gtk2+
+BuildRequires: gtk2-devel
 # 1.0.14-7 has OSGi metadata and itext dep fix
 BuildRequires: jfreechart >= 1.0.14-7
 # 1.0.17-4 has OSGi metadata
@@ -100,6 +118,11 @@ Requires: google-gson
 Requires: apache-commons-fileupload
 Requires: httpcomponents-core
 Requires: httpcomponents-client
+# At this point some of the icons in thermostat are hard-coded to
+# gnome icons. This is going to change upstream. Once that's done
+# (self-contained within thermostat) we can remove this again.
+# See RHBZ#966892
+Requires: gnome-icon-theme
 
 %description
 Thermostat is a monitoring and instrumentation tool for the Hotspot JVM,
@@ -132,13 +155,17 @@ This package contains the exploded web archive which installs into
 tomcat's webapps directory.
 
 %prep
-%setup -q -n %{name}-%{hgrev}
+#%setup -q -n %{name}-%{hgrev}
+%setup -q -n %{name}-%{version}
 %patch0 -p1
 %patch1 -p1
 %patch2 -p1
 %patch3 -p1
 %patch4 -p1
 %patch5 -p1
+%patch6 -p1
+%patch7 -p1
+%patch8 -p1
 
 # webservice command is going to be disabled.
 rm distribution/config/commands/webservice.properties
@@ -169,6 +196,7 @@ rm distribution/config/commands/webservice.properties
 # additional dep. It's used in agent/core/pom.xml and in keyring/pom.xml
 %pom_remove_plugin org.codehaus.mojo:exec-maven-plugin agent/core
 %pom_remove_plugin org.codehaus.mojo:exec-maven-plugin keyring
+%pom_remove_plugin org.codehaus.mojo:exec-maven-plugin laf-utils
 
 # Remove jacoco-coverage plugin (in main pom.xml and web/war/pom.xml)
 %pom_remove_plugin org.jacoco:jacoco-maven-plugin
@@ -211,7 +239,7 @@ export CFLAGS="$RPM_OPT_FLAGS" LDFLAGS="$RPM_LD_FLAGS"
 set_jvm
 export JAVA_HOME
 
-# Build JNI bits
+################## Build JNI bits ########################
 pushd keyring
 mkdir -p target/classes
 javac -d target/classes src/main/java/com/redhat/thermostat/utils/keyring/Keyring.java \
@@ -223,9 +251,18 @@ rm target/classes/com/redhat/thermostat/annotations/Service.class
 popd
 pushd agent/core
 mkdir -p target/classes
-javac -d target/classes src/main/java/com/redhat/thermostat/utils/hostname/HostName.java
+javac -d target/classes \
+         src/main/java/com/redhat/thermostat/utils/hostname/HostName.java \
+         src/main/java/com/redhat/thermostat/utils/username/UserNameUtil.java \
+         src/main/java/com/redhat/thermostat/utils/username/internal/UserNameUtilImpl.java
 make all
 popd
+pushd laf-utils
+mkdir -p target/classes
+javac -d target/classes src/main/java/com/redhat/thermostat/internal/utils/laf/gtk/GTKThemeUtils.java
+make all
+popd
+################## Build JNI bits (end) ##################
 
 # This is roughly equivalent to:
 #   mvn 
@@ -245,10 +282,9 @@ mv thermostat-*jar distribution/target/libs/
 
 # fix path to java in scripts
 sed -i 's|^JAVA=.*|JAVA="/usr/lib/jvm/java-openjdk/jre/bin/java"|' distribution/target/bin/thermostat
-sed -i 's|^JAVA=.*|JAVA="/usr/lib/jvm/java-openjdk/jre/bin/java"|' distribution/target/bin/thermostat-client-gui
 
 # Remove dirs/files which we don't need shipped
-rm -rf distribution/target/{maven-archiver,maven-status,osgi-cache,generated-sources,tools,classes}
+rm -rf distribution/target/{antrun,archive-tmp,maven-archiver,maven-status,osgi-cache,generated-sources,tools,classes}
 rm distribution/target/thermostat-distribution-*.jar
 
 # Collect a list of filenames which we later use in order to symlink from /usr/share/java
@@ -283,19 +319,21 @@ mv distribution/target/libs/thermostat-web-server*.jar webstorage-webapp/WEB-INF
 #######################################################
 mkdir -p %{buildroot}%{_bindir}
 mkdir -p %{buildroot}%{_sysconfdir}/%{name}
+mkdir -p %{buildroot}%{_sysconfdir}/sysconfig
 mkdir -p %{buildroot}%{_datarootdir}
 # JNI things live there
 mkdir -p %{buildroot}%{_libdir}/%{name}
 mkdir -p %{buildroot}%{_jnidir}
 mkdir -p %{buildroot}%{_unitdir}
 
-# Dance the xmvn install limbo. This only makes sense if %mvn_build does NOT have
-# the '-i' switch.
+# Dance the xmvn install limbo. This only makes sense if %mvn_build does NOT
+# have the '-i' switch.
 %mvn_install
 
 rm -rf %{buildroot}%{_javadir}/%{name}
 
-# now make xmvn happy, it expects version-less thermostat jars in %{_javadir}/%{name}
+# now make xmvn happy, it expects version-less thermostat jars in
+# %{_javadir}/%{name}
 mkdir %{buildroot}%{_javadir}/%{name}
 for i in $(cat distribution/symlink-map-filenames); do
   s=$(echo $i | cut -d'#' -f1)
@@ -308,12 +346,14 @@ pushd distribution/target/libs
 # %{_libdir}/%{name} files. Files are moved to
 # %{_libdir}/%{name} next.
 for i in thermostat-keyring-*.jar \
-    thermostat-agent-core-*.jar; do
+    thermostat-agent-core-*.jar \
+    thermostat-laf-utils-*.jar; do
   ln -s %{_libdir}/%{name}/$i %{buildroot}%{_jnidir}/$i
 done
 # JNI files are in %{_libdir}
 mv thermostat-keyring-*.jar \
    thermostat-agent-core-*.jar \
+   thermostat-laf-utils-*.jar \
    %{buildroot}%{_libdir}/%{name}
 # Make native libs executable so that debuginfos get properly
 # generated
@@ -329,6 +369,10 @@ cp -a *.service %{buildroot}%{_unitdir}/
 popd
 rm -rf distribution/target/systemd
 
+# remove agent/storage directories which get symlinked later
+rm -r distribution/target/storage/{db,run,logs}
+rm -r distribution/target/agent/{run,logs}
+
 # move everything else into /usr/share/thermostat
 cp -a distribution/target %{buildroot}%{_datarootdir}/%{name}
 
@@ -382,9 +426,7 @@ popd
 ln -s /usr/lib/jvm/java-openjdk/lib/tools.jar \
     %{buildroot}%{_datarootdir}/%{name}/libs/
 
-# binary names
-ln -s %{_datarootdir}/%{name}/bin/thermostat-client-gui \
-    %{buildroot}%{_bindir}/thermostat-client
+# Symlink the thermostat script in /bin
 ln -s %{_datarootdir}/%{name}/bin/thermostat \
     %{buildroot}%{_bindir}/thermostat
 
@@ -406,6 +448,29 @@ ln -s %{_sysconfdir}/%{name}/$i \
 done
 popd
 
+# Install sysconfig file. This is so as to set THERMOSTAT_HOME to
+# /usr/share/thermostat rather than ~/.thermostat which the script
+# would do.
+sed -i 's#__installdir__#%{_datarootdir}/%{name}/#g' %{SOURCE1}
+cp %{SOURCE1} %{buildroot}%{_sysconfdir}/sysconfig/%{name}
+
+# Set up directory structure for running thermostat storage/
+# thermostat agend via systemd
+%{__install} -d -m 0775 %{buildroot}%{system_datadir}/db
+%{__install} -d -m 0775 %{buildroot}%{system_cachedir}
+%{__install} -d -m 0775 %{buildroot}%{system_logdir}/storage
+%{__install} -d -m 0775 %{buildroot}%{system_statedir}/storage
+%{__install} -d -m 0775 %{buildroot}%{system_statedir}/agent
+# Symlink storage/agent directories so that they can be run
+# as systemd services. The target directories will have
+# appropriate permissions for the thermostat user to allow
+# writing.
+ln -s %{system_datadir}/db %{buildroot}%{_datarootdir}/%{name}/storage/db
+ln -s %{system_statedir}/storage %{buildroot}%{_datarootdir}/%{name}/storage/run
+ln -s %{system_logdir}/storage %{buildroot}%{_datarootdir}/%{name}/storage/logs
+ln -s %{system_statedir}/agent %{buildroot}%{_datarootdir}/%{name}/agent/run
+ln -s %{system_cachedir} %{buildroot}%{_datarootdir}/%{name}/osgi-cache
+
 #######################################################
 # Thermostat web storage webapp
 #######################################################
@@ -455,25 +520,43 @@ popd
 # add the thermostat user and group
 %{_sbindir}/groupadd -r thermostat 2>/dev/null || :
 %{_sbindir}/useradd -c "Thermostat" -g thermostat \
-    -s /bin/nologin -r -d %{_datarootdir}/%{name} thermostat 2>/dev/null || :
+    -s /sbin/nologin -r -d %{_datarootdir}/%{name} thermostat 2>/dev/null || :
 
 %post
 # install but don't activate
 %systemd_post %{name}-agent.service
 %systemd_post %{name}-storage.service
 
+%preun
+%systemd_preun %{name}-agent.service
+%systemd_preun %{name}-storage.service
+
+%postun
+%systemd_postun %{name}-agent.service
+%systemd_postun %{name}-storage.service
+
 %files -f .mfiles
 %doc COPYING
 %doc LICENSE
 %doc README
 %config(noreplace) %{_sysconfdir}/%{name}
+%config(noreplace) %{_sysconfdir}/sysconfig/%{name}
 %{_datarootdir}/%{name}
 %{_libdir}/%{name}
 %{_jnidir}/thermostat-*.jar
-%{_bindir}/thermostat-client
 %{_bindir}/thermostat
 %{_unitdir}/%{name}-storage.service
 %{_unitdir}/%{name}-agent.service
+# To these directories get written to when thermostat storage/agent
+# run as systemd services
+%attr(0770,thermostat,root) %dir %{system_datadir}
+%attr(0770,thermostat,root) %dir %{system_datadir}/db
+%attr(0770,thermostat,root) %dir %{system_cachedir}
+%attr(0770,thermostat,root) %dir %{system_logdir}
+%attr(0770,thermostat,root) %dir %{system_logdir}/storage
+%attr(0770,thermostat,root) %dir %{system_statedir}
+%attr(0770,thermostat,root) %dir %{system_statedir}/storage
+%attr(0770,thermostat,root) %dir %{system_statedir}/agent
 
 %files javadoc -f .mfiles-javadoc
 %doc LICENSE
@@ -483,6 +566,11 @@ popd
 %{_datadir}/tomcat/webapps/%{name}
 
 %changelog
+* Wed May 22 2013 Severin Gehwolf <sgehwolf at redhat.com> 0.9.0-1
+- Update to upstream 0.9.0 release.
+- Remove thermostat-client script.
+- Fixes RHBZ#966892.
+
 * Tue May 21 2013 Severin Gehwolf <sgehwolf at redhat.com> 0.8.0-0.1.20130521hg97e66ed2e4ae
 - Update to 0.8.0 pre-release.
 - Install systemd unit files.
diff --git a/username_util.patch b/username_util.patch
new file mode 100644
index 0000000..c13dd0e
--- /dev/null
+++ b/username_util.patch
@@ -0,0 +1,88 @@
+diff --git a/agent/core/src/main/java/com/redhat/thermostat/utils/username/UserNameUtil.java b/agent/core/src/main/java/com/redhat/thermostat/utils/username/UserNameUtil.java
+--- a/agent/core/src/main/java/com/redhat/thermostat/utils/username/UserNameUtil.java
++++ b/agent/core/src/main/java/com/redhat/thermostat/utils/username/UserNameUtil.java
+@@ -36,17 +36,22 @@
+ 
+ package com.redhat.thermostat.utils.username;
+ 
++import java.io.IOException;
+ 
+ /**
+  * Utility to query the operating system for a user name.
+  */
+ public interface UserNameUtil {
+-    
++
+     /**
+      * Returns the user name corresponding to the provided UID.
+-     * @param uid - the UID whose name to return
+-     * @return the user name if found, or null otherwise
++     * 
++     * @param uid
++     *            The UID whose name to return.
++     * @throws IOException
++     *            If the username for the given uid could not be retrieved.
++     * @return The user name if found, or null otherwise.
+      */
+-    String getUserName(long uid);
++    String getUserName(long uid) throws IOException;
+ 
+ }
+diff --git a/agent/core/src/main/java/com/redhat/thermostat/utils/username/internal/UserNameUtilImpl.java b/agent/core/src/main/java/com/redhat/thermostat/utils/username/internal/UserNameUtilImpl.java
+--- a/agent/core/src/main/java/com/redhat/thermostat/utils/username/internal/UserNameUtilImpl.java
++++ b/agent/core/src/main/java/com/redhat/thermostat/utils/username/internal/UserNameUtilImpl.java
+@@ -37,14 +37,10 @@
+ package com.redhat.thermostat.utils.username.internal;
+ 
+ import java.io.IOException;
+-import java.util.logging.Level;
+-import java.util.logging.Logger;
+ 
+-import com.redhat.thermostat.common.utils.LoggingUtils;
+ import com.redhat.thermostat.utils.username.UserNameUtil;
+ 
+ public class UserNameUtilImpl implements UserNameUtil {
+-    private static final Logger logger = LoggingUtils.getLogger(UserNameUtilImpl.class);
+     
+     static {
+         /*
+@@ -54,16 +50,14 @@
+         System.loadLibrary("UserNameUtilWrapper");
+     }
+     
+-    public String getUserName(long uid) {
+-        String result = null;
++    public String getUserName(long uid) throws IOException {
+         if (uid >= 0) {
+-            try {
+-                result = getUserName0(uid);
+-            } catch (IOException e) {
+-                logger.log(Level.WARNING, "Unable to retrieve username for uid: " + uid, e);
+-            }
++            // getUserName0 may throw IOException. We catch and log this in
++            // the consumer rather than here. This free's us from using the
++            // logger in a JNI class.
++            return getUserName0(uid);
+         }
+-        return result;
++        return null;
+     }
+     
+     private native String getUserName0(long uid) throws IOException;
+diff --git a/system-backend/src/main/java/com/redhat/thermostat/backend/system/ProcessUserInfoBuilder.java b/system-backend/src/main/java/com/redhat/thermostat/backend/system/ProcessUserInfoBuilder.java
+--- a/system-backend/src/main/java/com/redhat/thermostat/backend/system/ProcessUserInfoBuilder.java
++++ b/system-backend/src/main/java/com/redhat/thermostat/backend/system/ProcessUserInfoBuilder.java
+@@ -88,7 +88,12 @@
+         try {
+             Reader reader = source.getStatusReader(pid);
+             long uid = getUidFromProcfs(new BufferedReader(reader));
+-            String name = userNameUtil.getUserName(uid);
++            String name = null;
++            try {
++                name = userNameUtil.getUserName(uid);
++            } catch (IOException e) {
++                logger.log(Level.WARNING, "Unable to retrieve username for uid: " + uid, e);
++            }
+             info = new ProcessUserInfo(uid, name);
+         } catch (IOException e) {
+             logger.log(Level.WARNING, "Unable to read user info for " + pid, e);


More information about the scm-commits mailing list