aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-12-09 02:39:34 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-12-09 02:39:34 +0000
commit934b1264385f780e997e7bb895ea0b98c13fc1cb (patch)
tree295203e69ccfdece6781fcb42d19b6c8a9bee2df
parentd9de19673ae38c62105d2c1f11d906d45ca1ffa6 (diff)
downloadpaludis-934b1264385f780e997e7bb895ea0b98c13fc1cb.tar.gz
paludis-934b1264385f780e997e7bb895ea0b98c13fc1cb.tar.xz
Oops
-rw-r--r--hooks/demos/elog.bash.in93
1 files changed, 93 insertions, 0 deletions
diff --git a/hooks/demos/elog.bash.in b/hooks/demos/elog.bash.in
new file mode 100644
index 0000000..b903024
--- /dev/null
+++ b/hooks/demos/elog.bash.in
@@ -0,0 +1,93 @@
+#!/bin/bash
+# vim: set et sw=4 sts=4 :
+
+# This hook makes Paludis store messages generated by an ebuild in a file.
+# These stored messages are then displayed to the user after a merge. To enable
+# this functionality, this script should be copied or symlinked into:
+#
+# @DATADIR@/paludis/hooks/elog/
+# @DATADIR@/paludis/hooks/install_all_pre/
+# @DATADIR@/paludis/hooks/install_all_post/
+# @DATADIR@/paludis/hooks/install_fail/
+# @DATADIR@/paludis/hooks/uninstall_all_pre/
+# @DATADIR@/paludis/hooks/uninstall_all_post/
+# @DATADIR@/paludis/hooks/uninstall_fail/
+#
+# And optionally:
+#
+# @DATADIR@/paludis/hooks/einfo/
+# @DATADIR@/paludis/hooks/ewarn/
+# @DATADIR@/paludis/hooks/eerror/
+#
+# You should ensure that it has execute permissions.
+
+source ${PALUDIS_EBUILD_DIR}/echo_functions.bash
+
+logfile="${ROOT}/var/log/paludis.elog.${PALUDIS_PID}"
+
+case "${HOOK}" in
+ elog)
+ echo "L ${CATEGORY}/${PF} ${MESSAGE}" >> "${logfile}"
+ ;;
+
+ einfo)
+ echo "I ${CATEGORY}/${PF} ${MESSAGE}" >> "${logfile}"
+ ;;
+
+ ewarn)
+ echo "W ${CATEGORY}/${PF} ${MESSAGE}" >> "${logfile}"
+ ;;
+
+ eerror)
+ echo "E ${CATEGORY}/${PF} ${MESSAGE}" >> "${logfile}"
+ ;;
+
+ install_all_pre|uninstall_all_pre)
+ rm -f "${logfile}"
+ touch "${logfile}" || die "Couldn't create '${logfile}' for elog hooks"
+ ;;
+
+ install_all_post|uninstall_all_post|install_fail|uninstall_fail)
+ echo
+ old_pf=""
+ while read line ; do
+ line_status=$(echo ${line} | cut -d' ' -f1 )
+ line_pf=$(echo ${line} | cut -d' ' -f2 )
+ line_message=$(echo ${line} | cut -d' ' -f3- )
+
+ if [[ "${old_pf}" != "${line_pf}" ]] ; then
+ echo
+ echo "${COLOUR_GOOD}Summary of messages from ${line_pf}:${COLOUR_NORMAL}"
+ echo
+ old_pf="${line_pf}"
+ fi
+
+ case "${line_status}" in
+ L|I)
+ echo -ne " ${COLOUR_GOOD}*${COLOUR_NORMAL} "
+ ;;
+
+ W)
+ echo -ne " ${COLOUR_WARN}*${COLOUR_NORMAL} "
+ ;;
+
+ E)
+ echo -ne " ${COLOUR_BAD}*${COLOUR_NORMAL} "
+ ;;
+ esac
+ echo "${line_message}"
+
+ done <"${logfile}"
+
+ rm -f "${logfile}"
+ ;;
+
+ *)
+ paludis_ecmd \
+ "ewarn" \
+ "" \
+ "`echo -ne " ${COLOUR_WARN}*${COLOUR_NORMAL} "`" \
+ "elog.bash doesn't know what to do for HOOK=\"${HOOK}\""
+ ;;
+esac
+