aboutsummaryrefslogtreecommitdiff
path: root/hooks/demos/pretend_resume.hook.in
blob: 50169598fec7366765b431076d17ba50da347044 (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
#!/usr/bin/env bash
# vim: set et sw=4 sts=4 :

# This hook makes Paludis display the resume command at the end of the
# --install --pretend output, so the installation can be carried out
# without recalculating dependencies, rescanning libraries, etc. To
# enable this functionality, this script should be copied or symlinked
# into:
#
#     @DATADIR@/paludis/hooks/auto/
#
# You should ensure that it has execute permissions.

hook_run_install_pretend_post() {
    [[ -n ${RESUME_COMMAND} ]] || exit 0
    ${DEPLIST_HAS_ERRORS} && exit 0
    echo

    local template_var=$(tr '[[:lower:]]' '[[:upper:]]' <<<"${PALUDIS_CLIENT}")_CMDLINE_resume_command_template
    local template=${!template_var}
    local file

    if [[ -n ${template} ]]; then
        if [[ ${template} = *XXXXXX* ]]; then
            file="$(mktemp "${template}")"
        else
            file=${template}
        fi

        if touch "${file}" && chmod 644 "${file}" && echo "${RESUME_COMMAND}" >"${file}"; then
            echo "Resume command saved to file: ${file}"
        else
            echo "Resume command NOT saved to file: ${file}"
            echo "Resume command: ${RESUME_COMMAND}"
        fi

    else
        echo "Resume command: ${RESUME_COMMAND}"
    fi
}

hook_auto_names() {
    echo install_pretend_post
}