summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Le Cuirot <chewi@gentoo.org>2016-10-15 21:41:49 +0100
committerJames Le Cuirot <chewi@gentoo.org>2016-10-17 16:15:22 +0100
commitb1698dfc057866498de619b23263fa769b482f66 (patch)
tree207243ac78c57134ec4639c78aebaf19ecfb4a1e /eclass/java-utils-2.eclass
parentjava-pkg-simple.eclass: Implemented auto classpath (diff)
downloadgentoo-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.eclass21
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
}