Skip to content

Commit

Permalink
Merge branch 'hooks'
Browse files Browse the repository at this point in the history
* hooks:
  bee-install: remove defect pre-install hook
  hooks: grep more specific
  hooks: update-mime-database be less verbose
  hooks: change way of checking for binaries
  hooks: use pkg-config in gdk-pixbuf-query-loaders
  hook-tools: gdk-pixbuf-query-loaders.sh - tool to update pixbuf loaders cache
  hook-tools: update-desktop-database.sh - tool to update mimeinfo cache
  hook-tools: ldconfig.sh - new tool to update library database
  hook-tools: gtk-update-icon-cache.sh - tool to update icon cache
  hook-tools: mkfontdir-mkfontscale.sh - tool to update fonts
  hook-tools: glib-compile-schemas.sh - tool to update schemas
  hook-tools: update-mime-database.sh - added updating of mime databases
  Makefile/bee-install/bee-remove: added auto execution of hooks
  • Loading branch information
mariux committed Jul 20, 2011
2 parents 604d3fb + 1b33cbd commit 5973a6b
Show file tree
Hide file tree
Showing 10 changed files with 254 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
11 changes: 11 additions & 0 deletions src/bee-install.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -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 ###
##
Expand Down
13 changes: 13 additions & 0 deletions src/bee-remove.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
30 changes: 30 additions & 0 deletions src/hooks.d/gdk-pixbuf-query-loaders.sh
Original file line number Diff line number Diff line change
@@ -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
30 changes: 30 additions & 0 deletions src/hooks.d/glib-compile-schemas.sh
Original file line number Diff line number Diff line change
@@ -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
29 changes: 29 additions & 0 deletions src/hooks.d/gtk-update-icon-cache.sh
Original file line number Diff line number Diff line change
@@ -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
27 changes: 27 additions & 0 deletions src/hooks.d/ldconfig.sh
Original file line number Diff line number Diff line change
@@ -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
49 changes: 49 additions & 0 deletions src/hooks.d/mkfontdir-mkfontscale.sh
Original file line number Diff line number Diff line change
@@ -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
30 changes: 30 additions & 0 deletions src/hooks.d/update-desktop-database.sh
Original file line number Diff line number Diff line change
@@ -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
26 changes: 26 additions & 0 deletions src/hooks.d/update-mime-database.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 5973a6b

Please sign in to comment.