From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id CA45A1581D3 for ; Sun, 2 Jun 2024 13:58:14 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D3E91E2B54; Sun, 2 Jun 2024 13:57:27 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 70DE5E2B51 for ; Sun, 2 Jun 2024 13:57:27 +0000 (UTC) From: Florian Schmaus To: gentoo-dev@lists.gentoo.org Cc: pacho@gentoo.org, Florian Schmaus Subject: [gentoo-dev] [PATCH 3/4] readme.gentoo-r1.eclass: add readme.gentoo_stdin() Date: Sun, 2 Jun 2024 15:57:08 +0200 Message-ID: <20240602135716.66992-4-flow@gentoo.org> X-Mailer: git-send-email 2.44.1 In-Reply-To: <20240602135716.66992-1-flow@gentoo.org> References: <20240109083914.242561-1-flow@gentoo.org> <20240602135716.66992-1-flow@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Archives-Salt: 96836df5-ceee-439c-9cf3-3a6f46bad0af X-Archives-Hash: 0213306042df48ee6b0deaea644dcb93 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 --- 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