summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetteri Räty <betelgeuse@gentoo.org>2006-12-27 18:46:01 +0000
committerPetteri Räty <betelgeuse@gentoo.org>2006-12-27 18:46:01 +0000
commit25f99bafe47a97f039f0e484764dc2e01060534c (patch)
treec80d7b188dbf3112be3c9ce0efade5feb849c606 /eclass/java-ant-2.eclass
parentVersion bump. The only improvement is xml-rewrite-2.py that uses expat intern... (diff)
downloadhistorical-25f99bafe47a97f039f0e484764dc2e01060534c.tar.gz
historical-25f99bafe47a97f039f0e484764dc2e01060534c.tar.bz2
historical-25f99bafe47a97f039f0e484764dc2e01060534c.zip
Reworked the eclass to work with xml-rewrite-2.py that is way faster.
Diffstat (limited to 'eclass/java-ant-2.eclass')
-rw-r--r--eclass/java-ant-2.eclass109
1 files changed, 81 insertions, 28 deletions
diff --git a/eclass/java-ant-2.eclass b/eclass/java-ant-2.eclass
index 44087abfc6ba..c2ee91c06b5f 100644
--- a/eclass/java-ant-2.eclass
+++ b/eclass/java-ant-2.eclass
@@ -2,10 +2,15 @@
#
# Copyright (c) 2004-2005, Thomas Matthijs <axxo@gentoo.org>
# Copyright (c) 2004-2005, Gentoo Foundation
+# Changes:
+# December 2006:
+# I pretty much rewrote the logic of the bsfix functions
+# and xml-rewrite.py because they were so slow
+# Petteri Räty (betelgeuse@gentoo.org)
#
# Licensed under the GNU General Public License, v2
#
-# $Header: /var/cvsroot/gentoo-x86/eclass/java-ant-2.eclass,v 1.9 2006/12/03 13:05:06 betelgeuse Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/java-ant-2.eclass,v 1.10 2006/12/27 18:46:01 betelgeuse Exp $
inherit java-utils-2
@@ -105,70 +110,118 @@ java-ant_bsfix() {
echo "QA Notice: Package is using java-ant, but doesn't depend on a Java VM"
fi
- cd "${S}"
+ pushd "${S}" >/dev/null
local find_args=""
[[ "${JAVA_PKG_BSFIX_ALL}" == "yes" ]] || find_args="-maxdepth 1"
find_args="${find_args} -type f -name ${JAVA_PKG_BSFIX_NAME// / -o -name } "
- local i=0
- local -a bsfix_these
+ # This voodoo is done for paths with spaces
+ local bsfix_these
while read line; do
[[ -z ${line} ]] && continue
- bsfix_these[${i}]="${line}"
- let i+=1
+ bsfix_these="${bsfix_these} '${line}'"
done <<-EOF
$(find . ${find_args})
EOF
- for (( i = 0 ; i < ${#bsfix_these[@]} ; i++ )); do
- local file="${bsfix_these[${i}]}"
- java-ant_bsfix_one "${file}"
- done
+ [[ "${bsfix_these// /}" ]] && eval java-ant_bsfix_files ${bsfix_these}
+
+ popd > /dev/null
}
# ------------------------------------------------------------------------------
-# @public java-ant_bsfix_one
+# @public java-ant_bsfix_files
#
-# Attempts to fix named build file. The following variables will affect its behavior
+# Attempts to fix named build files. The following variables will affect its behavior
# as listed above:
# JAVA_PKG_BSFIX_SOURCE_TAGS
# JAVA_PKG_BSFIX_TARGET_TAGS
+#
+# When changing this function, make sure that it works with paths with spaces in
+# them.
# ------------------------------------------------------------------------------
-java-ant_bsfix_one() {
+java-ant_bsfix_files() {
debug-print-function ${FUNCNAME} $*
- if [ -z "${1}" ]; then
- eerror "java-ant_bsfix_one needs one argument"
- die "java-ant_bsfix_one needs one argument"
- fi
+ [[ ${#} = 0 ]] && die "${FUNCNAME} called without arguments"
local want_source="$(java-pkg_get-source)"
local want_target="$(java-pkg_get-target)"
- debug-print "bsfix_one: target: ${want_target} source: ${want_source}"
+ debug-print "${FUNCNAME}: target: ${want_target} source: ${want_source}"
if [ -z "${want_source}" -o -z "${want_target}" ]; then
eerror "Could not find valid -source/-target values"
eerror "Please file a bug about this on bugs.gentoo.org"
die "Could not find valid -source/-target values"
else
- local file="${1}"
- echo "Rewriting ${file}"
- debug-print "bsfix: ${file}"
+ local files
+
+ [[ -x "/usr/bin/xml-rewrite-2.py" ]] && local using_new="true"
+
+ for file in "${@}"; do
+ debug-print "${FUNCNAME}: ${file}"
+
+ if [[ -n "${JAVA_PKG_DEBUG}" ]]; then
+ cp "${file}" "${file}.orig" || die "failed to copy ${file}"
+ fi
+
+ if [[ ! -w "${file}" ]]; then
+ chmod u+w "${file}" || die "chmod u+w ${file} failed"
+ fi
+
+ files="${files} -f '${file}'"
+
+ if [[ -z "${using_new}" ]]; then
+ vecho "Rewriting $file (using xml-rewrite.py)"
+ # Doing this twice because otherwise the source attributes would
+ # get added to target tags too and javadoc does not like target
+ xml-rewrite.py -f "${file}" -c -e ${JAVA_PKG_BSFIX_SOURCE_TAGS// / -e } -a source -v ${want_source} || die "xml-rewrite failed: ${file}"
+ xml-rewrite.py -f "${file}" -c -e ${JAVA_PKG_BSFIX_TARGET_TAGS// / -e } -a target -v ${want_target} || die "xml-rewrite failed: ${file}"
+ fi
+ done
+
+ if [[ "${using_new}" ]]; then
+ quiet_mode && local output=">/dev/null"
+ vecho "Rewriting source attributes"
+ eval xml-rewrite-2.py ${files} \
+ -c -e ${JAVA_PKG_BSFIX_SOURCE_TAGS// / -e } \
+ -a source -v ${want_source} ${output} || die "xml-rewrite2 failed: ${file}"
+
+ vecho "Rewriting target attributes"
+ eval xml-rewrite-2.py ${files} \
+ -c -e ${JAVA_PKG_BSFIX_TARGET_TAGS// / -e } \
+ -a target -v ${want_target} ${output} || die "xml-rewrite2 failed: ${file}"
+ fi
- cp "${file}" "${file}.orig" || die "failed to copy ${file}"
+ if [[ -n "${JAVA_PKG_DEBUG}" ]]; then
+ for file in "${@}"; do
+ diff -NurbB "${file}.orig" "${file}"
+ done
+ fi
+ fi
+}
- chmod u+w "${file}"
- xml-rewrite.py -f "${file}" -c -e ${JAVA_PKG_BSFIX_SOURCE_TAGS// / -e } -a source -v ${want_source} || die "xml-rewrite failed: ${file}"
- xml-rewrite.py -f "${file}" -c -e ${JAVA_PKG_BSFIX_TARGET_TAGS// / -e } -a target -v ${want_target} || die "xml-rewrite failed: ${file}"
+# ------------------------------------------------------------------------------
+# @public java-ant_bsfix_one
+#
+# Attempts to fix named build file. The following variables will affect its behavior
+# as listed above:
+# JAVA_PKG_BSFIX_SOURCE_TAGS
+# JAVA_PKG_BSFIX_TARGET_TAGS
+# ------------------------------------------------------------------------------
+java-ant_bsfix_one() {
+ debug-print-function ${FUNCNAME} $*
- if [[ -n "${JAVA_PKG_DEBUG}" ]]; then
- diff -NurbB "${file}.orig" "${file}"
- fi
+ if [ -z "${1}" ]; then
+ eerror "${FUNCNAME} needs one argument"
+ die "${FUNCNAME} needs one argument"
fi
+
+ java-ant_bsfix_files "${1}"
}
# ------------------------------------------------------------------------------