/[gentoo-x86]/eclass/readme.gentoo.eclass
Gentoo

Contents of /eclass/readme.gentoo.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (show annotations) (download)
Fri May 24 18:05:27 2013 UTC (19 months ago) by pacho
Branch: MAIN
Changes since 1.6: +3 -3 lines
Reword sentences a bit

1 # Copyright 1999-2013 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/readme.gentoo.eclass,v 1.6 2013/05/18 16:22:27 pacho Exp $
4
5 # @ECLASS: readme.gentoo
6 # @MAINTAINER:
7 # Pacho Ramos <pacho@gentoo.org>
8 # @AUTHOR:
9 # Author: Pacho Ramos <pacho@gentoo.org>
10 # @BLURB: An eclass for installing a README.gentoo doc file recording tips
11 # shown via elog messages.
12 # @DESCRIPTION:
13 # An eclass for installing a README.gentoo doc file recording tips
14 # shown via elog messages. With this eclass, those elog messages will only be
15 # shown at first package installation and a file for later reviewing will be
16 # installed under /usr/share/doc/${PF}
17
18 if [[ ${___ECLASS_ONCE_README_GENTOO} != "recur -_+^+_- spank" ]] ; then
19 ___ECLASS_ONCE_README_GENTOO="recur -_+^+_- spank"
20
21 inherit eutils
22
23 case "${EAPI:-0}" in
24 0|1|2|3)
25 die "Unsupported EAPI=${EAPI:-0} (too old) for ${ECLASS}"
26 ;;
27 4|5)
28 # EAPI>=4 is required for REPLACING_VERSIONS preventing us
29 # from needing to export another pkg_preinst phase to save has_version
30 # result. Also relies on EAPI >=4 default src_install phase.
31 ;;
32 *)
33 die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}"
34 ;;
35 esac
36
37 EXPORT_FUNCTIONS src_install pkg_postinst
38
39 # @ECLASS-VARIABLE: DISABLE_AUTOFORMATTING
40 # @DEFAULT_UNSET
41 # @DESCRIPTION:
42 # If non-empty, DOC_CONTENTS information will be strictly respected,
43 # not getting it automatically formatted by fmt. If empty, it will
44 # rely on fmt for formatting and 'echo -e' options to tweak lines a bit.
45
46 # @ECLASS-VARIABLE: FORCE_PRINT_ELOG
47 # @DEFAULT_UNSET
48 # @DESCRIPTION:
49 # If non-empty this variable forces elog messages to be printed.
50
51 # @FUNCTION: readme.gentoo_create_doc
52 # @DESCRIPTION:
53 # Create doc file with ${DOC_CONTENTS} variable (preferred) and, if not set,
54 # look for "${FILESDIR}/README.gentoo" contents. You can use
55 # ${FILESDIR}/README.gentoo-${SLOT} also.
56 # Usually called at src_install phase.
57 readme.gentoo_create_doc() {
58 debug-print-function ${FUNCNAME} "${@}"
59
60 if [[ -n "${DOC_CONTENTS}" ]]; then
61 eshopts_push
62 set -f
63 if [[ -n "${DISABLE_AUTOFORMATTING}" ]]; then
64 echo "${DOC_CONTENTS}" > "${T}"/README.gentoo
65 else
66 echo -e ${DOC_CONTENTS} | fold -s -w 70 \
67 | sed 's/[[:space:]]*$//' > "${T}"/README.gentoo
68 fi
69 eshopts_pop
70 elif [[ -f "${FILESDIR}/README.gentoo-${SLOT%/*}" ]]; then
71 cp "${FILESDIR}/README.gentoo-${SLOT%/*}" "${T}"/README.gentoo
72 elif [[ -f "${FILESDIR}/README.gentoo" ]]; then
73 cp "${FILESDIR}/README.gentoo" "${T}"/README.gentoo
74 else
75 die "You are not specifying README.gentoo contents!"
76 fi
77
78 dodoc "${T}"/README.gentoo
79 README_GENTOO_DOC_VALUE=$(< "${T}/README.gentoo")
80 }
81
82 # @FUNCTION: readme.gentoo_print_elog
83 # @DESCRIPTION:
84 # Print elog messages with "${T}"/README.gentoo contents. They will be
85 # shown only when package is installed at first time.
86 # Usually called at pkg_postinst phase.
87 #
88 # If you want to show them always, please set FORCE_PRINT_ELOG to a non empty
89 # value in your ebuild before this function is called.
90 # This can be useful when, for example, DOC_CONTENTS is modified, then, you can
91 # rely on specific REPLACING_VERSIONS handling in your ebuild to print messages
92 # when people update from versions still providing old message.
93 readme.gentoo_print_elog() {
94 debug-print-function ${FUNCNAME} "${@}"
95
96 if [[ -z "${README_GENTOO_DOC_VALUE}" ]]; then
97 die "readme.gentoo_print_elog invoked without matching readme.gentoo_create_doc call!"
98 elif ! [[ -n "${REPLACING_VERSIONS}" ]] || [[ -n "${FORCE_PRINT_ELOG}" ]]; then
99 echo -e "${README_GENTOO_DOC_VALUE}" | while read -r ELINE; do elog "${ELINE}"; done
100 elog ""
101 elog "(Note: Above message is only printed the first time package is"
102 elog "installed. Please look at /usr/share/doc/${PF}/README.gentoo*"
103 elog "for future reference)"
104 fi
105 }
106
107
108 # @FUNCTION: readme.gentoo_src_install
109 # @DESCRIPTION:
110 # Install generated doc file automatically.
111 readme.gentoo_src_install() {
112 debug-print-function ${FUNCNAME} "${@}"
113 default
114 readme.gentoo_create_doc
115 }
116
117 # @FUNCTION: readme.gentoo_pkg_postinst
118 # @DESCRIPTION:
119 # Show elog messages from from just generated doc file.
120 readme.gentoo_pkg_postinst() {
121 debug-print-function ${FUNCNAME} "${@}"
122 readme.gentoo_print_elog
123 }
124
125 fi

  ViewVC Help
Powered by ViewVC 1.1.20