From: Florian Schmaus <flow@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Cc: pacho@gentoo.org, Florian Schmaus <flow@gentoo.org>
Subject: [gentoo-dev] [PATCH 3/4] readme.gentoo-r1.eclass: add readme.gentoo_stdin()
Date: Sun, 2 Jun 2024 15:57:08 +0200 [thread overview]
Message-ID: <20240602135716.66992-4-flow@gentoo.org> (raw)
In-Reply-To: <20240602135716.66992-1-flow@gentoo.org>
Add a new function readme.gentoo_stdin() that consumes the content of
README.gentoo from stdin. In many cases, this is a supperiour method to
construct readme, compared to the eclass' DOC_CONTENTS approach.
Signed-off-by: Florian Schmaus <flow@gentoo.org>
---
eclass/readme.gentoo-r1.eclass | 51 ++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
diff --git a/eclass/readme.gentoo-r1.eclass b/eclass/readme.gentoo-r1.eclass
index 078077241944..db7fa0c47077 100644
--- a/eclass/readme.gentoo-r1.eclass
+++ b/eclass/readme.gentoo-r1.eclass
@@ -14,6 +14,22 @@
# shown at first package installation and a file for later reviewing will be
# installed under /usr/share/doc/${PF}
#
+# @CODE
+# inherit readme.gentoo-r1
+#
+# src_install() {
+# …
+# readme.gentoo_stdin <<-EOF
+# This is the content of the created readme doc file.
+# EOF
+# …
+# if use foo; then
+# readme.gentoo_stdin --apend <<-EOF
+# This is conditional readme content, based on USE=foo.
+# EOF
+# fi
+# }
+# @CODE
#
# You need to call readme.gentoo_create_doc in src_install phase if you
# use DOC_CONTENTS or obtain the readme from FILESIDR.
@@ -59,6 +75,41 @@ _GREADME_DOC_DIR="usr/share/doc/${PF}"
_GREADME_REL_PATH="${_GREADME_DOC_DIR}/${_GREADME_FILENAME}"
_GREADME_HASH_REL_PATH="${_GREADME_DOC_DIR}/${_GREADME_HASH_FILENAME}"
+# @FUNCTION: readme.gentoo_stdin
+# @USAGE: [--append]
+# @DESCRIPTION:
+# Create the readme doc via stdin. You can use --append to append to an
+# existing readme doc.
+readme.gentoo_stdin() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ local append=false
+ while [[ -n ${1} ]] && [[ ${1} =~ --* ]]; do
+ case ${1} in
+ --append)
+ append=true
+ shift
+ ;;
+ esac
+ done
+
+ if $append; then
+ if [[ ! -f "${_GREADME_TMP_FILE}" ]]; then
+ die "Gentoo README does not exist when trying to append to it"
+ fi
+
+ cat >> "${_GREADME_TMP_FILE}" || die
+ else
+ if [[ -f "${_GREADME_TMP_FILE}" ]]; then
+ die "Gentoo README already exists while trying to create it"
+ fi
+
+ cat > "${_GREADME_TMP_FILE}" || die
+ fi
+
+ readme.gentoo_create_doc
+}
+
# @FUNCTION: readme.gentoo_create_doc
# @DESCRIPTION:
# Create doc file with ${DOC_CONTENTS} variable (preferred) and, if not set,
--
2.44.1
next prev parent reply other threads:[~2024-06-02 13:58 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-06 17:01 [gentoo-dev] [PATCH 0/1] [RFC] greadme.eclass Florian Schmaus
2024-01-06 17:01 ` [gentoo-dev] [PATCH 1/1] greadme.eclass: new eclass Florian Schmaus
2024-01-06 17:21 ` [gentoo-dev] [PATCH 0/1] [RFC] greadme.eclass Michał Górny
2024-01-09 8:30 ` Florian Schmaus
2024-01-09 8:39 ` [gentoo-dev] [PATCH v2 1/3] greadme.eclass: new eclass Florian Schmaus
2024-01-09 8:39 ` [gentoo-dev] [PATCH v2 2/3] add UNPACKER_NO_BANNER variable Florian Schmaus
2024-01-09 8:45 ` [gentoo-dev] " Florian Schmaus
2024-01-09 8:39 ` [gentoo-dev] [PATCH v2 3/3] greadme.eclass: set UNPACKER_NO_BANNER Florian Schmaus
2024-01-09 11:23 ` [gentoo-dev] [PATCH v2 1/3] greadme.eclass: new eclass David Seifert
2024-01-09 11:30 ` Florian Schmaus
2024-06-02 13:57 ` [gentoo-dev] [PATCH 0/4] Improve readme.gentoo-r1.eclass Florian Schmaus
2024-06-02 13:57 ` [gentoo-dev] [PATCH 1/4] readme.gentoo-r1.eclass: display readme if content changed (or fresh install) Florian Schmaus
2024-06-02 15:34 ` Ulrich Mueller
2024-06-02 15:48 ` Eli Schwartz
2024-06-02 16:28 ` Ulrich Mueller
2024-06-02 17:48 ` Florian Schmaus
2024-06-02 17:51 ` Eli Schwartz
2024-06-02 18:24 ` Ulrich Mueller
2024-06-04 15:15 ` Florian Schmaus
2024-06-04 17:45 ` Ulrich Mueller
2024-06-04 18:28 ` Florian Schmaus
2024-06-04 18:33 ` Eli Schwartz
2024-06-04 18:40 ` Ulrich Mueller
2024-06-04 18:37 ` Ionen Wolkens
2024-06-04 18:59 ` Ionen Wolkens
2024-06-02 16:16 ` Florian Schmaus
2024-06-02 13:57 ` [gentoo-dev] [PATCH 2/4] readme.gentoo-r1.eclass: use _GREADME_TMP_FILE in existing code Florian Schmaus
2024-06-02 13:57 ` Florian Schmaus [this message]
2024-06-02 13:57 ` [gentoo-dev] [PATCH 4/4] readme.gentoo-r1.eclass: add readme.gentoo_file() Florian Schmaus
2024-06-02 15:25 ` [gentoo-dev] [PATCH 0/4] Improve readme.gentoo-r1.eclass Ulrich Mueller
2024-06-02 16:12 ` Florian Schmaus
2024-06-02 16:40 ` Ulrich Mueller
2024-06-02 17:34 ` Florian Schmaus
2024-01-09 9:59 ` [gentoo-dev] [PATCH 0/1] [RFC] greadme.eclass Michał Górny
2024-01-09 10:39 ` Florian Schmaus
2024-01-09 10:43 ` Michał Górny
2024-01-09 10:47 ` Florian Schmaus
2024-01-10 11:04 ` Sam James
2024-01-10 13:23 ` Florian Schmaus
2024-01-10 13:58 ` Ulrich Mueller
2024-01-10 14:30 ` Florian Schmaus
2024-01-10 15:10 ` Ulrich Mueller
2024-01-10 15:54 ` Florian Schmaus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240602135716.66992-4-flow@gentoo.org \
--to=flow@gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
--cc=pacho@gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox