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

Contents of /eclass/readme.gentoo.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download)
Thu Jan 24 21:38:41 2013 UTC (21 months, 3 weeks ago) by pacho
Branch: MAIN
Changes since 1.1: +15 -3 lines
Include FORCE_PRINT_ELOG variable to for printing of messages when desired. Thanks to Tomáš Chvátal for his suggestions.

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.1 2013/01/20 11:42:30 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: FORCE_PRINT_ELOG
40 # @DEFAULT_UNSET
41 # @DESCRIPTION:
42 # If non-empty this variable forces elog messages to be printed.
43
44 # @FUNCTION: readme.gentoo_create_doc
45 # @DESCRIPTION:
46 # Create doc file with ${DOC_CONTENTS} variable (preferred) and, if not set,
47 # look for "${FILESDIR}/README.gentoo" contents. You can use
48 # ${FILESDIR}/README.gentoo-${SLOT} also.
49 # Usually called at src_install phase.
50 readme.gentoo_create_doc() {
51 debug-print-function ${FUNCNAME} "${@}"
52
53 if [[ -n "${DOC_CONTENTS}" ]]; then
54 eshopts_push
55 set -f
56 echo ${DOC_CONTENTS} | fmt > "${T}"/README.gentoo
57 eshopts_pop
58 dodoc "${T}"/README.gentoo
59 else
60 if [[ -f "${FILESDIR}/README.gentoo-${SLOT%/*}" ]]; then
61 cp "${FILESDIR}/README.gentoo-${SLOT%/*}" "${T}"/README.gentoo
62 dodoc "${T}"/README.gentoo
63 else
64 if [[ -f "${FILESDIR}/README.gentoo" ]]; then
65 cp "${FILESDIR}/README.gentoo" "${T}"/README.gentoo
66 dodoc "${T}"/README.gentoo
67 else
68 die "You are not specifying README.gentoo contents!"
69 fi
70 fi
71 fi
72 }
73
74 # @FUNCTION: readme.gentoo_print_elog
75 # @DESCRIPTION:
76 # Print elog messages with "${T}"/README.gentoo contents. They will be
77 # shown only when package is installed at first time.
78 # Usually called at pkg_postinst phase.
79 #
80 # If you want to show them always, please set FORCE_PRINT_ELOG to a non empty
81 # value in your ebuild before this function is called.
82 # This can be useful when, for example, DOC_CONTENTS is modified, then, you can
83 # rely on specific REPLACING_VERSIONS handling in your ebuild to print messages
84 # when people update from versions still providing old message.
85 readme.gentoo_print_elog() {
86 debug-print-function ${FUNCNAME} "${@}"
87
88 if [[ -f "${T}"/README.gentoo ]]; then
89 if ! [[ -n "${REPLACING_VERSIONS}" ]] || [[ -n "${FORCE_PRINT_ELOG}" ]]; then
90 eshopts_push
91 set -f
92 cat "${T}"/README.gentoo | while read -r ELINE; do elog "${ELINE}"; done
93 eshopts_pop
94 fi
95 else
96 die "README.gentoo wasn't created at src_install!"
97 fi
98 }
99
100
101 # @FUNCTION: readme.gentoo_src_install
102 # @DESCRIPTION:
103 # Install generated doc file automatically.
104 readme.gentoo_src_install() {
105 debug-print-function ${FUNCNAME} "${@}"
106 default
107 readme.gentoo_create_doc
108 }
109
110 # @FUNCTION: readme.gentoo_pkg_postinst
111 # @DESCRIPTION:
112 # Show elog messages from from just generated doc file.
113 readme.gentoo_pkg_postinst() {
114 debug-print-function ${FUNCNAME} "${@}"
115 readme.gentoo_print_elog
116 }
117
118 fi

  ViewVC Help
Powered by ViewVC 1.1.20