1 |
ulm 15/03/31 16:48:00 |
2 |
|
3 |
Added: ecj-0.7.eselect |
4 |
Log: |
5 |
Move package from app-admin to app-eselect category. |
6 |
|
7 |
(Portage version: 2.2.18/cvs/Linux x86_64, RepoMan options: --force, signed Manifest commit with key 9433907D693FB5B8!) |
8 |
|
9 |
Revision Changes Path |
10 |
1.1 app-eselect/eselect-ecj/files/ecj-0.7.eselect |
11 |
|
12 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-eselect/eselect-ecj/files/ecj-0.7.eselect?rev=1.1&view=markup |
13 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-eselect/eselect-ecj/files/ecj-0.7.eselect?rev=1.1&content-type=text/plain |
14 |
|
15 |
Index: ecj-0.7.eselect |
16 |
=================================================================== |
17 |
# -*-eselect-*- vim: ft=eselect |
18 |
# Copyright 1999-2015 Gentoo Foundation |
19 |
# Distributed under the terms of the GNU General Public License v2 |
20 |
# $Id: ecj-0.7.eselect,v 1.1 2015/03/31 16:48:00 ulm Exp $ |
21 |
|
22 |
DESCRIPTION="Manage ECJ targets" |
23 |
MAINTAINER="java@g.o" |
24 |
VERSION="0.7" |
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 |
# determine the current target. |
57 |
get_target() { |
58 |
local canonicalised=$(canonicalise "${ECJ}") |
59 |
echo $(basename "${canonicalised}") |
60 |
} |
61 |
|
62 |
### show action ### |
63 |
|
64 |
describe_show() { |
65 |
echo "Show current ECJ target" |
66 |
} |
67 |
|
68 |
do_show() { |
69 |
if [[ ${#} -gt 0 ]]; then |
70 |
die -q "No parameters allowed." |
71 |
fi |
72 |
|
73 |
if [[ -L "${ECJ}" ]] ; then |
74 |
get_target |
75 |
return 0 |
76 |
elif [[ -e "${ECJ}" ]] ; then |
77 |
echo "(not a symlink)" >&2 |
78 |
return 1 |
79 |
else |
80 |
echo "(unset)" >&2 |
81 |
return 1 |
82 |
fi |
83 |
} |
84 |
|
85 |
### list action ### |
86 |
|
87 |
describe_list() { |
88 |
echo "List available ECJ targets" |
89 |
} |
90 |
|
91 |
do_list() { |
92 |
if [[ ${#} -gt 0 ]]; then |
93 |
die -q "Usage error: no parameters allowed." |
94 |
fi |
95 |
|
96 |
local i targets |
97 |
targets=( $(find_targets) ) |
98 |
|
99 |
for (( i = 0; i < ${#targets[@]}; i++ )); do |
100 |
[[ ${targets[i]} = $(basename "$(canonicalise "${ECJ}")") ]] \ |
101 |
&& targets[i]=$(highlight_marker "${targets[i]}") |
102 |
done |
103 |
|
104 |
write_list_start "Available ECJ targets:" |
105 |
write_numbered_list -m "(none found)" "${targets[@]}" |
106 |
} |
107 |
|
108 |
### set action ### |
109 |
|
110 |
describe_set() { |
111 |
echo "Set a new ECJ target" |
112 |
} |
113 |
|
114 |
describe_set_options() { |
115 |
echo "target : Target name or number (from 'list' action)" |
116 |
} |
117 |
|
118 |
describe_set_parameters() { |
119 |
echo "<target>" |
120 |
} |
121 |
|
122 |
do_set() { |
123 |
[[ ${1} ]] || die -q "You didn't give me a target name or number." |
124 |
[[ ${2} ]] && die -q "Too many parameters. Expected only one." |
125 |
|
126 |
local target=$(find_target "${1}") |
127 |
|
128 |
rm -f "${ECJ}" "${ECJ_JAR}" |
129 |
|
130 |
ln -sf "${target}" "${ECJ}" || die "Couldn't set ${target} symlink." |
131 |
mkdir -p $(dirname ${ECJ_JAR}) |
132 |
[[ "${target}" != ecj-gcj* ]] && target="eclipse-${target}" |
133 |
ln -sf "${EROOT}"/usr/share/${target}/lib/ecj.jar ${ECJ_JAR} \ |
134 |
|| die -q "Wasn't able to set a new provider." |
135 |
} |
136 |
|
137 |
### update action ### |
138 |
|
139 |
describe_update() { |
140 |
echo "Set the ECJ target to the latest if the current target is invalid or if the given target is the latest" |
141 |
} |
142 |
|
143 |
describe_update_options() { |
144 |
echo "target (optional) : Target name (from 'list' action)" |
145 |
} |
146 |
|
147 |
describe_update_parameters() { |
148 |
echo "<target>" |
149 |
} |
150 |
|
151 |
do_update() { |
152 |
[[ ${1} ]] && find_target "${1}" >/dev/null |
153 |
[[ ${2} ]] && die -q "Too many parameters. Expected only one." |
154 |
|
155 |
if [[ ! -f "${ECJ}" ]] || [[ ! -f "${ECJ_JAR}" ]]; then |
156 |
local target="${1}" |
157 |
if [[ -z "${target}" ]]; then |
158 |
local all_targets=( $(find_targets) ) |
159 |
target=${all_targets} |
160 |
fi |
161 |
if [[ ${target} ]]; then |
162 |
do_set ${target} |
163 |
else |
164 |
rm -f "${ECJ}" "${ECJ_JAR}" |
165 |
fi |
166 |
fi |
167 |
} |