Gentoo Archives: gentoo-commits

From: Pacho Ramos <pacho@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/
Date: Sun, 13 Dec 2015 22:24:55
Message-Id: 1450045479.b7a859392b35066cb39b04de1c35ca55ad5ff2ff.pacho@gentoo
1 commit: b7a859392b35066cb39b04de1c35ca55ad5ff2ff
2 Author: Pacho Ramos <pacho <AT> gentoo <DOT> org>
3 AuthorDate: Sun Dec 13 22:22:37 2015 +0000
4 Commit: Pacho Ramos <pacho <AT> gentoo <DOT> org>
5 CommitDate: Sun Dec 13 22:24:39 2015 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b7a85939
7
8 eclass/readme.gentoo-r1.eclass: introduce this revision for adding eapi6 support and explain the people the changes regarding it stopping to export phase functions (#520094#c6)
9
10 eclass/readme.gentoo-r1.eclass | 110 +++++++++++++++++++++++++++++++++++++++++
11 1 file changed, 110 insertions(+)
12
13 diff --git a/eclass/readme.gentoo-r1.eclass b/eclass/readme.gentoo-r1.eclass
14 new file mode 100644
15 index 0000000..d98a445
16 --- /dev/null
17 +++ b/eclass/readme.gentoo-r1.eclass
18 @@ -0,0 +1,110 @@
19 +# Copyright 1999-2015 Gentoo Foundation
20 +# Distributed under the terms of the GNU General Public License v2
21 +# $Id$
22 +
23 +# @ECLASS: readme.gentoo.eclass
24 +# @MAINTAINER:
25 +# Pacho Ramos <pacho@g.o>
26 +# @AUTHOR:
27 +# Author: Pacho Ramos <pacho@g.o>
28 +# @BLURB: An eclass for installing a README.gentoo doc file recording tips
29 +# shown via elog messages.
30 +# @DESCRIPTION:
31 +# An eclass for installing a README.gentoo doc file recording tips
32 +# shown via elog messages. With this eclass, those elog messages will only be
33 +# shown at first package installation and a file for later reviewing will be
34 +# installed under /usr/share/doc/${PF}
35 +#
36 +# You need to call readme.gentoo_create_doc in src_install phase and
37 +# readme.gentoo_print_elog in pkg_postinst
38 +
39 +if [[ -z ${_README_GENTOO_ECLASS} ]]; then
40 +_README_GENTOO_ECLASS=1
41 +
42 +inherit eutils
43 +
44 +case "${EAPI:-0}" in
45 + 0|1|2|3|4|5)
46 + die "Unsupported EAPI=${EAPI:-0} (too old) for ${ECLASS}"
47 + ;;
48 + 6)
49 + ;;
50 + *)
51 + die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}"
52 + ;;
53 +esac
54 +
55 +# @ECLASS-VARIABLE: DISABLE_AUTOFORMATTING
56 +# @DEFAULT_UNSET
57 +# @DESCRIPTION:
58 +# If non-empty, DOC_CONTENTS information will be strictly respected,
59 +# not getting it automatically formatted by fmt. If empty, it will
60 +# rely on fmt for formatting and 'echo -e' options to tweak lines a bit.
61 +
62 +# @ECLASS-VARIABLE: FORCE_PRINT_ELOG
63 +# @DEFAULT_UNSET
64 +# @DESCRIPTION:
65 +# If non-empty this variable forces elog messages to be printed.
66 +
67 +# @ECLASS-VARIABLE: README_GENTOO_SUFFIX
68 +# @DESCRIPTION:
69 +# If you want to specify a suffix for README.gentoo file please export it.
70 +: ${README_GENTOO_SUFFIX:=""}
71 +
72 +# @FUNCTION: readme.gentoo_create_doc
73 +# @DESCRIPTION:
74 +# Create doc file with ${DOC_CONTENTS} variable (preferred) and, if not set,
75 +# look for "${FILESDIR}/README.gentoo" contents. You can use
76 +# ${FILESDIR}/README.gentoo-${SLOT} also.
77 +# Usually called at src_install phase.
78 +readme.gentoo_create_doc() {
79 + debug-print-function ${FUNCNAME} "${@}"
80 +
81 + if [[ -n "${DOC_CONTENTS}" ]]; then
82 + eshopts_push
83 + set -f
84 + if [[ -n "${DISABLE_AUTOFORMATTING}" ]]; then
85 + echo "${DOC_CONTENTS}" > "${T}"/README.gentoo
86 + else
87 + echo -e ${DOC_CONTENTS} | fold -s -w 70 \
88 + | sed 's/[[:space:]]*$//' > "${T}"/README.gentoo
89 + fi
90 + eshopts_pop
91 + elif [[ -f "${FILESDIR}/README.gentoo-${SLOT%/*}" ]]; then
92 + cp "${FILESDIR}/README.gentoo-${SLOT%/*}" "${T}"/README.gentoo || die
93 + elif [[ -f "${FILESDIR}/README.gentoo${README_GENTOO_SUFFIX}" ]]; then
94 + cp "${FILESDIR}/README.gentoo${README_GENTOO_SUFFIX}" "${T}"/README.gentoo || die
95 + else
96 + die "You are not specifying README.gentoo contents!"
97 + fi
98 +
99 + dodoc "${T}"/README.gentoo
100 + README_GENTOO_DOC_VALUE=$(< "${T}/README.gentoo")
101 +}
102 +
103 +# @FUNCTION: readme.gentoo_print_elog
104 +# @DESCRIPTION:
105 +# Print elog messages with "${T}"/README.gentoo contents. They will be
106 +# shown only when package is installed at first time.
107 +# Usually called at pkg_postinst phase.
108 +#
109 +# If you want to show them always, please set FORCE_PRINT_ELOG to a non empty
110 +# value in your ebuild before this function is called.
111 +# This can be useful when, for example, DOC_CONTENTS is modified, then, you can
112 +# rely on specific REPLACING_VERSIONS handling in your ebuild to print messages
113 +# when people update from versions still providing old message.
114 +readme.gentoo_print_elog() {
115 + debug-print-function ${FUNCNAME} "${@}"
116 +
117 + if [[ -z "${README_GENTOO_DOC_VALUE}" ]]; then
118 + die "readme.gentoo_print_elog invoked without matching readme.gentoo_create_doc call!"
119 + elif ! [[ -n "${REPLACING_VERSIONS}" ]] || [[ -n "${FORCE_PRINT_ELOG}" ]]; then
120 + echo -e "${README_GENTOO_DOC_VALUE}" | while read -r ELINE; do elog "${ELINE}"; done
121 + elog ""
122 + elog "(Note: Above message is only printed the first time package is"
123 + elog "installed. Please look at ${EPREFIX}/usr/share/doc/${PF}/README.gentoo*"
124 + elog "for future reference)"
125 + fi
126 +}
127 +
128 +fi