aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-12-15 07:40:55 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-12-15 07:40:55 +0000
commitd15d456bb7327ba912227e61c95402edbaf63554 (patch)
tree28c0bb6a21185cf1f1c76fdc74095b5087e15b99
parent1afdc1a1bc9073be5f7b690b2591f88582032b36 (diff)
downloadpaludis-d15d456bb7327ba912227e61c95402edbaf63554.tar.gz
paludis-d15d456bb7327ba912227e61c95402edbaf63554.tar.xz
Add a demo hook that shows information about new packages after a sync. Allow the temporary directory used by demo hooks to be changed.
-rw-r--r--hooks/demos/Makefile.am9
-rw-r--r--hooks/demos/elog.bash.in2
-rw-r--r--hooks/demos/new_packages.bash.in50
3 files changed, 58 insertions, 3 deletions
diff --git a/hooks/demos/Makefile.am b/hooks/demos/Makefile.am
index ea6b7f2..c4bf176 100644
--- a/hooks/demos/Makefile.am
+++ b/hooks/demos/Makefile.am
@@ -2,11 +2,13 @@ SUBDIRS = .
DEMOS = \
report.bash \
- elog.bash
+ elog.bash \
+ new_packages.bash
EXTRA_DIST = \
report.bash.in \
- elog.bash.in
+ elog.bash.in \
+ new_packages.bash.in
MAINTAINERCLEANFILES = Makefile.in
CLEANFILES = *~ gmon.out *.gcov *.gcno *.gcda *.o *.so $(DEMOS)
@@ -14,6 +16,9 @@ CLEANFILES = *~ gmon.out *.gcov *.gcno *.gcda *.o *.so $(DEMOS)
hooksdemosdir = $(datadir)/paludis/hooks/demos/
hooksdemos_DATA = $(DEMOS)
+new_packages.bash : $(srcdir)/new_packages.bash.in
+ sed -e "s,@DATADIR@,$(datadir),g" < $(srcdir)/new_packages.bash.in > new_packages.bash
+
report.bash : $(srcdir)/report.bash.in
sed -e "s,@DATADIR@,$(datadir),g" < $(srcdir)/report.bash.in > report.bash
diff --git a/hooks/demos/elog.bash.in b/hooks/demos/elog.bash.in
index b903024..1743447 100644
--- a/hooks/demos/elog.bash.in
+++ b/hooks/demos/elog.bash.in
@@ -23,7 +23,7 @@
source ${PALUDIS_EBUILD_DIR}/echo_functions.bash
-logfile="${ROOT}/var/log/paludis.elog.${PALUDIS_PID}"
+logfile="${PALUDIS_HOOKS_TMPDIR:-${ROOT}/var/tmp/paludis}/elog.${PALUDIS_PID}"
case "${HOOK}" in
elog)
diff --git a/hooks/demos/new_packages.bash.in b/hooks/demos/new_packages.bash.in
new file mode 100644
index 0000000..f1395ed
--- /dev/null
+++ b/hooks/demos/new_packages.bash.in
@@ -0,0 +1,50 @@
+#!/bin/bash
+# vim: set et sw=4 sts=4 :
+
+# This hook makes Paludis display a summary of new packages available after
+# a sync. To enable this functionality, this script should be copied or
+# symlinked into:
+#
+# @DATADIR@/paludis/hooks/sync_all_pre/
+# @DATADIR@/paludis/hooks/sync_all_post/
+#
+# 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
+
+syncfile="${PALUDIS_HOOKS_TMPDIR:-${ROOT}/var/tmp/paludis}/sync.${PALUDIS_PID}"
+
+case "${HOOK}" in
+ sync_all_pre)
+ einfo "Building available packages list"
+ ${PALUDIS_COMMAND} --list-packages | grep '^\*' | cut -d' ' -f2 \
+ | sort -u >"${syncfile}"
+ ;;
+
+ sync_all_post)
+ echo
+ einfo "Newly available packages:"
+ ${PALUDIS_COMMAND} --list-packages | grep '^\*' | cut -d' ' -f2 \
+ | sort -u >"${syncfile}".new
+
+ diff "${syncfile}" "${syncfile}.new" | grep '^>' | cut -d' ' -f2- \
+ | while read line ; do
+ einfo " ${line}:"
+ einfo " $(${PALUDIS_COMMAND} -qM ${line} | sed -n -e 's/^ *DESCRIPTION: *//p' )"
+ einfo " $(${PALUDIS_COMMAND} -qM ${line} | sed -n -e 's/^ *HOMEPAGE: *//p' )"
+ done
+ rm -f "${syncfile}" "${syncfile}".new
+ ;;
+
+ *)
+ ewarn "new_packages.bash doesn't know what to do for HOOK=\"${HOOK}\""
+ ;;
+esac
+
+