/[gentoo-x86]/eclass/java-ant-2.eclass
Gentoo

Diff of /eclass/java-ant-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.2 Revision 1.5
33# default: yes 33# default: yes
34# ------------------------------------------------------------------------------ 34# ------------------------------------------------------------------------------
35JAVA_ANT_BSFIX_ALL=${JAVA_PKG_BSFIX_ALL:="yes"} 35JAVA_ANT_BSFIX_ALL=${JAVA_PKG_BSFIX_ALL:="yes"}
36 36
37# ------------------------------------------------------------------------------ 37# ------------------------------------------------------------------------------
38# @global JAVA_ANT_BSFIX_NAME 38# @global JAVA_PKG_BSFIX_NAME
39# 39#
40# Filename of build files to fix/search for 40# Filename of build files to fix/search for
41# 41#
42# default: build.xml 42# default: build.xml
43# ------------------------------------------------------------------------------ 43# ------------------------------------------------------------------------------
44JAVA_ANT_BSFIX_NAME=${JAVA_PKG_BSFIX_NAME:="build.xml"} 44JAVA_PKG_BSFIX_NAME=${JAVA_PKG_BSFIX_NAME:="build.xml"}
45 45
46# ------------------------------------------------------------------------------ 46# ------------------------------------------------------------------------------
47# @global JAVA_ANT_BSFIX_TARGETS_TAGS 47# @global JAVA_ANT_BSFIX_TARGETS_TAGS
48# 48#
49# Targets to fix the 'source' attribute in 49# Targets to fix the 'source' attribute in
93# Attempts to fix build files. The following variables will affect its behavior 93# Attempts to fix build files. The following variables will affect its behavior
94# as listed above: 94# as listed above:
95# JAVA_PKG_BSFIX 95# JAVA_PKG_BSFIX
96# JAVA_PKG_BSFIX_ALL 96# JAVA_PKG_BSFIX_ALL
97# JAVA_PKG_BSFIX_NAME, 97# JAVA_PKG_BSFIX_NAME,
98# JAVA_PKG_BSFIX_SOURCE_TAGS
99# JAVA_PKG_BSFIX_TARGET_TAGS)
100# ------------------------------------------------------------------------------ 98# ------------------------------------------------------------------------------
101java-ant_bsfix() { 99java-ant_bsfix() {
102 debug-print-function ${FUNCNAME} $* 100 debug-print-function ${FUNCNAME} $*
103 101
104 [[ "${JAVA_PKG_BSFIX}" != "on" ]] && return 102 [[ "${JAVA_PKG_BSFIX}" != "on" ]] && return
105 if ! java-pkg_needs-vm; then 103 if ! java-pkg_needs-vm; then
106 echo "QA Notice: Package is using java-ant, but doesn't depend on a Java VM" 104 echo "QA Notice: Package is using java-ant, but doesn't depend on a Java VM"
107 fi 105 fi
108 106
109 cd "${S}" 107 cd "${S}"
110 108
111 local find_args="-type f" 109 local find_args="-type f"
112 if [[ "${JAVA_PKG_BSFIX_ALL}" == "yes" ]]; then 110 if [[ "${JAVA_PKG_BSFIX_ALL}" == "yes" ]]; then
113 find_args="${find_args} -name ${JAVA_PKG_BSFIX_NAME// / -o -name }" 111 find_args="${find_args} -name ${JAVA_PKG_BSFIX_NAME// / -o -name }"
114 else 112 else
115 find_args="${find_args} -maxdepth 1 -name ${JAVA_PKG_BSFIX_NAME// / -o -name } " 113 find_args="${find_args} -maxdepth 1 -name ${JAVA_PKG_BSFIX_NAME// / -o -name } "
120 while read line; do 118 while read line; do
121 [[ -z ${line} ]] && continue 119 [[ -z ${line} ]] && continue
122 bsfix_these[${i}]="${line}" 120 bsfix_these[${i}]="${line}"
123 let i+=1 121 let i+=1
124 done <<-EOF 122 done <<-EOF
125 $(find ${find_args}) 123 $(find . ${find_args})
126 EOF 124 EOF
125
126 for (( i = 0 ; i < ${#bsfix_these[@]} ; i++ )); do
127 local file="${bsfix_these[${i}]}"
128 java-ant_bsfix_one "${file}"
129 done
130}
131
132# ------------------------------------------------------------------------------
133# @public java-ant_bsfix_one
134#
135# Attempts to fix named build file. The following variables will affect its behavior
136# as listed above:
137# JAVA_PKG_BSFIX_SOURCE_TAGS
138# JAVA_PKG_BSFIX_TARGET_TAGS
139# ------------------------------------------------------------------------------
140java-ant_bsfix_one() {
141 debug-print-function ${FUNCNAME} $*
142
143 if [ -z "${1}" ]; then
144 eerror "java-ant_bsfix_one needs one argument"
145 die "java-ant_bsfix_one needs one argument"
146 fi
127 147
128 local want_source="$(java-pkg_get-source)" 148 local want_source="$(java-pkg_get-source)"
129 local want_target="$(java-pkg_get-target)" 149 local want_target="$(java-pkg_get-target)"
130 150
131 debug-print "bsfix: target: ${want_target} source: ${want_source}" 151 debug-print "bsfix_one: target: ${want_target} source: ${want_source}"
132 152
133 if [ -z "${want_source}" -o -z "${want_target}" ]; then 153 if [ -z "${want_source}" -o -z "${want_target}" ]; then
134 eerror "Could not find valid -source/-target values" 154 eerror "Could not find valid -source/-target values"
135 eerror "Please file a bug about this on bugs.gentoo.org" 155 eerror "Please file a bug about this on bugs.gentoo.org"
136 die "Could not find valid -source/-target values" 156 die "Could not find valid -source/-target values"
137 else 157 else
138 for (( i = 0 ; i < ${#bsfix_these[@]} ; i++ )); do 158 local file="${1}"
139 local file="${bsfix_these[${i}]}"
140 echo "Rewriting ${file}" 159 echo "Rewriting ${file}"
141 debug-print "bsfix: ${file}" 160 debug-print "bsfix: ${file}"
142 161
143 cp "${file}" "${file}.orig" || die "failed to copy ${file}" 162 cp "${file}" "${file}.orig" || die "failed to copy ${file}"
144 163
145 chmod u+w "${file}" 164 chmod u+w "${file}"
146 165
147 xml-rewrite.py -f "${file}" -c -e ${JAVA_PKG_BSFIX_SOURCE_TAGS// / -e } -a source -v ${want_source} || die "xml-rewrite failed: ${file}" 166 xml-rewrite.py -f "${file}" -c -e ${JAVA_PKG_BSFIX_SOURCE_TAGS// / -e } -a source -v ${want_source} || die "xml-rewrite failed: ${file}"
148 xml-rewrite.py -f "${file}" -c -e ${JAVA_PKG_BSFIX_TARGET_TAGS// / -e } -a target -v ${want_target} || die "xml-rewrite failed: ${file}" 167 xml-rewrite.py -f "${file}" -c -e ${JAVA_PKG_BSFIX_TARGET_TAGS// / -e } -a target -v ${want_target} || die "xml-rewrite failed: ${file}"
149 168
150 if [[ -n "${JAVA_PKG_DEBUG}" ]]; then 169 if [[ -n "${JAVA_PKG_DEBUG}" ]]; then
151 diff -NurbB "${file}.orig" "${file}" 170 diff -NurbB "${file}.orig" "${file}"
152 fi 171 fi
153 done
154 fi 172 fi
155} 173}

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.5

  ViewVC Help
Powered by ViewVC 1.1.20