aboutsummaryrefslogtreecommitdiff
path: root/hooks/demos/pretend_resume.bash.in
blob: 84c77a91b9555cead379321d42ca067435aeb758 (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
#!/bin/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/install_pretend_post/
#
# You should ensure that it has execute permissions.

[[ ${RESUME_COMMAND} = *" '="* ]] || exit 0
${DEPLIST_HAS_ERRORS} && exit 0
echo

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

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