16513834 input-method-cache SMF action does not follow GTK3 update
authorAlan Coopersmith <Alan.Coopersmith@Oracle.COM>
Thu, 22 Sep 2016 16:57:34 -0700
changeset 6968 8acbeef80cf1
parent 6967 9895f1ebff08
child 6969 c033ca9bd950
16513834 input-method-cache SMF action does not follow GTK3 update
components/gnome/gtk3/Makefile
components/gnome/gtk3/files/gtk3-input-method-cache.8s
components/gnome/gtk3/files/gtk3-input-method-cache.sh
components/gnome/gtk3/files/gtk3-input-method-cache.xml
components/gnome/gtk3/gtk3.p5m
transforms/actuators
--- a/components/gnome/gtk3/Makefile	Thu Sep 22 16:55:37 2016 -0700
+++ b/components/gnome/gtk3/Makefile	Thu Sep 22 16:57:34 2016 -0700
@@ -62,28 +62,6 @@
 # 32-bit gcc builds cause segfaults in gtk3; see bug 21393975.
 gcc_OPT.i386.32 = -O2
 
-# Generate and install architecture-specific configuration files.
-PROTOETCGTKDIR.32=	$(PROTO_DIR)/$(ETCDIR.32)/gtk-3.0
-PROTOETCGTKDIR.64=	$(PROTO_DIR)/$(ETCDIR.64)/gtk-3.0
-PROTOETCIMMCONF.32=	$(PROTOETCGTKDIR.32)/gtk.immodules
-PROTOETCIMMCONF.64=	$(PROTOETCGTKDIR.64)/gtk.immodules
-
-$(PROTOETCIMMCONF.32):
-	$(MKDIR) $(PROTOETCGTKDIR.32); \
-	LD_LIBRARY_PATH=$(PROTO_DIR)/$(USRLIB.32) \
-	  $(PROTOUSRBINDIR)/gtk-query-immodules-3.0 \
-	  $(PROTOUSRLIBDIR)/gtk-3.0/*/immodules/*.so | \
-	  $(GSED) -e "s#$(PROTO_DIR)/##" > $(PROTOETCIMMCONF.32)
-
-$(PROTOETCIMMCONF.64):
-	$(MKDIR) $(PROTOETCGTKDIR.64); \
-	LD_LIBRARY_PATH=$(PROTO_DIR)/$(USRLIB.64) \
-	  $(PROTOUSRBINDIR64)/gtk-query-immodules-3.0 \
-	  $(PROTOUSRLIBDIR64)/gtk-3.0/*/immodules/*.so | \
-	  $(GSED) -e "s#$(PROTO_DIR)/##" > $(PROTOETCIMMCONF.64)
-
-install: $(PROTOETCIMMCONF.32) $(PROTOETCIMMCONF.64)
-
 CONFIGURE_ENV += PATH=$(GNUBIN):$(PATH)
 CONFIGURE_OPTIONS += --enable-cloudprint
 # Required for other components.
@@ -99,6 +77,27 @@
 # Needed due to patch to configure.ac.
 COMPONENT_PREP_ACTION += (cd $(@D); autoreconf -fiv);
 
+# Make sure SMF manifests are valid
+$(BUILD_DIR)/.validated-smf-manifests-$(MACH): $(BUILD_DIR)
+	@for f in files/*.xml ; do \
+	    (set -ex ; /usr/sbin/svccfg validate "$$f") ; \
+	done
+	$(TOUCH) [email protected]
+
+validate-smf:	$(BUILD_DIR)/.validated-smf-manifests-$(MACH)
+build:		$(BUILD_DIR)/.validated-smf-manifests-$(MACH)
+
+# Generate and install architecture-specific configuration files.
+PROTOGTKDIR=		$(PROTO_DIR)$(USRLIB)/gtk-3.0/3.0.0
+PROTOIMMCONF=		$(PROTOGTKDIR)/immodules.cache
+
+COMPONENT_POST_INSTALL_ACTION += \
+	$(MKDIR) $(PROTOGTKDIR); \
+	LD_LIBRARY_PATH='$(PROTO_DIR)$(USRLIB)' \
+	  $(PROTO_DIR)$(USRBIN)/gtk-query-immodules-3.0 \
+	  $(PROTOGTKDIR)/immodules/*.so | \
+	  $(GSED) -e 's%$(PROTO_DIR)%%' > $(PROTOIMMCONF) ;
+
 REQUIRED_PACKAGES += data/docbook/docbook-dtds
 REQUIRED_PACKAGES += data/docbook/docbook-style-dsssl
 REQUIRED_PACKAGES += data/docbook/docbook-style-xsl
@@ -118,6 +117,7 @@
 REQUIRED_PACKAGES += print/cups
 REQUIRED_PACKAGES += runtime/perl-522
 REQUIRED_PACKAGES += runtime/python-27
+REQUIRED_PACKAGES += system/core-os
 REQUIRED_PACKAGES += system/library/fontconfig
 REQUIRED_PACKAGES += system/library/freetype-2
 REQUIRED_PACKAGES += system/library/gcc/gcc-c-runtime
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/gnome/gtk3/files/gtk3-input-method-cache.8s	Thu Sep 22 16:57:34 2016 -0700
@@ -0,0 +1,69 @@
+.\" Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+.\"
+.\" CDDL HEADER START
+.\"
+.\" The contents of this file are subject to the terms of the
+.\" Common Development and Distribution License (the "License").
+.\" You may not use this file except in compliance with the License.
+.\"
+.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+.\" or http://www.opensolaris.org/os/licensing.
+.\" See the License for the specific language governing permissions
+.\" and limitations under the License.
+.\"
+.\" When distributing Covered Code, include this CDDL HEADER in each
+.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+.\" If applicable, add the following below this CDDL HEADER, with the
+.\" fields enclosed by brackets "[]" replaced with your own identifying
+.\" information: Portions Copyright [yyyy] [name of copyright owner]
+.\"
+.\" CDDL HEADER END
+.TH gtk3-input-method-cache 8S "14 Sep 2016"
+.SH NAME
+.PP
+svc:/application/desktop-cache/gtk3-input-method-cache \- GTK+ 3.x input method module cache service
+.SH DESCRIPTION
+.PP
+The
+.B svc:/application/desktop-cache/gtk3-input-method-cache
+transient
+.BR smf (7)
+service runs
+.BR gtk-query-immodules-3.0 (1)
+when necessary to update the immodules.cache file with the information from
+the input method modules for GTK+ 3.x in the
+.IR libdir /gtk-3.0/3.0.0/immodules
+directory (where
+.I libdir
+may be either /usr/lib or /usr/lib/64).
+.PP
+Packages that deliver files into the
+.IR libdir /gtk-3.0/3.0.0/immodules
+directory should set a
+.I refresh_fmri
+attribute with the value
+.B svc:/application/desktop-cache/gtk3-input-method-cache:default
+on such files.
+.PP
+This service has no configurable properties.
+.PP
+Administrative actions on this service, such as enabling, disabling, or
+requesting restart, can be performed using \fBsvcadm\fR(8). The status of the
+service can be queried using the \fBsvcs\fR(1) command.
+.SH FILES
+.TP 30
+.IR libdir /gtk-3.0/3.0.0/immodules
+GTK+ 3.x input method modules
+.TP 30
+.IR libdir /gtk-3.0/3.0.0/immodules.cache
+The default im cache file used by GTK+ 3.x applications
+.SH SEE ALSO
+.PP
+.BR gtk-query-immodules-3.0 (1),
+.BR svcs (1),
+.BR attributes (7),
+.BR pkg (7),
+.BR smf (7),
+.BR svcadm (8)
+.PP
+https://wiki.gnome.org/Projects/dconf/SystemAdministrators
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/gnome/gtk3/files/gtk3-input-method-cache.sh	Thu Sep 22 16:57:34 2016 -0700
@@ -0,0 +1,88 @@
+#! /bin/ksh93
+
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+#
+
+PATH=/usr/bin:/usr/sbin
+
+. /lib/svc/share/smf_include.sh
+
+USAGE="Usage: $0 <method>"
+
+if [[ $# -ne 1 ]] ; then
+	print "$USAGE" >&2
+	exit 2
+fi
+
+METHOD="$1"
+
+case $METHOD in
+	start|refresh)
+		# Continue with rest of script
+		;;
+	-*)
+		print "$USAGE" >&2
+		exit 2
+		;;
+	*)
+		print "Invalid method $METHOD" >&2
+		exit 2
+		;;
+esac
+
+for DIR in "" "/64"; do
+    MAKE_CACHE="/usr/bin$DIR/gtk-query-immodules-3.0"
+    MODULE_DIR="/usr/lib$DIR/gtk-3.0/3.0.0/immodules/"
+    CACHE_FILE="/usr/lib$DIR/gtk-3.0/3.0.0/immodules.cache"
+
+    if [[ ! -x "${MAKE_CACHE}" ]] ; then
+	print "${MAKE_CACHE} not installed"
+	continue
+    fi
+
+    if [[ ! -r "${CACHE_FILE}" ]]; then
+	RESULT="no cache file"
+    elif [[ "${METHOD}" == "refresh" ]]; then
+	RESULT="refresh requested"
+    elif [[ "${MODULE_DIR}" -nt "${CACHE_FILE}" ]] ; then
+	RESULT="directory updated"
+    else
+	RESULT="$(find ${MODULE_DIR} -newer ${CACHE_FILE})"
+    fi
+
+    if [[ -n "$RESULT" ]]; then
+	print "updating/creating im modules cache file ($RESULT)"
+	umask 022
+	${MAKE_CACHE} --update-cache
+	if [ $? -ne 0 ]; then
+	    print "${MAKE_CACHE} exited with an error while generating the cache file ${CACHE_FILE}"
+	    exit $SMF_EXIT_ERR_FATAL
+	else
+	    print "input method cache installed in ${CACHE_FILE}"
+	fi
+    fi
+done
+
+exit $SMF_EXIT_OK
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/gnome/gtk3/files/gtk3-input-method-cache.xml	Thu Sep 22 16:57:34 2016 -0700
@@ -0,0 +1,112 @@
+<?xml version="1.0"?>
+<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
+<!--
+
+Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
+
+CDDL HEADER START
+
+The contents of this file are subject to the terms of the
+Common Development and Distribution License (the "License").
+You may not use this file except in compliance with the License.
+
+You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+or http://www.opensolaris.org/os/licensing.
+See the License for the specific language governing permissions
+and limitations under the License.
+
+When distributing Covered Code, include this CDDL HEADER in each
+file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+If applicable, add the following below this CDDL HEADER, with the
+fields enclosed by brackets "[]" replaced with your own identifying
+information: Portions Copyright [yyyy] [name of copyright owner]
+
+CDDL HEADER END
+
+Service manifest for ensuring GSettings schemas & overrides are compiled into
+required form on install & update
+
+-->
+
+<service_bundle type='manifest' name='gtk3-input-method-cache'>
+
+<service
+	name='application/desktop-cache/gtk3-input-method-cache'
+	type='service'
+	version='1'>
+
+	<create_default_instance enabled='true' />
+
+	<single_instance />
+
+	<!-- Need / & /usr filesystems mounted -->
+	<dependency
+		name='usr'
+		type='service'
+		grouping='require_all'
+		restart_on='none'>
+		<service_fmri value='svc:/system/filesystem/minimal' />
+	</dependency>
+
+	<dependent
+		name='gtk3-input-method-cache_assembly-complete'
+		grouping='optional_all'
+		restart_on='none'>
+		<service_fmri value='svc:/milestone/self-assembly-complete' />
+	</dependent>
+
+	<!-- Need to be run before gdm is started -->
+	<dependent
+		name='gtk3-input-method-cache_gdm'
+		grouping='optional_all'
+		restart_on='none'>
+		<service_fmri value='svc:/application/graphical-login/gdm' />
+	</dependent>
+
+	<method_context>
+		<method_credential user='daemon' group='daemon'
+			privileges='basic,{zone}:/usr/lib/gtk-3.0/3.0.0/*,{zone}:/usr/lib/amd64/gtk-3.0/3.0.0/*,{zone}:/usr/lib/sparcv9/gtk-3.0/3.0.0/*' />
+	</method_context>
+
+	<exec_method
+		type='method'
+		name='start'
+		exec='/lib/svc/method/gtk3-input-method-cache %m'
+		timeout_seconds='600'>
+	</exec_method>
+
+	<exec_method
+		type='method'
+		name='refresh'
+		exec='/lib/svc/method/gtk3-input-method-cache %m'
+		timeout_seconds='600'>
+	</exec_method>
+
+	<exec_method
+		type='method'
+		name='stop'
+		exec=':true'
+		timeout_seconds='60' />
+
+	<property_group name='startd' type='framework'>
+		<propval name='duration' type='astring'	value='transient' />
+	</property_group>
+
+	<stability value='Unstable' />
+
+	<template>
+		<common_name>
+			<loctext xml:lang='C'>GTK+ 3.x input method module cache service
+				</loctext>
+		</common_name>
+
+		<documentation>
+			<manpage
+				title='application/desktop-cache/gtk3-input-method-cache'
+				section='8s'
+				manpath='/usr/share/man' />
+		</documentation>
+	</template>
+</service>
+
+</service_bundle>
--- a/components/gnome/gtk3/gtk3.p5m	Thu Sep 22 16:55:37 2016 -0700
+++ b/components/gnome/gtk3/gtk3.p5m	Thu Sep 22 16:57:34 2016 -0700
@@ -39,15 +39,15 @@
 set name=info.upstream-url value=$(COMPONENT_PROJECT_URL)
 set name=org.opensolaris.arc-caseid value=PSARC/2016/320
 set name=org.opensolaris.consolidation value=$(CONSOLIDATION)
-file path=etc/$(MACH64)/gtk-3.0/gtk.immodules \
-    original_name=SUNWgtk3:etc/$(MACH64)/gtk-3.0/gtk.immodules preserve=true
 file path=etc/$(MACH64)/gtk-3.0/im-multipress.conf \
     original_name=SUNWgtk3:etc/$(MACH64)/gtk-3.0/im-multipress.conf \
     preserve=true
-file path=etc/gtk-3.0/gtk.immodules \
-    original_name=SUNWgtk3:etc/gtk-3.0/gtk.immodules preserve=true
 file path=etc/gtk-3.0/im-multipress.conf \
     original_name=SUNWgtk3:etc/gtk-3.0/im-multipress.conf preserve=true
+file files/gtk3-input-method-cache.xml \
+    path=lib/svc/manifest/application/desktop-cache/gtk3-input-method-cache.xml
+file files/gtk3-input-method-cache.sh \
+    path=lib/svc/method/gtk3-input-method-cache
 file path=usr/bin/$(MACH64)/gtk-encode-symbolic-svg
 file path=usr/bin/$(MACH64)/gtk-launch
 file path=usr/bin/$(MACH64)/gtk-query-immodules-3.0
@@ -437,6 +437,7 @@
 file path=usr/lib/$(MACH64)/girepository-1.0/Gdk-3.0.typelib
 file path=usr/lib/$(MACH64)/girepository-1.0/GdkX11-3.0.typelib
 file path=usr/lib/$(MACH64)/girepository-1.0/Gtk-3.0.typelib
+file path=usr/lib/$(MACH64)/gtk-3.0/3.0.0/immodules.cache preserve=true
 file path=usr/lib/$(MACH64)/gtk-3.0/3.0.0/immodules/im-am-et.so
 file path=usr/lib/$(MACH64)/gtk-3.0/3.0.0/immodules/im-cedilla.so
 file path=usr/lib/$(MACH64)/gtk-3.0/3.0.0/immodules/im-cyrillic-translit.so
@@ -468,6 +469,7 @@
 file path=usr/lib/girepository-1.0/Gdk-3.0.typelib
 file path=usr/lib/girepository-1.0/GdkX11-3.0.typelib
 file path=usr/lib/girepository-1.0/Gtk-3.0.typelib
+file path=usr/lib/gtk-3.0/3.0.0/immodules.cache preserve=true
 file path=usr/lib/gtk-3.0/3.0.0/immodules/im-am-et.so
 file path=usr/lib/gtk-3.0/3.0.0/immodules/im-cedilla.so
 file path=usr/lib/gtk-3.0/3.0.0/immodules/im-cyrillic-translit.so
@@ -771,6 +773,8 @@
 file path=usr/share/man/man1/gtk3-demo.1
 file path=usr/share/man/man1/gtk3-icon-browser.1
 file path=usr/share/man/man1/gtk3-widget-factory.1
+file files/gtk3-input-method-cache.8s \
+    path=usr/share/man/man8s/application/desktop-cache/gtk3-input-method-cache.8s
 file path=usr/share/themes/Default/gtk-3.0/gtk-keys.css
 file path=usr/share/themes/Emacs/gtk-3.0/gtk-keys.css
 license COPYING license=LGPLv2
--- a/transforms/actuators	Thu Sep 22 16:55:37 2016 -0700
+++ b/transforms/actuators	Thu Sep 22 16:57:34 2016 -0700
@@ -49,9 +49,13 @@
 <transform file path=usr/share/mime/packages/.*\.xml$ -> \
     default restart_fmri svc:/application/desktop-cache/mime-types-cache:default>
 
-# GNOME gtk Input Method modules
-<transform file path=usr/lib.*/gtk-.*/.*/immodules/.*.so$ -> \
-    default restart_fmri svc:/application/desktop-cache/input-method-cache:default>
+# GNOME gtk2 Input Method modules
+<transform file path=usr/lib.*/gtk-2.*/.*/immodules/.*.so$ -> \
+    default refresh_fmri svc:/application/desktop-cache/input-method-cache:default>
+
+# GNOME gtk3 Input Method modules
+<transform file path=usr/lib.*/gtk-3.*/.*/immodules/.*.so$ -> \
+    default refresh_fmri svc:/application/desktop-cache/gtk3-input-method-cache:default>
 
 # GNOME gdk-pixbuf image loader modules
 <transform file path=usr/lib.*/gdk-pixbuf-.*/.*/loaders/.*.so$ -> \