components/desktop/desktop-cache/files/pixbuf-loaders-installer
changeset 5889 d78a523a8925
equal deleted inserted replaced
5888:09b82e3ff500 5889:d78a523a8925
       
     1 #!/bin/ksh -p
       
     2 #
       
     3 # Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.
       
     4 #
       
     5 # Permission is hereby granted, free of charge, to any person obtaining a
       
     6 # copy of this software and associated documentation files (the
       
     7 # "Software"), to deal in the Software without restriction, including
       
     8 # without limitation the rights to use, copy, modify, merge, publish,
       
     9 # distribute, and/or sell copies of the Software, and to permit persons
       
    10 # to whom the Software is furnished to do so, provided that the above
       
    11 # copyright notice(s) and this permission notice appear in all copies of
       
    12 # the Software and that both the above copyright notice(s) and this
       
    13 # permission notice appear in supporting documentation.
       
    14 #
       
    15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
       
    16 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
       
    17 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
       
    18 # OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
       
    19 # HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
       
    20 # INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
       
    21 # FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
       
    22 # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
       
    23 # WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
       
    24 #
       
    25 # Except as contained in this notice, the name of a copyright holder
       
    26 # shall not be used in advertising or otherwise to promote the sale, use
       
    27 # or other dealings in this Software without prior written authorization
       
    28 # of the copyright holder.
       
    29 #
       
    30 ###########################################################################
       
    31 #
       
    32 
       
    33 PATH=/usr/bin:/usr/sbin
       
    34 
       
    35 . /lib/svc/share/smf_include.sh
       
    36 
       
    37 USAGE="Usage: $0 { start | refresh }"
       
    38 FIND_NEWER=/usr/share/desktop-cache/find_newer
       
    39 
       
    40 if [ $# -ne 1 ] ; then
       
    41     echo $USAGE
       
    42     exit 2
       
    43 fi
       
    44 
       
    45 #
       
    46 # for each architecture 
       
    47 #   if loader file exist 
       
    48 #      get the list of modules newer than the loader file
       
    49 #   else
       
    50 #      make list greater than zero
       
    51 #
       
    52 #   if list generate loader list     
       
    53 #
       
    54 
       
    55 ARCH64=`/bin/isainfo -k`
       
    56 
       
    57 if [[ $ARCH64 != "amd64" ]] && [[ "$ARCH64" != "sparcv9" ]]; then
       
    58   ARCH64=""
       
    59 fi
       
    60 
       
    61 start_pixbuf_loaders_installer ()
       
    62 {
       
    63 for DIR in "" $ARCH64; do
       
    64   test -x /usr/bin/$DIR/gdk-pixbuf-query-loaders || {
       
    65       echo "gdk-pixbuf-query-loaders not installed"
       
    66       continue
       
    67   }
       
    68   test -w /etc/$DIR/gtk-2.0 || {
       
    69       echo "/etc/$DIR/gtk-2.0 is not writable, skipping."
       
    70       return
       
    71   }
       
    72   if [ -a "/etc/$DIR/gtk-2.0/gdk-pixbuf.loaders" ] && [ ! -w "/etc/$DIR/gtk-2.0/gdk-pixbuf.loaders" ]; then
       
    73     echo "/etc/$DIR/gtk-2.0/gdk-pixbuf.loaders is not writable, skipping."
       
    74     return
       
    75   fi
       
    76   if [ -a "/etc/$DIR/gtk-2.0/gdk-pixbuf.loaders" ]; then
       
    77     RESULT=`${FIND_NEWER} -f -c -m --name '*.so' \
       
    78 	--newer /etc/$DIR/gtk-2.0/gdk-pixbuf.loaders \
       
    79 	/usr/lib/$DIR/gdk-pixbuf-2.0/*/loaders 2>/dev/null`
       
    80   else
       
    81     RESULT="no gdk pixbuf loaders file"
       
    82   fi
       
    83 
       
    84   if [ -n "$RESULT" ]; then 
       
    85     echo "updating/creating gdk pixbuf loaders file"
       
    86     /usr/bin/$DIR/gdk-pixbuf-query-loaders > /etc/$DIR/gtk-2.0/gdk-pixbuf.loaders
       
    87     if [ $? -ne 0 ]; then
       
    88       echo "gdk-pixbuf-query-loaders exited with an error while generating the installer file /etc/$DIR/gtk-2.0/gdk-pixbuf.loaders"
       
    89       exit $SMF_EXIT_ERR_FATAL
       
    90     else
       
    91       echo "gdk pixbuf loaders installed in /etc/$DIR/gtk-2.0/gdk-pixbuf.loaders"
       
    92     fi
       
    93   fi
       
    94 
       
    95   test -w /usr/lib/$DIR/gdk-pixbuf-2.0/2.10.0 || {
       
    96       echo "/usr/lib/$DIR/gdk-pixbuf-2.0/2.10.0 is not writable, skipping."
       
    97       return
       
    98   }
       
    99   if [ -a "/usr/lib/$DIR/gdk-pixbuf-2.0/2.10.0/loaders.cache" ] && [ ! -w "/usr/lib/$DIR/gdk-pixbuf-2.0/2.10.0/loaders.cache" ]; then
       
   100     echo "/usr/lib/$DIR/gdk-pixbuf-2.0/2.10.0/loaders.cache is not writable, skipping."
       
   101     return
       
   102   fi
       
   103   if [ -a "/usr/lib/$DIR/gdk-pixbuf-2.0/2.10.0/loaders.cache" ]; then
       
   104     RESULT=`${FIND_NEWER} -f -c -m --name '*.so' \
       
   105 	--newer /usr/lib/$DIR/gdk-pixbuf-2.0/2.10.0/loaders.cache \
       
   106 	/usr/lib/$DIR/gdk-pixbuf-2.0/*/loaders 2>/dev/null`
       
   107   else
       
   108     RESULT="no loaders cache file"
       
   109   fi
       
   110 
       
   111   if [ -n "$RESULT" ]; then
       
   112     echo "updating/creating loaders cache file"
       
   113     /usr/bin/$DIR/gdk-pixbuf-query-loaders > /usr/lib/$DIR/gdk-pixbuf-2.0/2.10.0/loaders.cache
       
   114     if [ $? -ne 0 ]; then
       
   115       echo "gdk-pixbuf-query-loaders exited with an error while generating the installer file /usr/lib/$DIR/gdk-pixbuf-2.0/2.10.0/loaders.cache"
       
   116       exit $SMF_EXIT_ERR_FATAL
       
   117     else
       
   118       echo "loaders cache installed in /usr/lib/$DIR/gdk-pixbuf-2.0/2.10.0/loaders.cache"
       
   119     fi
       
   120   fi
       
   121 done
       
   122 }
       
   123 
       
   124 refresh_pixbuf_loaders_installer ()
       
   125 {
       
   126 for DIR in "" $ARCH64; do
       
   127   test -x /usr/bin/$DIR/gdk-pixbuf-query-loaders || {
       
   128       echo "gdk-pixbuf-query-loaders not installed"
       
   129       continue
       
   130   }
       
   131   test -w /etc/$DIR/gtk-2.0 || {
       
   132       echo "/etc/$DIR/gtk-2.0 is not writable, skipping."
       
   133       return
       
   134   }
       
   135   if [ -a "/etc/$DIR/gtk-2.0/gdk-pixbuf.loaders" ] && [ ! -w "/etc/$DIR/gtk-2.0/gdk-pixbuf.loaders" ]; then
       
   136     echo "/etc/$DIR/gtk-2.0/gdk-pixbuf.loaders is not writable, skipping."
       
   137     return
       
   138   fi
       
   139   if [ -a "/etc/$DIR/gtk-2.0/gdk-pixbuf.loaders" ]; then
       
   140     RESULT=`/usr/bin/find /usr/lib/$DIR/gdk-pixbuf-2.0/*/loaders/*.so ! -type d \
       
   141 	   -follow -print 2>/dev/null`
       
   142   else
       
   143     RESULT="no gdk pixbuf loaders file"
       
   144   fi
       
   145 
       
   146   if [ -n "$RESULT" ]; then 
       
   147     echo "updating/creating gdk pixbuf loaders file"
       
   148     /usr/bin/$DIR/gdk-pixbuf-query-loaders > /etc/$DIR/gtk-2.0/gdk-pixbuf.loaders
       
   149     if [ $? -ne 0 ]; then
       
   150       echo "gdk-pixbuf-query-loaders exited with an error while generating the installer file /etc/$DIR/gtk-2.0/gdk-pixbuf.loaders"
       
   151       exit $SMF_EXIT_ERR_FATAL
       
   152     else
       
   153       echo "gdk pixbuf loaders installed in /etc/$DIR/gtk-2.0/gdk-pixbuf.loaders"
       
   154     fi
       
   155   fi
       
   156 
       
   157   test -w /usr/lib/$DIR/gdk-pixbuf-2.0/2.10.0 || {
       
   158       echo "/usr/lib/$DIR/gdk-pixbuf-2.0/2.10.0 is not writable, skipping."
       
   159       return
       
   160   }
       
   161   if [ -a "/usr/lib/$DIR/gdk-pixbuf-2.0/2.10.0/loaders.cache" ] && [ ! -w "/usr/lib/$DIR/gdk-pixbuf-2.0/2.10.0/loaders.cache" ]; then
       
   162     echo "/usr/lib/$DIR/gdk-pixbuf-2.0/2.10.0/loaders.cache is not writable, skipping."
       
   163     return
       
   164   fi
       
   165   if [ -a "/usr/lib/$DIR/gdk-pixbuf-2.0/2.10.0/loaders.cache" ]; then
       
   166     RESULT=`/usr/bin/find /usr/lib/$DIR/gdk-pixbuf-2.0/*/loaders/*.so ! -type d \
       
   167            -follow -print 2>/dev/null`
       
   168   else
       
   169     RESULT="no loaders cache file"
       
   170   fi
       
   171 
       
   172   if [ -n "$RESULT" ]; then
       
   173     echo "updating/creating loaders cache file"
       
   174     /usr/bin/$DIR/gdk-pixbuf-query-loaders > /usr/lib/$DIR/gdk-pixbuf-2.0/2.10.0/loaders.cache
       
   175     if [ $? -ne 0 ]; then
       
   176       echo "gdk-pixbuf-query-loaders exited with an error while generating the installer file /usr/lib/$DIR/gdk-pixbuf-2.0/2.10.0/loaders.cache"
       
   177       exit $SMF_EXIT_ERR_FATAL
       
   178     else
       
   179       echo "loaders cache installed in /usr/lib/$DIR/gdk-pixbuf-2.0/2.10.0/loaders.cache"
       
   180     fi
       
   181   fi
       
   182 done
       
   183 }
       
   184 
       
   185 METHOD=$1
       
   186 
       
   187 case "$METHOD" in
       
   188     'start')
       
   189 	# Continue with rest of script
       
   190 	;;
       
   191     'refresh')
       
   192 	# Continue with rest of script
       
   193 	;;
       
   194     -*)
       
   195 	echo $USAGE
       
   196 	exit 2
       
   197 	;;
       
   198     *)
       
   199 	echo "Invalid method $METHOD"
       
   200 	exit 2
       
   201 	;;
       
   202 esac
       
   203 
       
   204 ${METHOD}_pixbuf_loaders_installer
       
   205 
       
   206 exit $SMF_EXIT_OK