commit:     b9f4a96c9fdddac81aee77abc7513c6432cb65eb
Author:     Thibaud CANALE <thican <AT> thican <DOT> net>
AuthorDate: Sat Mar 22 19:51:56 2025 +0000
Commit:     Matthew Thode <prometheanfire <AT> gentoo <DOT> org>
CommitDate: Wed Apr 16 20:39:41 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b9f4a96c

app-crypt/certbot: rework ebuilds

Reworked as it had some quality issues:
- Create the list of modules and set it once;
- Do not use and/or edit internal functions and variables;
- Discard python_prepare_all as distutils-r1_python_prepare_all should
  be done once, which is the default;
- Also discard configure phase modifications as it’s a no-op;
- Use temporary directory for documentation;
- Fix test (changing current directory is required).

Bug: https://bugs.gentoo.org/951716
Signed-off-by: Thibaud CANALE <thican <AT> thican.net>
Closes: https://github.com/gentoo/gentoo/pull/41252
Signed-off-by: Matthew Thode <prometheanfire <AT> gentoo.org>

 ...t-3.3.0-r2.ebuild => certbot-3.2.0-r103.ebuild} | 163 +++++---------------
 ...t-3.2.0-r102.ebuild => certbot-3.3.0-r3.ebuild} | 167 +++++----------------
 ...bot-4.0.0-r1.ebuild => certbot-4.0.0-r2.ebuild} |  59 ++++++--
 app-crypt/certbot/certbot-9999.ebuild              |  59 ++++++--
 4 files changed, 170 insertions(+), 278 deletions(-)

diff --git a/app-crypt/certbot/certbot-3.3.0-r2.ebuild 
b/app-crypt/certbot/certbot-3.2.0-r103.ebuild
similarity index 61%
rename from app-crypt/certbot/certbot-3.3.0-r2.ebuild
rename to app-crypt/certbot/certbot-3.2.0-r103.ebuild
index 6f67453d14a7..50600140fd7a 100644
--- a/app-crypt/certbot/certbot-3.3.0-r2.ebuild
+++ b/app-crypt/certbot/certbot-3.2.0-r103.ebuild
@@ -154,154 +154,69 @@ distutils_enable_sphinx docs \
        dev-python/sphinx-rtd-theme
 distutils_enable_tests pytest
 
-src_prepare() {
-       local S_BACKUP="${S}"
-
-       local certbot_dirs=()
-       local base module dir
-       for base in "${CERTBOT_BASE[@]}"; do
-               certbot_dirs+=("${base}")
-       done
-       for module in "${CERTBOT_MODULES_EXTRA[@]}"; do
-               use "certbot-${module}" \
-                       && certbot_dirs+=("certbot-${module}")
-       done
+CERTBOT_DIRS=()
+# Stores temporary modules docs in each subdirectories,
+# will be used for HTML_DOCS
+CERTBOT_DOCS="${T}/docs"
 
-       for dir in "${certbot_dirs[@]}"; do
-               S="${WORKDIR}/${P}/${dir}"
-               pushd "${S}" > /dev/null || die
-               distutils-r1_src_prepare
-               popd > /dev/null || die
-       done
-
-       # Restore S
-       S="${S_BACKUP}"
-}
-
-src_configure() {
-       local S_BACKUP="${S}"
+src_prepare() {
+       default
 
-       local certbot_dirs=()
-       local base module dir
+       # set CERTBOT_DIRS
+       local base module
        for base in "${CERTBOT_BASE[@]}"; do
-               certbot_dirs+=("${base}")
+               CERTBOT_DIRS+=("${base}")
        done
        for module in "${CERTBOT_MODULES_EXTRA[@]}"; do
-               use "certbot-${module}" \
-                       && certbot_dirs+=("certbot-${module}")
+               use "certbot-${module}" &&
+                       CERTBOT_DIRS+=("certbot-${module}")
        done
 
-       for dir in "${certbot_dirs[@]}"; do
-               S="${WORKDIR}/${P}/${dir}"
-               pushd "${S}" > /dev/null || die
-               distutils-r1_src_configure
-               popd > /dev/null || die
-       done
-
-       # Restore S
-       S="${S_BACKUP}"
+       # Used to build documentation
+       mkdir "${CERTBOT_DOCS}" || die
 }
 
-src_compile() {
-       # Used for building documentation
-       # Stores temporary modules docs in each subdirectories, will be used 
for HTML_DOCS
-       local temp_docs="${T}/docs"
-       use doc && {
-               mkdir "${temp_docs}" || die
-       }
-
-       local S_BACKUP="${S}"
+python_compile() {
+       local dir
+       for dir in "${CERTBOT_DIRS[@]}"; do
+               pushd "${dir}" > /dev/null || die
 
-       local certbot_dirs=()
-       local base module dir
-       for base in "${CERTBOT_BASE[@]}"; do
-               certbot_dirs+=("${base}")
-       done
-       for module in "${CERTBOT_MODULES_EXTRA[@]}"; do
-               use "certbot-${module}" \
-                       && certbot_dirs+=("certbot-${module}")
-       done
+               distutils-r1_python_compile
 
-       for dir in "${certbot_dirs[@]}"; do
-               S="${WORKDIR}/${P}/${dir}"
-               pushd "${S}" > /dev/null || die
-               distutils-r1_src_compile
                popd > /dev/null || die
        done
-
-       # Restore S
-       S="${S_BACKUP}"
-
-       use doc && {
-               # Replace HTML_DOCS with one single entry to avoid merging
-               HTML_DOCS=( "${temp_docs}" )
-       }
 }
 
+# Used to build documentation
 python_compile_all() {
-       # There is no documentation in certbot-apache or certbot-nginx.
-       if [[ "${dir}" = "certbot-apache" ]] || [[ "${dir}" = "certbot-nginx" 
]]; then
-               return
-       fi
-
-       # Used to build documentation
-       use doc && {
-               sphinx_compile_all
+       use doc || return
 
-               # Subdirectory "_build/html" from build_sphinx in 
eclass/python-utils-r1.eclass
-               mv "${_DISTUTILS_SPHINX_SUBDIR}/_build/html" 
"${temp_docs}/${dir}" || die
-       }
-}
+       local dir
+       for dir in "${CERTBOT_DIRS[@]}"; do
+               # There is no documentation in certbot-apache or certbot-nginx.
+               if has "${dir}" "certbot-apache" "certbot-nginx"; then
+                       continue
+               fi
 
-python_test() {
-       local -x PYTEST_DISABLE_PLUGIN_AUTOLOAD=1
-       epytest
-}
+               pushd "${dir}" > /dev/null || die
 
-src_test() {
-       local S_BACKUP="${S}"
+               sphinx_compile_all
 
-       local certbot_dirs=()
-       local base module dir
-       for base in "${CERTBOT_BASE[@]}"; do
-               certbot_dirs+=("${base}")
-       done
-       for module in "${CERTBOT_MODULES_EXTRA[@]}"; do
-               use "certbot-${module}" \
-                       && certbot_dirs+=("certbot-${module}")
-       done
+               # Note: discard the `/.` in last entry suffix to avoid error
+               # with `mv` command.
+               mv "${HTML_DOCS[-1]%/.}" "${CERTBOT_DOCS}/${dir}" || die
 
-       for dir in "${certbot_dirs[@]}"; do
-               S="${WORKDIR}/${P}/${dir}"
-               pushd "${S}" > /dev/null || die
-               distutils-r1_src_test
                popd > /dev/null || die
        done
 
-       # Restore S
-       S="${S_BACKUP}"
+       # And finally give the result.
+       # Note: the suffix `/.` here is to discard the holding directory.
+       HTML_DOCS=( "${CERTBOT_DOCS}/." )
 }
 
-src_install() {
-       local S_BACKUP="${S}"
-
-       local certbot_dirs=()
-       local base module dir
-       for base in "${CERTBOT_BASE[@]}"; do
-               certbot_dirs+=("${base}")
-       done
-       for module in "${CERTBOT_MODULES_EXTRA[@]}"; do
-               use "certbot-${module}" \
-                       && certbot_dirs+=("certbot-${module}")
-       done
-
-       for dir in "${certbot_dirs[@]}"; do
-               S="${WORKDIR}/${P}/${dir}"
-               pushd "${S}" > /dev/null || die
-               distutils-r1_src_install
-               popd > /dev/null || die
-       done
-
-       # Restore S
-       S="${S_BACKUP}"
+python_test() {
+       local -x PYTEST_DISABLE_PLUGIN_AUTOLOAD=1
+       # Change for pytest rootdir is required.
+       cd "${BUILD_DIR}/install$(python_get_sitedir)" || die
+       epytest
 }

diff --git a/app-crypt/certbot/certbot-3.2.0-r102.ebuild 
b/app-crypt/certbot/certbot-3.3.0-r3.ebuild
similarity index 60%
rename from app-crypt/certbot/certbot-3.2.0-r102.ebuild
rename to app-crypt/certbot/certbot-3.3.0-r3.ebuild
index 4dbc10590d40..50600140fd7a 100644
--- a/app-crypt/certbot/certbot-3.2.0-r102.ebuild
+++ b/app-crypt/certbot/certbot-3.3.0-r3.ebuild
@@ -19,10 +19,6 @@ else
                https://github.com/certbot/certbot/archive/v${PV}.tar.gz
                        -> ${P}.gh.tar.gz
        "
-       #KEYWORDS="~amd64 ~arm ~arm64 ~ppc64 ~riscv ~x86"
-       # Only for amd64, arm64 and x86 because of dev-python/python-augeas
-       #KEYWORDS="~amd64 ~arm64 ~x86"
-       # Only for amd64 and x86 because of dev-python/dns-lexicon
        KEYWORDS="~amd64 ~arm ~arm64 ~ppc64 ~riscv ~x86"
 fi
 
@@ -158,154 +154,69 @@ distutils_enable_sphinx docs \
        dev-python/sphinx-rtd-theme
 distutils_enable_tests pytest
 
-src_prepare() {
-       local S_BACKUP="${S}"
-
-       local certbot_dirs=()
-       local base module dir
-       for base in "${CERTBOT_BASE[@]}"; do
-               certbot_dirs+=("${base}")
-       done
-       for module in "${CERTBOT_MODULES_EXTRA[@]}"; do
-               use "certbot-${module}" \
-                       && certbot_dirs+=("certbot-${module}")
-       done
+CERTBOT_DIRS=()
+# Stores temporary modules docs in each subdirectories,
+# will be used for HTML_DOCS
+CERTBOT_DOCS="${T}/docs"
 
-       for dir in "${certbot_dirs[@]}"; do
-               S="${WORKDIR}/${P}/${dir}"
-               pushd "${S}" > /dev/null || die
-               distutils-r1_src_prepare
-               popd > /dev/null || die
-       done
-
-       # Restore S
-       S="${S_BACKUP}"
-}
-
-src_configure() {
-       local S_BACKUP="${S}"
+src_prepare() {
+       default
 
-       local certbot_dirs=()
-       local base module dir
+       # set CERTBOT_DIRS
+       local base module
        for base in "${CERTBOT_BASE[@]}"; do
-               certbot_dirs+=("${base}")
+               CERTBOT_DIRS+=("${base}")
        done
        for module in "${CERTBOT_MODULES_EXTRA[@]}"; do
-               use "certbot-${module}" \
-                       && certbot_dirs+=("certbot-${module}")
+               use "certbot-${module}" &&
+                       CERTBOT_DIRS+=("certbot-${module}")
        done
 
-       for dir in "${certbot_dirs[@]}"; do
-               S="${WORKDIR}/${P}/${dir}"
-               pushd "${S}" > /dev/null || die
-               distutils-r1_src_configure
-               popd > /dev/null || die
-       done
-
-       # Restore S
-       S="${S_BACKUP}"
+       # Used to build documentation
+       mkdir "${CERTBOT_DOCS}" || die
 }
 
-src_compile() {
-       # Used for building documentation
-       # Stores temporary modules docs in each subdirectories, will be used 
for HTML_DOCS
-       local temp_docs="${T}/docs"
-       use doc && {
-               mkdir "${temp_docs}" || die
-       }
-
-       local S_BACKUP="${S}"
+python_compile() {
+       local dir
+       for dir in "${CERTBOT_DIRS[@]}"; do
+               pushd "${dir}" > /dev/null || die
 
-       local certbot_dirs=()
-       local base module dir
-       for base in "${CERTBOT_BASE[@]}"; do
-               certbot_dirs+=("${base}")
-       done
-       for module in "${CERTBOT_MODULES_EXTRA[@]}"; do
-               use "certbot-${module}" \
-                       && certbot_dirs+=("certbot-${module}")
-       done
+               distutils-r1_python_compile
 
-       for dir in "${certbot_dirs[@]}"; do
-               S="${WORKDIR}/${P}/${dir}"
-               pushd "${S}" > /dev/null || die
-               distutils-r1_src_compile
                popd > /dev/null || die
        done
-
-       # Restore S
-       S="${S_BACKUP}"
-
-       use doc && {
-               # Replace HTML_DOCS with one single entry to avoid merging
-               HTML_DOCS=( "${temp_docs}" )
-       }
 }
 
+# Used to build documentation
 python_compile_all() {
-       # There is no documentation in certbot-apache or certbot-nginx.
-       if [[ "${dir}" = "certbot-apache" ]] || [[ "${dir}" = "certbot-nginx" 
]]; then
-               return
-       fi
-
-       # Used to build documentation
-       use doc && {
-               sphinx_compile_all
+       use doc || return
 
-               # Subdirectory "_build/html" from build_sphinx in 
eclass/python-utils-r1.eclass
-               mv "${_DISTUTILS_SPHINX_SUBDIR}/_build/html" 
"${temp_docs}/${dir}" || die
-       }
-}
+       local dir
+       for dir in "${CERTBOT_DIRS[@]}"; do
+               # There is no documentation in certbot-apache or certbot-nginx.
+               if has "${dir}" "certbot-apache" "certbot-nginx"; then
+                       continue
+               fi
 
-python_test() {
-       local -x PYTEST_DISABLE_PLUGIN_AUTOLOAD=1
-       epytest
-}
+               pushd "${dir}" > /dev/null || die
 
-src_test() {
-       local S_BACKUP="${S}"
+               sphinx_compile_all
 
-       local certbot_dirs=()
-       local base module dir
-       for base in "${CERTBOT_BASE[@]}"; do
-               certbot_dirs+=("${base}")
-       done
-       for module in "${CERTBOT_MODULES_EXTRA[@]}"; do
-               use "certbot-${module}" \
-                       && certbot_dirs+=("certbot-${module}")
-       done
+               # Note: discard the `/.` in last entry suffix to avoid error
+               # with `mv` command.
+               mv "${HTML_DOCS[-1]%/.}" "${CERTBOT_DOCS}/${dir}" || die
 
-       for dir in "${certbot_dirs[@]}"; do
-               S="${WORKDIR}/${P}/${dir}"
-               pushd "${S}" > /dev/null || die
-               distutils-r1_src_test
                popd > /dev/null || die
        done
 
-       # Restore S
-       S="${S_BACKUP}"
+       # And finally give the result.
+       # Note: the suffix `/.` here is to discard the holding directory.
+       HTML_DOCS=( "${CERTBOT_DOCS}/." )
 }
 
-src_install() {
-       local S_BACKUP="${S}"
-
-       local certbot_dirs=()
-       local base module dir
-       for base in "${CERTBOT_BASE[@]}"; do
-               certbot_dirs+=("${base}")
-       done
-       for module in "${CERTBOT_MODULES_EXTRA[@]}"; do
-               use "certbot-${module}" \
-                       && certbot_dirs+=("certbot-${module}")
-       done
-
-       for dir in "${certbot_dirs[@]}"; do
-               S="${WORKDIR}/${P}/${dir}"
-               pushd "${S}" > /dev/null || die
-               distutils-r1_src_install
-               popd > /dev/null || die
-       done
-
-       # Restore S
-       S="${S_BACKUP}"
+python_test() {
+       local -x PYTEST_DISABLE_PLUGIN_AUTOLOAD=1
+       # Change for pytest rootdir is required.
+       cd "${BUILD_DIR}/install$(python_get_sitedir)" || die
+       epytest
 }

diff --git a/app-crypt/certbot/certbot-4.0.0-r1.ebuild 
b/app-crypt/certbot/certbot-4.0.0-r2.ebuild
similarity index 78%
rename from app-crypt/certbot/certbot-4.0.0-r1.ebuild
rename to app-crypt/certbot/certbot-4.0.0-r2.ebuild
index 83fd24c753d4..97c68bc1873f 100644
--- a/app-crypt/certbot/certbot-4.0.0-r1.ebuild
+++ b/app-crypt/certbot/certbot-4.0.0-r2.ebuild
@@ -146,40 +146,73 @@ RDEPEND="
 #      )
 # "
 
+# Note: "docs" is not an actual directory under "S", they are actually
+# under each modules, see python_compile_all redefinition, but keep
+# this instruction enabled for dependency configuration.
+distutils_enable_sphinx docs \
+       dev-python/sphinx-rtd-theme
 distutils_enable_tests pytest
 
-certbot_dirs=()
+CERTBOT_DIRS=()
+# Stores temporary modules docs in each subdirectories,
+# will be used for HTML_DOCS
+CERTBOT_DOCS="${T}/docs"
 
-my_certbot_dirs_listing() {
+src_prepare() {
+       default
+
+       # set CERTBOT_DIRS
        local base module
        for base in "${CERTBOT_BASE[@]}"; do
-               certbot_dirs+=("${base}")
+               CERTBOT_DIRS+=("${base}")
        done
        for module in "${CERTBOT_MODULES_EXTRA[@]}"; do
-               use "certbot-${module}" \
-                       && certbot_dirs+=("certbot-${module}")
+               use "certbot-${module}" &&
+                       CERTBOT_DIRS+=("certbot-${module}")
        done
-}
-
-src_prepare() {
-       default
 
-       my_certbot_dirs_listing
+       # Used to build documentation
+       mkdir "${CERTBOT_DOCS}" || die
 }
 
 python_compile() {
        local dir
-       for dir in "${certbot_dirs[@]}"; do
+       for dir in "${CERTBOT_DIRS[@]}"; do
                pushd "${dir}" > /dev/null || die
 
                distutils-r1_python_compile
-               # Delete previous build directory to avoid collision.
-               rm -rf "${BUILD_DIR}/build"
 
                popd > /dev/null || die
        done
 }
 
+# Used to build documentation
+python_compile_all() {
+       use doc || return
+
+       local dir
+       for dir in "${CERTBOT_DIRS[@]}"; do
+               # There is no documentation in certbot-apache or certbot-nginx.
+               if has "${dir}" "certbot-apache" "certbot-nginx"; then
+                       continue
+               fi
+
+               pushd "${dir}" > /dev/null || die
+
+               sphinx_compile_all
+
+               # Note: discard the `/.` in last entry suffix to avoid error
+               # with `mv` command.
+               mv "${HTML_DOCS[-1]%/.}" "${CERTBOT_DOCS}/${dir}" || die
+
+               popd > /dev/null || die
+       done
+
+       # And finally give the result.
+       # Note: the suffix `/.` here is to discard the holding directory.
+       HTML_DOCS=( "${CERTBOT_DOCS}/." )
+}
+
 python_test() {
        local -x PYTEST_DISABLE_PLUGIN_AUTOLOAD=1
        # Change for pytest rootdir is required.

diff --git a/app-crypt/certbot/certbot-9999.ebuild 
b/app-crypt/certbot/certbot-9999.ebuild
index 83fd24c753d4..97c68bc1873f 100644
--- a/app-crypt/certbot/certbot-9999.ebuild
+++ b/app-crypt/certbot/certbot-9999.ebuild
@@ -146,40 +146,73 @@ RDEPEND="
 #      )
 # "
 
+# Note: "docs" is not an actual directory under "S", they are actually
+# under each modules, see python_compile_all redefinition, but keep
+# this instruction enabled for dependency configuration.
+distutils_enable_sphinx docs \
+       dev-python/sphinx-rtd-theme
 distutils_enable_tests pytest
 
-certbot_dirs=()
+CERTBOT_DIRS=()
+# Stores temporary modules docs in each subdirectories,
+# will be used for HTML_DOCS
+CERTBOT_DOCS="${T}/docs"
 
-my_certbot_dirs_listing() {
+src_prepare() {
+       default
+
+       # set CERTBOT_DIRS
        local base module
        for base in "${CERTBOT_BASE[@]}"; do
-               certbot_dirs+=("${base}")
+               CERTBOT_DIRS+=("${base}")
        done
        for module in "${CERTBOT_MODULES_EXTRA[@]}"; do
-               use "certbot-${module}" \
-                       && certbot_dirs+=("certbot-${module}")
+               use "certbot-${module}" &&
+                       CERTBOT_DIRS+=("certbot-${module}")
        done
-}
-
-src_prepare() {
-       default
 
-       my_certbot_dirs_listing
+       # Used to build documentation
+       mkdir "${CERTBOT_DOCS}" || die
 }
 
 python_compile() {
        local dir
-       for dir in "${certbot_dirs[@]}"; do
+       for dir in "${CERTBOT_DIRS[@]}"; do
                pushd "${dir}" > /dev/null || die
 
                distutils-r1_python_compile
-               # Delete previous build directory to avoid collision.
-               rm -rf "${BUILD_DIR}/build"
 
                popd > /dev/null || die
        done
 }
 
+# Used to build documentation
+python_compile_all() {
+       use doc || return
+
+       local dir
+       for dir in "${CERTBOT_DIRS[@]}"; do
+               # There is no documentation in certbot-apache or certbot-nginx.
+               if has "${dir}" "certbot-apache" "certbot-nginx"; then
+                       continue
+               fi
+
+               pushd "${dir}" > /dev/null || die
+
+               sphinx_compile_all
+
+               # Note: discard the `/.` in last entry suffix to avoid error
+               # with `mv` command.
+               mv "${HTML_DOCS[-1]%/.}" "${CERTBOT_DOCS}/${dir}" || die
+
+               popd > /dev/null || die
+       done
+
+       # And finally give the result.
+       # Note: the suffix `/.` here is to discard the holding directory.
+       HTML_DOCS=( "${CERTBOT_DOCS}/." )
+}
+
 python_test() {
        local -x PYTEST_DISABLE_PLUGIN_AUTOLOAD=1
        # Change for pytest rootdir is required.

Reply via email to