1 |
ulm 10/02/28 18:52:00 |
2 |
|
3 |
Added: ecj-0.5.eselect |
4 |
Removed: ecj-0.4.eselect |
5 |
Log: |
6 |
Add support for brief output mode, bug 292101. Remove intermediate version. |
7 |
(Portage version: 2.2_rc63/cvs/Linux i686) |
8 |
|
9 |
Revision Changes Path |
10 |
1.1 app-admin/eselect-ecj/files/ecj-0.5.eselect |
11 |
|
12 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/app-admin/eselect-ecj/files/ecj-0.5.eselect?rev=1.1&view=markup |
13 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/app-admin/eselect-ecj/files/ecj-0.5.eselect?rev=1.1&content-type=text/plain |
14 |
|
15 |
Index: ecj-0.5.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.5.eselect,v 1.1 2010/02/28 18:52:00 ulm Exp $ |
21 |
|
22 |
DESCRIPTION="Manage ECJ targets" |
23 |
MAINTAINER="java@g.o" |
24 |
VERSION="0.5" |
25 |
|
26 |
ECJ="${EROOT}/usr/bin/ecj" |
27 |
|
28 |
# find a list of ecj symlink targets, best first. |
29 |
find_targets() { |
30 |
for f in $(ls -r "${ECJ}"-[0-9]* 2> /dev/null) ; do |
31 |
if [[ -f "${f}" ]] ; then |
32 |
echo $(basename "${f}") |
33 |
fi |
34 |
done |
35 |
} |
36 |
|
37 |
# get a named or numbered target. |
38 |
find_target() { |
39 |
local target=${1} |
40 |
|
41 |
if is_number "${target}" && [[ ${target} -ge 1 ]] ; then |
42 |
targets=( $(find_targets ) ) |
43 |
[[ -z "${targets}" ]] && die -q "No targets found!" |
44 |
target=${targets[target-1]} |
45 |
fi |
46 |
|
47 |
if [[ "${target}" = ecj-[0-9]* ]] && [[ -f "${EROOT}/usr/bin/${target}" ]] ; then |
48 |
echo ${target} |
49 |
else |
50 |
die -q "Target \"${1}\" doesn't appear to be valid!" |
51 |
fi |
52 |
} |
53 |
|
54 |
# try to remove the ecj symlink. |
55 |
remove_symlink() { |
56 |
rm "${ECJ}" &>/dev/null |
57 |
} |
58 |
|
59 |
# determine the current target. |
60 |
get_target() { |
61 |
local canonicalised=$(canonicalise "${ECJ}") |
62 |
echo $(basename "${canonicalised}") |
63 |
} |
64 |
|
65 |
# set the ecj symlink. |
66 |
set_symlink() { |
67 |
local target=$(find_target "${1}") |
68 |
remove_symlink |
69 |
ln -s "${EROOT}/usr/bin/${target}" "${ECJ}" || \ |
70 |
die "Couldn't set ${target} symlink." |
71 |
} |
72 |
|
73 |
### show action ### |
74 |
|
75 |
describe_show() { |
76 |
echo "Show current ECJ target" |
77 |
} |
78 |
|
79 |
do_show() { |
80 |
if [[ ${#} -gt 0 ]]; then |
81 |
die -q "No parameters allowed." |
82 |
fi |
83 |
|
84 |
if [[ -L "${ECJ}" ]] ; then |
85 |
get_target |
86 |
return 0 |
87 |
elif [[ -e "${ECJ}" ]] ; then |
88 |
echo "(not a symlink)" >&2 |
89 |
return 1 |
90 |
else |
91 |
echo "(unset)" >&2 |
92 |
return 1 |
93 |
fi |
94 |
} |
95 |
|
96 |
### list action ### |
97 |
|
98 |
describe_list() { |
99 |
echo "List available ECJ targets" |
100 |
} |
101 |
|
102 |
do_list() { |
103 |
if [[ ${#} -gt 0 ]]; then |
104 |
die -q "Usage error: no parameters allowed." |
105 |
fi |
106 |
|
107 |
local i targets |
108 |
targets=( $(find_targets) ) |
109 |
|
110 |
for (( i = 0; i < ${#targets[@]}; i++ )); do |
111 |
[[ ${targets[i]} = $(basename "$(canonicalise "${ECJ}")") ]] \ |
112 |
&& targets[i]=$(highlight_marker "${targets[i]}") |
113 |
done |
114 |
|
115 |
write_list_start "Available ECJ targets:" |
116 |
write_numbered_list -m "(none found)" "${targets[@]}" |
117 |
} |
118 |
|
119 |
### set action ### |
120 |
|
121 |
describe_set() { |
122 |
echo "Set a new ECJ target" |
123 |
} |
124 |
|
125 |
describe_set_options() { |
126 |
echo "target : Target name or number (from 'list' action)" |
127 |
} |
128 |
|
129 |
describe_set_parameters() { |
130 |
echo "<target>" |
131 |
} |
132 |
|
133 |
do_set() { |
134 |
if [[ $# -gt 1 ]]; then |
135 |
die -q "Too many parameters. Expected only one." |
136 |
fi |
137 |
|
138 |
local target=${1} |
139 |
|
140 |
if [[ -z "${target}" ]] ; then |
141 |
die -q "You didn't give me a target name or number." |
142 |
elif [[ -L "${ECJ}" ]] ; then |
143 |
if ! remove_symlink ; then |
144 |
die -q "Can't remove existing ecj provider." |
145 |
elif ! set_symlink "${1}" ; then |
146 |
die -q "Can't set new ecj provider." |
147 |
fi |
148 |
elif [[ -e "${ECJ}" ]] ; then |
149 |
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." |
150 |
else |
151 |
set_symlink "${target}" || die -q "Wasn't able to set a new provider." |
152 |
fi |
153 |
} |
154 |
|
155 |
### update action ### |
156 |
|
157 |
describe_update() { |
158 |
echo "Set the ECJ target to the latest if the current target is invalid or if the given target is the latest" |
159 |
} |
160 |
|
161 |
describe_update_options() { |
162 |
echo "target (optional) : Target name (from 'list' action)" |
163 |
} |
164 |
|
165 |
describe_update_parameters() { |
166 |
echo "<target>" |
167 |
} |
168 |
|
169 |
do_update() { |
170 |
if [[ $# -gt 1 ]] ; then |
171 |
die -q "Too many parameters. Expected only one." |
172 |
fi |
173 |
|
174 |
# For pkg_postrm |
175 |
if [[ ! $(find_targets) ]]; then |
176 |
remove_symlink |
177 |
return |
178 |
fi |
179 |
|
180 |
local canonicalised=$(canonicalise "${ECJ}") |
181 |
|
182 |
if [[ ! -L "${ECJ}" ]] || [[ ! -f "${canonicalised}" ]] ; then |
183 |
do_set 1 |
184 |
elif [[ -n "${1}" ]] ; then |
185 |
# Check whether target name is valid. |
186 |
find_target "${1}" > /dev/null |
187 |
|
188 |
if [[ "${1}" == "$(find_target 1)" ]] ; then |
189 |
do_set 1 |
190 |
fi |
191 |
fi |
192 |
} |