Skip to content

Commit

Permalink
2009-01-28 Ghee Teo <ghee.teo@sun.com>
Browse files Browse the repository at this point in the history
        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:



git-svn-id: file:///export/mirror/svn/svn.opensolaris.org/svn/jds/desktop-cache/trunk@29 080c96c5-abdd-cfe1-8e51-841d7e5cfe93
  • Loading branch information
gheet committed Jan 28, 2009
1 parent ae6ddd6 commit da9403c
Show file tree
Hide file tree
Showing 8 changed files with 328 additions and 121 deletions.
12 changes: 12 additions & 0 deletions ChangeLog
@@ -1,3 +1,15 @@
2009-01-28 Ghee Teo <ghee.teo@sun.com>

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 - <erwann.chenede@sun.com>

* configure.in: bump to 0.1.3
Expand Down
2 changes: 1 addition & 1 deletion 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])

Expand Down
62 changes: 42 additions & 20 deletions desktop-mime-cache/desktop-mime-cache
Expand Up @@ -34,30 +34,13 @@ PATH=/usr/bin:/usr/sbin

. /lib/svc/share/smf_include.sh

USAGE="Usage: $0 <method>"
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
Expand All @@ -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`
Expand All @@ -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
90 changes: 70 additions & 20 deletions gconf-cache/gconf-cache
Expand Up @@ -35,30 +35,13 @@ PATH=/usr/bin:/usr/sbin

. /lib/svc/share/smf_include.sh

USAGE="Usage: $0 <method>"
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
Expand All @@ -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' \
Expand Down Expand Up @@ -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
78 changes: 59 additions & 19 deletions icon-cache/icon-cache
Expand Up @@ -35,29 +35,13 @@ PATH=/usr/bin:/usr/sbin

. /lib/svc/share/smf_include.sh

USAGE="Usage: $0 <method>"
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
Expand All @@ -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
Expand Down Expand Up @@ -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

0 comments on commit da9403c

Please sign in to comment.