diff options
author | James Le Cuirot <chewi@gentoo.org> | 2016-10-15 21:41:49 +0100 |
---|---|---|
committer | James Le Cuirot <chewi@gentoo.org> | 2016-10-17 16:15:22 +0100 |
commit | b1698dfc057866498de619b23263fa769b482f66 (patch) | |
tree | 207243ac78c57134ec4639c78aebaf19ecfb4a1e /eclass/java-utils-2.eclass | |
parent | java-pkg-simple.eclass: Implemented auto classpath (diff) | |
download | gentoo-b1698dfc057866498de619b23263fa769b482f66.tar.gz gentoo-b1698dfc057866498de619b23263fa769b482f66.tar.bz2 gentoo-b1698dfc057866498de619b23263fa769b482f66.zip |
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.
Diffstat (limited to 'eclass/java-utils-2.eclass')
-rw-r--r-- | eclass/java-utils-2.eclass | 21 |
1 files 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 } |