commit: b1698dfc057866498de619b23263fa769b482f66
Author: James Le Cuirot <chewi <AT> gentoo <DOT> org>
AuthorDate: Sat Oct 15 20:41:49 2016 +0000
Commit: James Le Cuirot <chewi <AT> gentoo <DOT> org>
CommitDate: Mon Oct 17 15:15:22 2016 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b1698dfc
java-utils-2.eclass: Rework wltjr's new java-pkg_gen-cp
* Use an accurate regexp rather than naive string manipulation.
* Join the entries with , for a single call to java-config.
* Don't export the given variable as we haven't previously.
* die if the atom is invalid, particularly if the SLOT is missing.
* Avoid adding duplicates because this may get called more than once.
eclass/java-utils-2.eclass | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/eclass/java-utils-2.eclass b/eclass/java-utils-2.eclass
index 61b338a..b723396 100644
--- a/eclass/java-utils-2.eclass
+++ b/eclass/java-utils-2.eclass
@@ -2900,14 +2900,15 @@ java-pkg_clean() {
java-pkg_gen-cp() {
debug-print-function ${FUNCNAME} "${@}"
- if [[ ${CP_DEPEND} ]]; then
- local cp="${!1}"
- local p
- for p in ${CP_DEPEND}; do
- p="${p/-[0-9]*:/-}"
- cp="${cp} ${p#*/}"
- done
- cp="${cp//:/-}"
- [[ ${cp} ]] && export ${1}="${cp//-0/}"
- fi
+ local atom
+ for atom in ${CP_DEPEND}; do
+ if [[ ${atom} =~
/(([[:alnum:]+_-]+)-[0-9]+(\.[0-9]+)*[a-z]?(_[[:alnum:]]+)?(-r[0-9]*)?|[[:alnum:]+_-]+):([[:alnum:]+_.-]+)
]]; then
+ atom=${BASH_REMATCH[2]:-${BASH_REMATCH[1]}}
+ [[ ${BASH_REMATCH[6]} != 0 ]] &&
atom+=-${BASH_REMATCH[6]}
+ local regex="(^|\s|,)${atom}($|\s|,)"
+ [[ ${!1} =~ ${regex} ]] || declare -g
${1}+=${!1:+,}${atom}
+ else
+ die "Invalid CP_DEPEND atom ${atom}, ensure a SLOT is
included"
+ fi
+ done
}