Gentoo Archives: gentoo-commits

From: "Vlastimil Babka (caster)" <caster@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in app-admin/eselect-ecj/files: ecj-0.6.eselect
Date: Sun, 31 Oct 2010 17:17:48
Message-Id: 20101031171743.6034D20054@flycatcher.gentoo.org
1 caster 10/10/31 17:17:43
2
3 Added: ecj-0.6.eselect
4 Log:
5 Version bump, promoting the 0.5-r1 version from java-overlay to 0.6. Changes by Andrew John Hughes <andrew@g.o>, adding support for ecj-gcj and manage a /usr/share/eclipse-ecj/ecj.jar symlink along with the launcher.
6
7 (Portage version: 2.2.0_alpha2/cvs/Linux x86_64)
8
9 Revision Changes Path
10 1.1 app-admin/eselect-ecj/files/ecj-0.6.eselect
11
12 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-admin/eselect-ecj/files/ecj-0.6.eselect?rev=1.1&view=markup
13 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-admin/eselect-ecj/files/ecj-0.6.eselect?rev=1.1&content-type=text/plain
14
15 Index: ecj-0.6.eselect
16 ===================================================================
17 # -*-eselect-*- vim: ft=eselect
18 # Copyright 1999-2010 Gentoo Foundation
19 # Distributed under the terms of the GNU General Public License v2
20 # $Id: ecj-0.6.eselect,v 1.1 2010/10/31 17:17:43 caster Exp $
21
22 DESCRIPTION="Manage ECJ targets"
23 MAINTAINER="java@g.o"
24 VERSION="0.6"
25
26 ECJ="${EROOT}/usr/bin/ecj"
27 ECJ_JAR="${EROOT}/usr/share/eclipse-ecj/ecj.jar"
28
29 # find a list of ecj symlink targets, best first.
30 find_targets() {
31 for f in $(ls -r "${ECJ}"-[0-9]* "${ECJ}"-gcj-[0-9]* 2> /dev/null) ; do
32 if [[ -f "${f}" ]] ; then
33 echo $(basename "${f}")
34 fi
35 done
36 }
37
38 # get a named or numbered target.
39 find_target() {
40 local target=${1}
41
42 if is_number "${target}" && [[ ${target} -ge 1 ]] ; then
43 targets=( $(find_targets ) )
44 [[ -z "${targets}" ]] && die -q "No targets found!"
45 target=${targets[target-1]}
46 fi
47
48 if [[ "${target}" = ecj-[0-9]* || "${target}" = ecj-gcj-[0-9]* ]] \
49 && [[ -f "${EROOT}/usr/bin/${target}" ]] ; then
50 echo ${target}
51 else
52 die -q "Target \"${1}\" doesn't appear to be valid!"
53 fi
54 }
55
56 # try to remove the ecj symlink.
57 remove_symlink() {
58 rm "${ECJ}" &>/dev/null
59 if [[ -e ${ECJ_JAR} ]] ; then
60 rm "${ECJ_JAR}"
61 fi
62 }
63
64 # determine the current target.
65 get_target() {
66 local canonicalised=$(canonicalise "${ECJ}")
67 echo $(basename "${canonicalised}")
68 }
69
70 # set the ecj symlink.
71 set_symlink() {
72 local target=$(find_target "${1}")
73 remove_symlink
74 ln -s "${target}" "${ECJ}" || die "Couldn't set ${target} symlink."
75 mkdir -p $(dirname ${ECJ_JAR})
76 if [[ "${target}" = ecj-gcj* ]] ; then
77 ln -sf /usr/share/${target}/lib/ecj.jar ${ECJ_JAR}
78 else
79 ln -sf /usr/share/eclipse-${target}/lib/ecj.jar ${ECJ_JAR}
80 fi
81 }
82
83 ### show action ###
84
85 describe_show() {
86 echo "Show current ECJ target"
87 }
88
89 do_show() {
90 if [[ ${#} -gt 0 ]]; then
91 die -q "No parameters allowed."
92 fi
93
94 if [[ -L "${ECJ}" ]] ; then
95 get_target
96 return 0
97 elif [[ -e "${ECJ}" ]] ; then
98 echo "(not a symlink)" >&2
99 return 1
100 else
101 echo "(unset)" >&2
102 return 1
103 fi
104 }
105
106 ### list action ###
107
108 describe_list() {
109 echo "List available ECJ targets"
110 }
111
112 do_list() {
113 if [[ ${#} -gt 0 ]]; then
114 die -q "Usage error: no parameters allowed."
115 fi
116
117 local i targets
118 targets=( $(find_targets) )
119
120 for (( i = 0; i < ${#targets[@]}; i++ )); do
121 [[ ${targets[i]} = $(basename "$(canonicalise "${ECJ}")") ]] \
122 && targets[i]=$(highlight_marker "${targets[i]}")
123 done
124
125 write_list_start "Available ECJ targets:"
126 write_numbered_list -m "(none found)" "${targets[@]}"
127 }
128
129 ### set action ###
130
131 describe_set() {
132 echo "Set a new ECJ target"
133 }
134
135 describe_set_options() {
136 echo "target : Target name or number (from 'list' action)"
137 }
138
139 describe_set_parameters() {
140 echo "<target>"
141 }
142
143 do_set() {
144 if [[ $# -gt 1 ]]; then
145 die -q "Too many parameters. Expected only one."
146 fi
147
148 local target=${1}
149
150 if [[ -z "${target}" ]] ; then
151 die -q "You didn't give me a target name or number."
152 elif [[ -L "${ECJ}" ]] ; then
153 if ! remove_symlink ; then
154 die -q "Can't remove existing ecj provider."
155 elif ! set_symlink "${1}" ; then
156 die -q "Can't set new ecj provider."
157 fi
158 elif [[ -e "${ECJ}" ]] ; then
159 write_warning_msg "Can't set a new ecj provider. There's a file in the way at ${ECJ}. You can try removing it manually, and then re-running this command."
160 elif [[ -e "${ECJ_JAR}" ]] ; then
161 write_warning_msg "Can't set a new ecj provider. There's a file in the way at ${ECJ_JAR}. You can try removing it manually, and then re-running this command."
162 else
163 set_symlink "${target}" || die -q "Wasn't able to set a new provider."
164 fi
165 }
166
167 ### update action ###
168
169 describe_update() {
170 echo "Set the ECJ target to the latest if the current target is invalid or if the given target is the latest"
171 }
172
173 describe_update_options() {
174 echo "target (optional) : Target name (from 'list' action)"
175 }
176
177 describe_update_parameters() {
178 echo "<target>"
179 }
180
181 do_update() {
182 if [[ $# -gt 1 ]] ; then
183 die -q "Too many parameters. Expected only one."
184 fi
185
186 # For pkg_postrm
187 if [[ ! $(find_targets) ]]; then
188 remove_symlink
189 return
190 fi
191
192 local canonicalised=$(canonicalise "${ECJ}")
193
194 if [[ ! -L "${ECJ}" ]] || [[ ! -f "${canonicalised}" ]] ; then
195 do_set 1
196 elif [[ -n "${1}" ]] ; then
197 # Check whether target name is valid.
198 find_target "${1}" > /dev/null
199
200 if [[ "${1}" == "$(find_target 1)" ]] ; then
201 do_set 1
202 fi
203 fi
204 }