From b1698dfc057866498de619b23263fa769b482f66 Mon Sep 17 00:00:00 2001 From: James Le Cuirot Date: Sat, 15 Oct 2016 21:41:49 +0100 Subject: [PATCH] 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 61b338a30f64..b723396c313a 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 } -- 2.26.2