7038N/A#!/bin/sh
7038N/A#
7038N/A# Class Action Script for installing input method modules for libgtk
7038N/A#
7038N/A# CDDL HEADER START
7038N/A#
7038N/A# The contents of this file are subject to the terms of the
7038N/A# Common Development and Distribution License, Version 1.0 only
7038N/A# (the "License"). You may not use this file except in compliance
7038N/A# with the License.
7038N/A#
7038N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
7038N/A# or http://www.opensolaris.org/os/licensing.
7038N/A# See the License for the specific language governing permissions
7038N/A# and limitations under the License.
7038N/A#
7038N/A# When distributing Covered Code, include this CDDL HEADER in each
7038N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
7038N/A# If applicable, add the following below this CDDL HEADER, with the
7038N/A# fields enclosed by brackets "[]" replaced with your own identifying
7038N/A# information: Portions Copyright [yyyy] [name of copyright owner]
7038N/A#
7038N/A# CDDL HEADER END
7038N/A#
7038N/A#
7411N/A# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
7038N/A# Use is subject to license terms.
7038N/A#
7038N/A
7038N/AF_A=/tmp/im.add.$$
7038N/AF_M=/tmp/im.merged.$$
7038N/Apkg_start="# Start $PKGINST"
7038N/Apkg_end="# End $PKGINST"
7038N/A
7411N/Aif [ "sparc" = "`uname -p`" ]; then
7411N/A ARCH=sparcv9
7411N/Aelse
7411N/A ARCH=amd64
7411N/Afi
7411N/A
7038N/Awhile read src dest; do
7038N/A if [ ! -f ${dest} ]; then
7411N/A echo "$pkg_start" > ${dest}
7038N/A sed -e "s/@ARCH@/${ARCH}/g" ${src} >> ${dest}
7411N/A echo "$pkg_end" >> ${dest}
7038N/A else
7038N/A sed -e "s/@ARCH@/${ARCH}/g" ${src} > ${F_A}
7038N/A # Check if any of the lines from ${src} are already in the file
7038N/A do_merge=yes
7411N/A # save the standard input as file descriptor 3
7411N/A exec 3<&0
7038N/A exec < ${F_A}
7038N/A while read line; do
7038N/A # input method spec lines start with quotes
7411N/A case "$line" in
7411N/A '"'*) ;;
7411N/A *) continue; ;;
7411N/A esac
7038N/A if /usr/bin/egrep -s -- "$line" ${dest}; then
7038N/A do_merge=no
7038N/A break
7038N/A fi
7038N/A done
7411N/A # restore the standard input
7411N/A exec <&3
7411N/A # close file descriptor 3
7411N/A exec 3<&-
7038N/A if [ $do_merge = yes ]; then
7038N/A if egrep -s 'GTK\+ Input Method Modules file' ${F_A}; then
7038N/A # The original Gtk+ config file should come first
7038N/A # Any additions should be at the end
7411N/A echo "$pkg_start" >> ${F_M}
7411N/A cat ${F_A} >> ${F_M}
7411N/A echo "$pkg_end" >> ${F_M}
7411N/A cat ${dest} >> ${F_M}
7038N/A else
7411N/A cat ${dest} >> ${F_M}
7411N/A echo "$pkg_start" >> ${F_M}
7411N/A cat ${F_A} >> ${F_M}
7411N/A echo "$pkg_end" >> ${F_M}
7038N/A fi
7038N/A cp ${F_M} ${dest}
7038N/A rm -f ${F_M}
7038N/A fi
7038N/A rm -f ${F_A}
7038N/A fi
7038N/Adone
7038N/A
7038N/Aexit 0