diff --git a/Makefile b/Makefile index 9e0df37..31641a9 100644 --- a/Makefile +++ b/Makefile @@ -39,6 +39,9 @@ LIBRARY_SHELL=beelib.config HELPER_BEESH_SHELL=configure cmake autogen perl-module perl-module-makemaker make python-module +HELPER_HOOKS_SHELL=update-mime-database glib-compile-schemas mkfontdir-mkfontscale gtk-update-icon-cache \ + ldconfig update-desktop-database gdk-pixbuf-query-loaders + CONFIG_TEMPLATES=fallback CONFIG_FILES=skiplist beerc @@ -130,6 +133,12 @@ install-core: build install -m 0644 src/beesh.d/$${i}.sh ${DESTDIR}${LIBEXECDIR}/bee/beesh.d/$${i}.sh ; \ done + @mkdir -p ${DESTDIR}${LIBEXECDIR}/bee/hooks.d + @for i in ${HELPER_HOOKS_SHELL} ; do \ + echo "installing ${DESTDIR}${LIBEXECDIR}/bee/hooks.d/$${i}.sh" ; \ + install -m 0755 src/hooks.d/$${i}.sh ${DESTDIR}${LIBEXECDIR}/bee/hooks.d/$${i}.sh ; \ + done + install-config: @mkdir -p ${DESTDIR}${DEFCONFDIR}/bee diff --git a/src/bee-install.sh.in b/src/bee-install.sh.in index 3898c25..b74ec27 100755 --- a/src/bee-install.sh.in +++ b/src/bee-install.sh.in @@ -260,9 +260,20 @@ do_install() { --transform="s,^PATCHES,${BEE_METADIR}/${pkg}/PATCHES," \ --show-transformed-names + [ "${NOOP}" != "yes" ] && run_hooks post-install ${pkg} + exit $? } +function run_hooks() { + local action=${1} + local pkg=${2} + + for t in ${BEE_LIBEXECDIR}/bee/hooks.d/*.sh ; do + ${t} ${action} ${pkg} + done +} + ############################################################################### ### print_pkg_list ### ## diff --git a/src/bee-remove.sh.in b/src/bee-remove.sh.in index fff3b06..85b3b29 100755 --- a/src/bee-remove.sh.in +++ b/src/bee-remove.sh.in @@ -39,6 +39,8 @@ do_remove() { FILES=$(@BINDIR@/beefind.pl --dump ${pkg}/FILES) + [ "${NOOP}" != "yes" ] && run_hooks pre-remove ${pkg} + # removing files for f in $FILES ; do # test for other pkg @@ -63,12 +65,23 @@ do_remove() { fi done + [ "${NOOP}" != "yes" ] && run_hooks post-remove ${pkg} + #cleaning up meta directory if [ -f ${pkg}/FILES ] ; then ${NOOP:+echo} rm -vfr ${pkg} fi } +function run_hooks() { + local action=${1} + local pkg=${2##*/} + + for t in ${BEE_LIBEXECDIR}/bee/hooks.d/*.sh ; do + ${t} ${action} ${pkg} + done +} + usage() { cat <<-EOF bee-remove v${VERSION} 2009-2011 diff --git a/src/hooks.d/gdk-pixbuf-query-loaders.sh b/src/hooks.d/gdk-pixbuf-query-loaders.sh new file mode 100644 index 0000000..8f660bc --- /dev/null +++ b/src/hooks.d/gdk-pixbuf-query-loaders.sh @@ -0,0 +1,30 @@ +#!/bin/bash +action=${1} +pkg=${2} + +if [ -z ${BEE_VERSION} ] ; then + echo >&2 "BEE-ERROR: cannot call $0 from the outside of bee .." + exit 1 +fi + +if ! which gdk-pixbuf-query-loaders >/dev/null 2>&1 ; then + exit 0 +fi + +gdk_pixbuf_moduledir=$(pkg-config --variable=gdk_pixbuf_moduledir gdk-pixbuf-2.0) +gdk_pixbuf_cache_file=$(pkg-config --variable=gdk_pixbuf_cache_file gdk-pixbuf-2.0) + +if grep -q "file=${gdk_pixbuf_moduledir}" ${BEE_METADIR}/${pkg}/FILES ; then + case "${action}" in + "post-install") + rm -f ${gdk_pixbuf_cache_file} + gdk-pixbuf-query-loaders --update-cache + ;; + "pre-remove") + rm -f ${gdk_pixbuf_cache_file} + ;; + "post-remove") + gdk-pixbuf-query-loaders --update-cache + ;; + esac +fi diff --git a/src/hooks.d/glib-compile-schemas.sh b/src/hooks.d/glib-compile-schemas.sh new file mode 100644 index 0000000..307ccc7 --- /dev/null +++ b/src/hooks.d/glib-compile-schemas.sh @@ -0,0 +1,30 @@ +#!/bin/bash +action=${1} +pkg=${2} + +if [ -z ${BEE_VERSION} ] ; then + echo >&2 "BEE-ERROR: cannot call $0 from the outside of bee .." + exit 1 +fi + +if ! which glib-compile-schemas >/dev/null 2>&1 ; then + exit 0 +fi + +for dir in ${XDG_DATA_DIRS//:/ } ; do + schema_dir=${dir}/glib-2.0/schemas + if grep -q "file=${schema_dir}" ${BEE_METADIR}/${pkg}/FILES ; then + case "${action}" in + "post-install") + rm -f ${schema_dir}/gschemas.compiled + glib-compile-schemas ${schema_dir} + ;; + "pre-remove") + rm -f ${schema_dir}/gschemas.compiled + ;; + "post-remove") + glib-compile-schemas ${schema_dir} + ;; + esac + fi +done diff --git a/src/hooks.d/gtk-update-icon-cache.sh b/src/hooks.d/gtk-update-icon-cache.sh new file mode 100644 index 0000000..c6b80e2 --- /dev/null +++ b/src/hooks.d/gtk-update-icon-cache.sh @@ -0,0 +1,29 @@ +#!/bin/bash +action=${1} +pkg=${2} + +if [ -z ${BEE_VERSION} ] ; then + echo >&2 "BEE-ERROR: cannot call $0 from the outside of bee .." + exit 1 +fi + +if ! which gtk-update-icon-cache >/dev/null 2>&1 ; then + exit 0 +fi + +for dir in ${XDG_DATA_DIRS//:/ } ; do + icon_base_dir=${dir}/icons + for line in $(grep -h "file=${icon_base_dir}/.*/index.theme" ${BEE_METADIR}/${pkg}/FILES) ; do + eval $(beesep ${line}) + icon_dir=${file%%/index.theme} + case "${action}" in + "post-install") + rm -f ${icon_dir}/icon-theme.cache + gtk-update-icon-cache -f ${icon_dir} + ;; + "pre-remove") + rm -f ${icon_dir}/icon-theme.cache + ;; + esac + done +done diff --git a/src/hooks.d/ldconfig.sh b/src/hooks.d/ldconfig.sh new file mode 100644 index 0000000..385b0fc --- /dev/null +++ b/src/hooks.d/ldconfig.sh @@ -0,0 +1,27 @@ +#!/bin/bash +action=${1} +pkg=${2} + +if [ -z ${BEE_VERSION} ] ; then + echo >&2 "BEE-ERROR: cannot call $0 from the outside of bee .." + exit 1 +fi + +if [ ${UID} -ne 0 ] ; then + exit 0 +fi + +if ! which ldconfig >/dev/null 2>&1 ; then + exit 0 +fi + +if grep -q "/lib/" ${BEE_METADIR}/${pkg}/FILES ; then + case "${action}" in + "post-install") + ldconfig + ;; + "post-remove") + ldconfig + ;; + esac +fi diff --git a/src/hooks.d/mkfontdir-mkfontscale.sh b/src/hooks.d/mkfontdir-mkfontscale.sh new file mode 100644 index 0000000..1b8d7eb --- /dev/null +++ b/src/hooks.d/mkfontdir-mkfontscale.sh @@ -0,0 +1,49 @@ +#!/bin/bash +action=${1} +pkg=${2} + +if [ -z ${BEE_VERSION} ] ; then + echo >&2 "BEE-ERROR: cannot call $0 from the outside of bee .." + exit 1 +fi + +if ! which mkfontscale mkfontdir >/dev/null 2>&1 ; then + exit 0 +fi + +function clean_font_dirs() { + local font_base_dir=${1} + + font_dirs=$(find ${font_base_dir} -mindepth 1 -type d) + for d in ${font_dirs} ; do + rm -f ${d}/fonts.{scale,dir} + done +} + +function update_fonts() { + local font_base_dir=${1} + + font_dirs=$(find ${font_base_dir} -mindepth 1 -type d) + for d in ${font_dirs} ; do + mkfontscale ${d} + mkfontdir ${d} + done +} + +for dir in ${XDG_DATA_DIRS//:/ } ; do + font_base_dir=${dir}/fonts + if grep -q "file=${font_base_dir}" ${BEE_METADIR}/${pkg}/FILES ; then + case "${action}" in + "post-install") + clean_font_dirs ${font_base_dir} + update_fonts ${font_base_dir} + ;; + "pre-remove") + clean_font_dirs ${font_base_dir} + ;; + "post-remove") + update_fonts ${font_base_dir} + ;; + esac + fi +done diff --git a/src/hooks.d/update-desktop-database.sh b/src/hooks.d/update-desktop-database.sh new file mode 100644 index 0000000..7281f78 --- /dev/null +++ b/src/hooks.d/update-desktop-database.sh @@ -0,0 +1,30 @@ +#!/bin/bash +action=${1} +pkg=${2} + +if [ -z ${BEE_VERSION} ] ; then + echo >&2 "BEE-ERROR: cannot call $0 from the outside of bee .." + exit 1 +fi + +if ! which update-desktop-database >/dev/null 2>&1 ; then + exit 0 +fi + +for dir in ${XDG_DATA_DIRS//:/ } ; do + desktop_dir=${dir}/applications + if grep -q "file=${desktop_dir}/.*\.desktop" ${BEE_METADIR}/${pkg}/FILES ; then + case "${action}" in + "post-install") + rm -f ${desktop_dir}/mimeinfo.cache + update-desktop-database ${desktop_dir} + ;; + "pre-remove") + rm -f ${desktop_dir}/mimeinfo.cache + ;; + "post-remove") + update-desktop-database ${desktop_dir} + ;; + esac + fi +done diff --git a/src/hooks.d/update-mime-database.sh b/src/hooks.d/update-mime-database.sh new file mode 100644 index 0000000..607ae51 --- /dev/null +++ b/src/hooks.d/update-mime-database.sh @@ -0,0 +1,26 @@ +#!/bin/bash +action=${1} +pkg=${2} + +if [ -z ${BEE_VERSION} ] ; then + echo >&2 "BEE-ERROR: cannot call $0 from the outside of bee .." + exit 1 +fi + +if ! which update-mime-database >/dev/null 2>&1 ; then + exit 0 +fi + +for dir in ${XDG_DATA_DIRS//:/ } ; do + mime_dir=${dir}/mime + if grep -q "file=${mime_dir}/packages" ${BEE_METADIR}/${pkg}/FILES ; then + case "${action}" in + "post-install") + update-mime-database ${mime_dir} + ;; + "post-remove") + update-mime-database ${mime_dir} + ;; + esac + fi +done