aboutsummaryrefslogtreecommitdiff
path: root/hooks/demos/new_packages.bash.in
blob: 9783e7a6eb422f63c0f5d3eff63f61645283d5e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/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/
#
# You should ensure that it has execute permissions.

source ${PALUDIS_ECHO_FUNCTIONS_DIR:-${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
    echo
    ;;

    *)
    ewarn "new_packages.bash doesn't know what to do for HOOK=\"${HOOK}\""
    ;;
esac