diff -Naur spkg-1.0rc13-old//include/commands.h spkg-1.0rc13/include/commands.h --- spkg-1.0rc13-old//include/commands.h 2010-06-14 09:29:00.000000000 +0300 +++ spkg-1.0rc13/include/commands.h 2011-02-09 15:37:50.818000041 +0200 @@ -34,6 +34,7 @@ gboolean no_scripts; /**< Turn off scripts (doinst.sh) execution. */ gboolean no_optsyms; /**< Turn off symlink optimizations. */ gboolean no_ldconfig; /**< Turn off ldconfig execution. */ + gboolean no_gtk_update_icon_cache; /**< Turn off gtk-update-icon-cache execution. */ gboolean reinstall; /**< Reinstall package when it is already installed (for upgrade). */ gchar** bl_symopts; /**< Blacklist for symlink optimizations. */ gchar** bl_upgrade; /**< Blacklist for upgrade. */ diff -Naur spkg-1.0rc13-old//src/cmd-install.c spkg-1.0rc13/src/cmd-install.c --- spkg-1.0rc13-old//src/cmd-install.c 2010-06-14 09:30:32.000000000 +0300 +++ spkg-1.0rc13/src/cmd-install.c 2011-02-09 15:42:13.119000041 +0200 @@ -525,6 +525,7 @@ - finish transaction - close package file - run doinst.sh + - run gtk-update-icon-cache in the hicolor icon dir - run ldconfig - remove install/ */ @@ -600,6 +601,7 @@ pkg->location = g_strdup(pkgfile); gboolean need_ldconfig = 0; + gboolean need_update_icon_cache = 0; gboolean has_doinst = 0; gchar* sane_path = NULL; gchar* root = sanitize_root_path(opts->root); @@ -637,6 +639,10 @@ if (!need_ldconfig && g_str_has_suffix(sane_path, ".so")) need_ldconfig = 1; + /* check if package contains .desktop files */ + if (!need_update_icon_cache && g_str_has_suffix(sane_path, ".desktop")) + need_update_icon_cache = 1; + /* check for metadata files */ if (!strcmp(sane_path, "install/slack-desc")) { @@ -766,6 +772,29 @@ } } + /* run gtk-update-icon-cache */ + if (need_update_icon_cache && !opts->no_gtk_update_icon_cache) + { + if (access("/usr/bin/gtk-update-icon-cache", X_OK) == 0) + { + gchar* cmd = g_strdup_printf("/usr/bin/gtk-update-icon-cache %susr/share/icons/hicolor > /dev/null 2>&1", root); + + _notice("Running /usr/bin/gtk-update-icon-cache..."); + if (!opts->dryrun) + { + gint rv = system(cmd); + if (rv < 0) + _warning("Can't execute /usr/bin/gtk-update-icon-cache. (%s)", strerror(errno)); + else if (rv > 0) + _warning("Program /usr/bin/gtk-update-icon-cache failed. (%d)", rv); + } + } + else + { + _warning("Program /usr/bin/gtk-update-icon-cache was not found on the system."); + } + } + if (!opts->dryrun) { gchar* install_path = g_strdup_printf("%sinstall", root); diff -Naur spkg-1.0rc13-old//src/cmd-upgrade.c spkg-1.0rc13/src/cmd-upgrade.c --- spkg-1.0rc13-old//src/cmd-upgrade.c 2009-06-26 18:55:43.000000000 +0300 +++ spkg-1.0rc13/src/cmd-upgrade.c 2011-02-09 15:41:33.960000042 +0200 @@ -630,6 +630,7 @@ - close package file - run doinst.sh - run ldconfig + - run gtk-update-icon-cache in the hicolor icon dir - remove install/ */ @@ -736,6 +737,7 @@ pkg->location = g_strdup(pkgfile); gboolean need_ldconfig = 0; + gboolean need_update_icon_cache = 0; gboolean has_doinst = 0; gchar* sane_path = NULL; gchar* root = sanitize_root_path(opts->root); @@ -774,6 +776,10 @@ if (!need_ldconfig && g_str_has_suffix(sane_path, ".so")) need_ldconfig = 1; + /* check if package contains .desktop files */ + if (!need_update_icon_cache && g_str_has_suffix(sane_path, ".desktop")) + need_update_icon_cache = 1; + /* check for metadata files */ if (!strcmp(sane_path, "install/slack-desc")) { @@ -912,6 +918,29 @@ } } + /* run gtk-update-icon-cache */ + if (need_update_icon_cache && !opts->no_gtk_update_icon_cache) + { + if (access("/usr/bin/gtk-update-icon-cache", X_OK) == 0) + { + gchar* cmd = g_strdup_printf("/usr/bin/gtk-update-icon-cache %susr/share/icons/hicolor > /dev/null 2>&1", root); + + _notice("Running /usr/bin/gtk-update-icon-cache..."); + if (!opts->dryrun) + { + gint rv = system(cmd); + if (rv < 0) + _warning("Can't execute /usr/bin/gtk-update-icon-cache. (%s)", strerror(errno)); + else if (rv > 0) + _warning("Program /usr/bin/gtk-update-icon-cache failed. (%d)", rv); + } + } + else + { + _warning("Program /usr/bin/gtk-update-icon-cache was not found on the system."); + } + } + if (!opts->dryrun) { gchar* install_path = g_strdup_printf("%sinstall", root); diff -Naur spkg-1.0rc13-old//src/main.c spkg-1.0rc13/src/main.c --- spkg-1.0rc13-old//src/main.c 2010-06-14 09:31:47.000000000 +0300 +++ spkg-1.0rc13/src/main.c 2011-02-09 15:31:59.111000042 +0200 @@ -68,6 +68,7 @@ .no_optsyms = 0, .no_scripts = 0, .no_ldconfig = 0, + .no_gtk_update_icon_cache = 0, .reinstall = 0, .bl_symopts = default_bl_symopts, .bl_upgrade = default_bl_upgrade @@ -135,6 +136,11 @@ "no-ldconfig", 0, 0, &cmd_opts.no_ldconfig, 0, "Don't execute ldconfig after installation and upgrade.", NULL }, +{ + "no-gtk-update-icon-cache", 0, 0, &cmd_opts.no_gtk_update_icon_cache, 0, + "Don't execute gtk-update-icon-cache after installation and upgrade " + "even if a .desktop file is included in the package.", NULL +}, POPT_TABLEEND };