diff --git a/ChangeLog b/ChangeLog index 5bff3d3..3726362 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2009-01-28 Ghee Teo + + Fixes d.o.o 2399 by adding in refresh option. + bump version to 0.1.4 + * configure.in: + * desktop-mime-cache/desktop-mime-cache: + * gconf-cache/gconf-cache: + * icon-cache/icon-cache: + * input-method/input-method-cache: + * mime-types-cache/mime-types-cache: + * pixbuf-loaders/pixbuf-loaders-installer: + 2008-11-07 Erwann Chenede - * configure.in: bump to 0.1.3 diff --git a/configure.in b/configure.in index c4b20e7..3056fbd 100644 --- a/configure.in +++ b/configure.in @@ -1,4 +1,4 @@ -AC_INIT([desktop-cache-smf-services], [0.1.3]) +AC_INIT([desktop-cache-smf-services], [0.1.4]) AM_INIT_AUTOMAKE AM_INIT_AUTOMAKE([1.9]) diff --git a/desktop-mime-cache/desktop-mime-cache b/desktop-mime-cache/desktop-mime-cache index 0b742c6..62ae9b0 100755 --- a/desktop-mime-cache/desktop-mime-cache +++ b/desktop-mime-cache/desktop-mime-cache @@ -34,30 +34,13 @@ PATH=/usr/bin:/usr/sbin . /lib/svc/share/smf_include.sh -USAGE="Usage: $0 " +USAGE="Usage: $0 { start | refresh }" if [ $# -ne 1 ] ; then echo $USAGE exit 2 fi -METHOD="$1" - -case "$METHOD" in - start) - # Continue with rest of script - ;; - -*) - echo $USAGE - exit 2 - ;; - *) - echo "Invalid method $METHOD" - exit 2 - ;; -esac - - # # IF the mime cache exist then : # get the list of mime type files newer than the cache file @@ -69,8 +52,7 @@ esac MIMEFILE="/usr/share/applications/mimeinfo.cache" -IFS=" -" +start_desktop_mime_cache () { if [ -a $MIMEFILE ]; then RESULT=`/usr/bin/find /usr/share/applications ! -type d -follow \ -newer $MIMEFILE 2>/dev/null` @@ -88,5 +70,45 @@ if [ -n "$RESULT" ]; then echo "desktop file cache $MIMEFILE generated" fi fi +} + +refresh_desktop_mime_cache () { +if [ -a $MIMEFILE ]; then + RESULT=`/usr/bin/find /usr/share/applications ! -type d -follow 2>/dev/null` +else + RESULT="no cache found" +fi + +if [ -n "$RESULT" ]; then + echo "updating desktop file cache" + /usr/bin/update-desktop-database + if [ $? -ne 0 ]; then + echo "update-mime-database exited with an error while generating the desktop file cache $MIMEFILE" + exit $SMF_EXIT_ERR_FATAL + else + echo "desktop file cache $MIMEFILE generated" + fi +fi +} + +METHOD="$1" + +case "$METHOD" in + 'start') + # Continue with rest of script + ;; + 'refresh') + ;; + -*) + echo $USAGE + exit 2 + ;; + *) + echo "Invalid method $METHOD" + exit 2 + ;; +esac + +${METHOD}_desktop_mime_cache exit $SMF_EXIT_OK diff --git a/gconf-cache/gconf-cache b/gconf-cache/gconf-cache index 2bf1254..bc7dca7 100755 --- a/gconf-cache/gconf-cache +++ b/gconf-cache/gconf-cache @@ -35,30 +35,13 @@ PATH=/usr/bin:/usr/sbin . /lib/svc/share/smf_include.sh -USAGE="Usage: $0 " +USAGE="Usage: $0 { start | refresh }" if [ $# -ne 1 ] ; then echo $USAGE exit 2 fi -METHOD=$1 - -case $METHOD in - start) - # Continue with rest of script - ;; - -*) - echo $USAGE - exit 2 - ;; - *) - echo "Invalid method $METHOD" - exit 2 - ;; -esac - - # # IF the gconf cache exist then : # find schema files newer than the cache @@ -68,8 +51,8 @@ esac # generate/merge schema files in the gconf cache # -IFS=" -" +start_gconf_cache () +{ if [ -a "/etc/gconf/gconf.xml.defaults/%gconf-tree.xml" ]; then SCHEMAS=`/usr/bin/find /etc/gconf/schemas ! -type d -follow \ -name '*.schemas' \ @@ -112,3 +95,70 @@ if [ -n "$ENTRIES" ]; then echo "Entries merged into the GConf cache" fi fi +} + +refresh_gconf_cache () +{ +if [ -a "/etc/gconf/gconf.xml.defaults/%gconf-tree.xml" ]; then + SCHEMAS=`/usr/bin/find /etc/gconf/schemas ! -type d -follow \ + -name '*.schemas' 2>/dev/null` + ENTRIES=`/usr/bin/find /etc/gconf/schemas ! -type d -follow \ + -name '*.entries' 2>/dev/null` +else + SCHEMAS=`/usr/bin/find /etc/gconf/schemas -name '*.schemas' ! -type d` + ENTRIES=`/usr/bin/find /etc/gconf/schemas -name '*.entries' ! -type d` +fi + +if [ -n "$SCHEMAS" ]; then + echo "Updating GConf cache for the following schemas:" + echo "$SCHEMAS" | /bin/sed -e 's/^/ /' + # redirect stdout to /dev/null because gconftool is too verbose + # errors are printed to stderr + GCONF_CONFIG_SOURCE=xml:merged:/etc/gconf/gconf.xml.defaults \ + /usr/bin/gconftool-2 --makefile-install-rule $SCHEMAS > /dev/null + if [ $? -ne 0 ]; then + echo "gconftool-2 exited with an error while installing schemas" + exit $SMF_EXIT_ERR_FATAL + else + echo "Schema files merged in the GConf cache" + fi +fi + +if [ -n "$ENTRIES" ]; then + echo "Updating GConf cache for the following entries:" + echo "$ENTRIES" | /bin/sed -e 's/^/ /' + # redirect stdout to /dev/null because gconftool is too verbose + # errors are printed to stderr + /usr/bin/gconftool-2 --direct \ + --config-source=xml:merged:/etc/gconf/gconf.xml.defaults \ + --load $ENTRIES > /dev/null + if [ $? -ne 0 ]; then + echo "gconftool-2 exited with an error while adding entries" + exit $SMF_EXIT_ERR_FATAL + else + echo "Entries merged into the GConf cache" + fi +fi +} + +METHOD=$1 + +case "$METHOD" in + 'start') + # Continue with rest of script + ;; + 'refresh') + ;; + -*) + echo $USAGE + exit 2 + ;; + *) + echo "Invalid method $METHOD" + exit 2 + ;; +esac + +${METHOD}_gconf_cache + +exit $SMF_EXIT_OK diff --git a/icon-cache/icon-cache b/icon-cache/icon-cache index 7beb1c1..d0a9c03 100755 --- a/icon-cache/icon-cache +++ b/icon-cache/icon-cache @@ -35,29 +35,13 @@ PATH=/usr/bin:/usr/sbin . /lib/svc/share/smf_include.sh -USAGE="Usage: $0 " +USAGE="Usage: $0 { start | refresh }" if [ $# -ne 1 ] ; then echo $USAGE exit 2 fi -METHOD=$1 - -case $METHOD in - start) - # Continue with rest of script - ;; - -*) - echo $USAGE - exit 2 - ;; - *) - echo "Invalid method $METHOD" - exit 2 - ;; -esac - # # for each icon directory update the icon cache if: # - a index.theme file exist @@ -67,8 +51,8 @@ esac # - if no cache exist but subdirectories (hence icons) are present # -IFS=" -" +start_icon_cache () +{ for DIR in /usr/share/icons/*; do if [ -a "$DIR/index.theme" ] ; then if [ -a "$DIR/icon-theme.cache" ] ; then @@ -101,5 +85,61 @@ generating the icon cache for $DIR." fi fi done +} + +refresh_icon_cache () +{ +for DIR in /usr/share/icons/*; do + if [ -a "$DIR/index.theme" ] ; then + if [ -a "$DIR/icon-theme.cache" ] ; then + RESULT=`/usr/bin/find $DIR ! -type d -follow 2>/dev/null` + else + RESULT=`/usr/bin/find $DIR -type d` + if [ ${#RESULT} == ${#DIR} ]; then + echo "$DIR doesn't contain subdirectories. No icon cache is needed" + RESULT="" + else + RESULT="nocache" + fi + fi + if [ -n "$RESULT" ]; then + if [ "$RESULT" == "nocache" ]; then + echo "No icon cache found in $DIR. Generating one." + else + echo "Icons newer than the cache found in $DIR. Updating the cache." + fi + rm -f $DIR/.icon-theme.cache + /usr/bin/gtk-update-icon-cache $DIR + if [ $? -ne 0 ]; then + echo "/usr/bin/gtk-update-icon-cache exited with an error while \ +generating the icon cache for $DIR." + exit $SMF_EXIT_ERR_FATAL + else + echo "Icon cache successfully generated in $DIR" + fi + fi + fi +done +} + +METHOD=$1 + +case $METHOD in + start) + # Continue with rest of script + ;; + refresh) + ;; + -*) + echo $USAGE + exit 2 + ;; + *) + echo "Invalid method $METHOD" + exit 2 + ;; +esac + +${METHOD}_icon_cache exit $SMF_EXIT_OK diff --git a/input-method/input-method-cache b/input-method/input-method-cache index d75c4e0..339aa19 100755 --- a/input-method/input-method-cache +++ b/input-method/input-method-cache @@ -35,29 +35,13 @@ PATH=/usr/bin:/usr/sbin . /lib/svc/share/smf_include.sh -USAGE="Usage: $0 " +USAGE="Usage: $0 { start | refresh }" if [ $# -ne 1 ] ; then echo $USAGE exit 2 fi -METHOD=$1 - -case "$METHOD" in - start) - # Continue with rest of script - ;; - -*) - echo $USAGE - exit 2 - ;; - *) - echo "Invalid method $METHOD" - exit 2 - ;; -esac - # # for each architecture @@ -69,15 +53,14 @@ esac # if list generate cache # -IFS=" -" - ARCH64=`/bin/isainfo -k` if [[ $ARCH64 != "amd64" ]] && [[ "$ARCH64" != "sparcv9" ]]; then ARCH64="" fi +start_input_method_cache () +{ for DIR in "" $ARCH64; do if [ -a "/etc/$DIR/gtk-2.0/gtk.immodules" ]; then RESULT=`/usr/bin/find /usr/lib/$DIR/gtk-2.0/*/immodules/*.so ! -type d -follow \ @@ -98,5 +81,51 @@ for DIR in "" $ARCH64; do fi fi done +} + +refresh_input_method_cache () +{ +for DIR in "" $ARCH64; do + if [ -a "/etc/$DIR/gtk-2.0/gtk.immodules" ]; then + RESULT=`/usr/bin/find /usr/lib/$DIR/gtk-2.0/*/immodules/*.so ! -type d \ + -follow 2>/dev/null` + else + RESULT="no cache file" + fi + + if [ -n "$RESULT" ]; then + echo "updating/creating im modules cache file" + /usr/bin/$DIR/gtk-query-immodules-2.0 /usr/lib/$DIR/gtk-2.0/*/immodules/*.so \ + > /etc/$DIR/gtk-2.0/gtk.immodules + if [ $? -ne 0 ]; then + echo "gtk-query-immodules-2.0 exited with an error while generating the cache file /etc/$DIR/gtk-2.0/gtk.immodules" + exit $SMF_EXIT_ERR_FATAL + else + echo "input method cache installed in /etc/$DIR/gtk-2.0/gtk.immodules" + fi + fi +done +} + +METHOD=$1 + +case "$METHOD" in + start) + # Continue with rest of script + ;; + refresh) + # Continue with rest of script + ;; + -*) + echo $USAGE + exit 2 + ;; + *) + echo "Invalid method $METHOD" + exit 2 + ;; +esac + +${METHOD}_input_method_cache exit $SMF_EXIT_OK diff --git a/mime-types-cache/mime-types-cache b/mime-types-cache/mime-types-cache index 51a4cb8..0e69519 100755 --- a/mime-types-cache/mime-types-cache +++ b/mime-types-cache/mime-types-cache @@ -34,30 +34,13 @@ PATH=/usr/bin:/usr/sbin . /lib/svc/share/smf_include.sh -USAGE="Usage: $0 " +USAGE="Usage: $0 { start | refresh }" if [ $# -ne 1 ] ; then echo $USAGE exit 2 fi -METHOD=$1 - -case "$METHOD" in - start) - # Continue with rest of script - ;; - -*) - echo $USAGE - exit 2 - ;; - *) - echo "Invalid method $METHOD" - exit 2 - ;; -esac - - # # IF the mime cache exist then : # get the list of mime type files newer than the cache file @@ -67,8 +50,8 @@ esac # generate the cache # -IFS=" -" +start_mime_types_cache () +{ if [ -a "/usr/share/mime/mime.cache" ]; then RESULT=`/usr/bin/find /usr/share/mime/packages ! -type d -follow \ -newer /usr/share/mime/mime.cache 2>/dev/null` @@ -86,4 +69,47 @@ if [ -n "$RESULT" ]; then echo "mime type cache /usr/share/mime/mime.cache generated" fi fi +} + +refresh_mime_types_cache () +{ +if [ -a "/usr/share/mime/mime.cache" ]; then + RESULT=`/usr/bin/find /usr/share/mime/packages ! -type d -follow 2>/dev/null` +else + RESULT="no cache found" +fi + +if [ -n "$RESULT" ]; then + echo "updating mime type cache" + /usr/bin/update-mime-database /usr/share/mime + if [ $? -ne 0 ]; then + echo "update-mime-database exited with an error while generating the mime type cache /usr/share/mime/mime.cache" + exit $SMF_EXIT_ERR_FATAL + else + echo "mime type cache /usr/share/mime/mime.cache generated" + fi +fi +} + +METHOD=$1 + +case "$METHOD" in + start) + # Continue with rest of script + ;; + refresh) + # Continue with rest of script + ;; + -*) + echo $USAGE + exit 2 + ;; + *) + echo "Invalid method $METHOD" + exit 2 + ;; +esac + +${METHOD}_mime_types_cache + exit $SMF_EXIT_OK diff --git a/pixbuf-loaders/pixbuf-loaders-installer b/pixbuf-loaders/pixbuf-loaders-installer index b6666fc..ea983df 100755 --- a/pixbuf-loaders/pixbuf-loaders-installer +++ b/pixbuf-loaders/pixbuf-loaders-installer @@ -35,30 +35,13 @@ PATH=/usr/bin:/usr/sbin . /lib/svc/share/smf_include.sh -USAGE="Usage: $0 " +USAGE="Usage: $0 { start | refresh }" if [ $# -ne 1 ] ; then echo $USAGE exit 2 fi -METHOD=$1 - -case "$METHOD" in - start) - # Continue with rest of script - ;; - -*) - echo $USAGE - exit 2 - ;; - *) - echo "Invalid method $METHOD" - exit 2 - ;; -esac - - # # for each architecture # if loader file exist @@ -69,15 +52,14 @@ esac # if list generate loader list # -IFS=" -" - ARCH64=`/bin/isainfo -k` if [[ $ARCH64 != "amd64" ]] && [[ "$ARCH64" != "sparcv9" ]]; then ARCH64="" fi +start_pixbuf_loaders_installer () +{ for DIR in "" $ARCH64; do if [ -a "/etc/$DIR/gtk-2.0/gdk-pixbuf.loaders" ]; then RESULT=`/usr/bin/find /usr/lib/$DIR/gtk-2.0/*/loaders/*.so ! -type d -follow \ @@ -97,4 +79,50 @@ for DIR in "" $ARCH64; do fi fi done +} + +refresh_pixbuf_loaders_installer () +{ +for DIR in "" $ARCH64; do + if [ -a "/etc/$DIR/gtk-2.0/gdk-pixbuf.loaders" ]; then + RESULT=`/usr/bin/find /usr/lib/$DIR/gtk-2.0/*/loaders/*.so ! -type d \ + -follow -print 2>/dev/null` + else + RESULT="no loader file" + fi + + if [ -n "$RESULT" ]; then + echo "updating/creating gdk pixbuf loader file" + /usr/bin/$DIR/gdk-pixbuf-query-loaders > /etc/$DIR/gtk-2.0/gdk-pixbuf.loaders + if [ $? -ne 0 ]; then + echo "gdk-pixbuf-query-loaders exited with an error while generating the installer file /etc/$DIR/gtk-2.0/gdk-pixbuf.loaders" + exit $SMF_EXIT_ERR_FATAL + else + echo "gdk pixbuf loaders installed in /etc/$DIR/gtk-2.0/gdk-pixbuf.loaders" + fi + fi +done +} + +METHOD=$1 + +case "$METHOD" in + start) + # Continue with rest of script + ;; + refresh) + # Continue with rest of script + ;; + -*) + echo $USAGE + exit 2 + ;; + *) + echo "Invalid method $METHOD" + exit 2 + ;; +esac + +${METHOD}_pixbuf_loaders_installer + exit $SMF_EXIT_OK