commit:     c4f94037c93aba068d04b843784e59067a589f33
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Fri Jun  2 18:35:35 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri Jun  2 18:39:06 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c4f94037

sys-libs/ncurses-compat: optimise SRC_URI generation

Thanks to radhermit's new pkgcraft tooling.

Before:
```
sys-libs/ncurses-compat-6.4_p20230401::gentoo: 46.290096ms
```

After:
```
sys-libs/ncurses-compat-6.4_p20230401::gentoo: 9.308438ms
```

Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../ncurses-compat-6.4_p20230401.ebuild            | 52 ++++++++++------------
 1 file changed, 24 insertions(+), 28 deletions(-)

diff --git a/sys-libs/ncurses-compat/ncurses-compat-6.4_p20230401.ebuild 
b/sys-libs/ncurses-compat/ncurses-compat-6.4_p20230401.ebuild
index 9732adbcdda4..b4d792b322ad 100644
--- a/sys-libs/ncurses-compat/ncurses-compat-6.4_p20230401.ebuild
+++ b/sys-libs/ncurses-compat/ncurses-compat-6.4_p20230401.ebuild
@@ -62,36 +62,32 @@ if [[ ${PV} == *_p* ]] ; then
        )
 
        if [[ -z ${PATCH_DATES[@]} ]] ; then
-               SRC_URI+=" 
https://invisible-island.net/archives/${PN}/${PV/_p*}/${P/_p/-}.patch.sh.gz";
-               SRC_URI+=" verify-sig? ( 
https://invisible-island.net/archives/${PN}/${PV/_p*}/${P/_p/-}.patch.sh.gz.asc";
+               SRC_URI+=" 
https://invisible-island.net/archives/${PN}/${PV/_p*}/${MY_P/_p/-}.patch.sh.gz";
+               SRC_URI+=" verify-sig? ( 
https://invisible-island.net/archives/${PN}/${PV/_p*}/${MY_P/_p/-}.patch.sh.gz.asc";
 
                # If we have a rollup patch, use that instead of the individual 
ones.
-               UPSTREAM_PATCHES+=( "${WORKDIR}"/${P/_p/-}-patch.sh )
+               UPSTREAM_PATCHES+=( patch.sh )
        else
-               patch_url=
-               my_patch_index=
-
-               # We keep a bunch of mirrors here as we've had reports of 
invisible*.net
-               # being 403 forbidden for some users.
-               urls=(
-                       
"https://invisible-island.net/archives/${PN}/${PV/_p*}/${MY_P}-%s";
-                       
"https://invisible-mirror.net/archives/${PN}/${PV/_p*}/${MY_P}-%s";
-                       
"https://dev.gentoo.org/~${GENTOO_PATCH_DEV}/distfiles/${CATEGORY}/${PN}/${MY_P}-%s";
-               )
-
-               for ((my_patch_index=0; my_patch_index < "${#PATCH_DATES[@]}"; 
my_patch_index++)); do
-                       for url in "${urls[@]}" ; do
-                               patch_url="$(printf ${urls} 
${PATCH_DATES[${my_patch_index}]}.patch.gz)"
-                               SRC_URI+=" ${patch_url}"
-                               SRC_URI+=" verify-sig? ( ${patch_url}.asc )"
-                       done
-
-                       UPSTREAM_PATCHES+=( 
"${WORKDIR}"/${MY_P}-${PATCH_DATES[${my_patch_index}]}.patch )
-               done
-
-               unset patch_url
-               unset my_patch_index
-               unset urls
+               # We use a mirror as well because we've had reports of 403 
forbidden for some users.
+               
upstream_url_base="https://invisible-island.net/archives/${PN}/${PV/_p*}/${MY_P}-";
+               
upstream_m_url_base="https://invisible-mirror.net/archives/${PN}/${PV/_p*}/${MY_P}-";
+
+               # Prefix each date with the upstream location 
(https://invisible-island.net/archives/${PN}/${PV/_p*}/${MY_P})
+               mangled_patches=( "${PATCH_DATES[@]/#/${upstream_url_base}}" )
+               # Suffix each with .patch.gz
+               mangled_patches=( "${mangled_patches[@]/%/.patch.gz}" )
+               mangled_patches_sig=( "${mangled_patches[@]/%/.asc}" )
+               # Repeat for .patch.gz.asc for verify-sig
+               SRC_URI+=" ${mangled_patches[@]}"
+               SRC_URI+=" verify-sig? ( ${mangled_patches_sig[@]} )"
+
+               # For all of the URLs, chuck in invisible-island.net too:
+               SRC_URI+=" 
${mangled_patches[@]/${upstream_url_base}/${upstream_m_url_base}}"
+               SRC_URI+=" verify-sig? ( 
${mangled_patches_sig[@]/${upstream_url_base}/${upstream_m_url_base}} )"
+
+               UPSTREAM_PATCHES=( "${PATCH_DATES[@]/%/.patch}" )
+
+               unset upstream_url_base upstream_m_url_base mangled_patches 
mangled_patches_sig
        fi
 fi
 
@@ -115,7 +111,7 @@ BDEPEND="verify-sig? ( sec-keys/openpgp-keys-thomasdickey )"
 S="${WORKDIR}/${MY_P}"
 
 PATCHES=(
-       "${UPSTREAM_PATCHES[@]}"
+       "${UPSTREAM_PATCHES[@]/#/${WORKDIR}/${MY_P}-}"
 
        # When rebasing Gentoo's patchset, please use git from a clean
        # src_prepare with upstream patches already applied. git am --reject

Reply via email to