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

Contents of /eclass/readme.gentoo.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations) (download)
Mon Feb 4 18:39:47 2013 UTC (18 months, 2 weeks ago) by pacho
Branch: MAIN
Changes since 1.2: +25 -23 lines
Add a variable to stop autoformatting when not desired, use '-e' option for echo in the autoformatting way to let people control it with sequences recognized by it (see man echo), fix it to work ok with prebuilt packages (#455030 by Brian Harring, Zac Medico and Fabio Erculiani)

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.2 2013/01/24 21:38:41 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} | fmt > "${T}"/README.gentoo
67 fi
68 eshopts_pop
69 elif [[ -f "${FILESDIR}/README.gentoo-${SLOT%/*}" ]]; then
70 cp "${FILESDIR}/README.gentoo-${SLOT%/*}" "${T}"/README.gentoo
71 elif [[ -f "${FILESDIR}/README.gentoo" ]]; then
72 cp "${FILESDIR}/README.gentoo" "${T}"/README.gentoo
73 else
74 die "You are not specifying README.gentoo contents!"
75 fi
76
77 dodoc "${T}"/README.gentoo
78 README_GENTOO_DOC_VALUE=$(< "${T}/README.gentoo")
79 }
80
81 # @FUNCTION: readme.gentoo_print_elog
82 # @DESCRIPTION:
83 # Print elog messages with "${T}"/README.gentoo contents. They will be
84 # shown only when package is installed at first time.
85 # Usually called at pkg_postinst phase.
86 #
87 # If you want to show them always, please set FORCE_PRINT_ELOG to a non empty
88 # value in your ebuild before this function is called.
89 # This can be useful when, for example, DOC_CONTENTS is modified, then, you can
90 # rely on specific REPLACING_VERSIONS handling in your ebuild to print messages
91 # when people update from versions still providing old message.
92 readme.gentoo_print_elog() {
93 debug-print-function ${FUNCNAME} "${@}"
94
95 if [[ -z "${README_GENTOO_DOC_VALUE}" ]]; then
96 die "readme.gentoo_print_elog invoked without matching readme.gentoo_create_doc call!"
97 elif ! [[ -n "${REPLACING_VERSIONS}" ]] || [[ -n "${FORCE_PRINT_ELOG}" ]]; then
98 echo -e "${README_GENTOO_DOC_VALUE}" | while read -r ELINE; do elog "${ELINE}"; done
99 fi
100 }
101
102
103 # @FUNCTION: readme.gentoo_src_install
104 # @DESCRIPTION:
105 # Install generated doc file automatically.
106 readme.gentoo_src_install() {
107 debug-print-function ${FUNCNAME} "${@}"
108 default
109 readme.gentoo_create_doc
110 }
111
112 # @FUNCTION: readme.gentoo_pkg_postinst
113 # @DESCRIPTION:
114 # Show elog messages from from just generated doc file.
115 readme.gentoo_pkg_postinst() {
116 debug-print-function ${FUNCNAME} "${@}"
117 readme.gentoo_print_elog
118 }
119
120 fi

  ViewVC Help
Powered by ViewVC 1.1.20