1 |
dev-zero 09/04/07 09:39:39 |
2 |
|
3 |
Added: boost.eselect-0.3 |
4 |
Log: |
5 |
Version bump for new boost versions: full profile support using profile files. |
6 |
(Portage version: 2.1.6.11/cvs/Linux x86_64) |
7 |
|
8 |
Revision Changes Path |
9 |
1.1 app-admin/eselect-boost/files/boost.eselect-0.3 |
10 |
|
11 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/app-admin/eselect-boost/files/boost.eselect-0.3?rev=1.1&view=markup |
12 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/app-admin/eselect-boost/files/boost.eselect-0.3?rev=1.1&content-type=text/plain |
13 |
|
14 |
Index: boost.eselect-0.3 |
15 |
=================================================================== |
16 |
# Copyright 1999-2009 Gentoo Foundation |
17 |
# Distributed under the terms of the GNU General Public License v2 |
18 |
# $Id: boost.eselect-0.3,v 1.1 2009/04/07 09:39:39 dev-zero Exp $ |
19 |
|
20 |
# This eclass-module has been initially written by Łukasz Michalik <lmi@××××××××××××.pl> |
21 |
# Corrections and extensions by Tiziano Müller <dev-zero@g.o> |
22 |
|
23 |
DESCRIPTION="Manage boost installations" |
24 |
MAINTAINER="dev-zero@g.o" |
25 |
VERSION="0.3" |
26 |
|
27 |
_boost_tools="bcp bjam compiler_status inspect library_status process_jam_log quickbook wave" |
28 |
|
29 |
# ... meaning: <none> and -debug: |
30 |
_suffices="|-debug" |
31 |
|
32 |
find_targets() { |
33 |
local f |
34 |
# use ls here to get a really empty set in case no boost is installed |
35 |
for d in $(ls -d "${ROOT}"/usr/share/boost-eselect/profiles/* 2>/dev/null) ; do |
36 |
for p in "${d}"/* ; do |
37 |
echo "boost-$(basename ${d})/$(basename ${p})" |
38 |
done |
39 |
done |
40 |
} |
41 |
|
42 |
remove_installation() { |
43 |
echo "Removing symlinks from old version" |
44 |
|
45 |
local link |
46 |
for link in "${ROOT}/usr/include/boost" "${ROOT}/usr/share/boostbook" ; do |
47 |
if [[ -L "${link}" ]] ; then |
48 |
rm "${link}" || die -q "Couldn't remove \"${link}\" symlink" |
49 |
else |
50 |
[[ -e "${link}" ]] && die -q "\${link}\" exists and isn't a symlink" |
51 |
fi |
52 |
done |
53 |
|
54 |
pushd "${ROOT}/usr/%LIBDIR%" 1>/dev/null |
55 |
local lib |
56 |
for lib in libboost_*.{a,so} ; do |
57 |
[[ -L "${lib}" && "${lib}" != libboost_*[[:digit:]]_[[:digit:]][[:digit:]]@(${_suffices}).@(a|so) ]] || continue |
58 |
rm "${lib}" || die -q "Unable to remove \"/usr/%LIBDIR%/${lib}\" symlink" |
59 |
done |
60 |
popd 1>/dev/null |
61 |
|
62 |
pushd "${ROOT}"/usr/bin 1>/dev/null |
63 |
local tool |
64 |
for tool in ${_boost_tools} ; do |
65 |
[[ -L "${tool}" ]] && ( rm "${tool}" || die -q "Unable to remove \"/usr/bin/${tool}\" symlink" ) |
66 |
done |
67 |
popd 1>/dev/null |
68 |
|
69 |
local mod="mpi.so" |
70 |
for moddir in "${ROOT}"/usr/%LIBDIR%/python*/site-packages ; do |
71 |
if [ -L "${moddir}/${mod}" ] ; then |
72 |
rm "${moddir}/${mod}" || die -q "Unable to remove \"${moddir}/${mod}\" symlink" |
73 |
else |
74 |
[[ -e "${moddir}/${mod}" ]] && die -q "\"${moddir}/${mod}\" exists and isn't a symlink" |
75 |
fi |
76 |
done |
77 |
|
78 |
if [ -L "${ROOT}/etc/eselect/boost/active" ] ; then |
79 |
rm "${ROOT}/etc/eselect/boost/active" || die -q "Unable to remove \"${ROOT}/etc/eselect/boost/active\" symlink" |
80 |
else |
81 |
[[ -e "${ROOT}/etc/eselect/boost/active" ]] && die -q "\"${ROOT}/etc/eselect/boost/active\" exists and isn't a symlink" |
82 |
fi |
83 |
} |
84 |
|
85 |
set_installation() { |
86 |
[[ -z "${1}" ]] && die -q "Too few parameters to set_installation()" |
87 |
local target="${1}" |
88 |
|
89 |
echo "Creating symlinks for ${target}" |
90 |
|
91 |
local profile="${target/*\/}" |
92 |
local version="${target/\/${profile}}" |
93 |
version="${version/boost-}" |
94 |
version="${version/./_}" |
95 |
|
96 |
cd "${ROOT}/etc/eselect/boost" |
97 |
ln -s "${ROOT}/usr/share/boost-eselect/profiles/${target//boost-}" active || die -q "Couldn't create symlink active -> /usr/share/boost-eselect/profiles/${target//boost-}/${profile}" |
98 |
|
99 |
. "${ROOT}/usr/share/boost-eselect/profiles/${target//boost-}" |
100 |
|
101 |
for t in ${dirs} ${bins} ${libs} ; do |
102 |
[[ -e "${ROOT}${t}" ]] || die -q "\"${t}\" listed as target does not exist" |
103 |
|
104 |
pushd "$(dirname ${ROOT}${t})" 1>/dev/null |
105 |
local ts=$(basename "${t}") |
106 |
local tt="${ts//-${version}}" |
107 |
tt="${tt//${suffix}}" |
108 |
ln -s ${ts} ${tt} || die -q "Couldn't create symlink \"$(pwd)/${tt}\"" |
109 |
popd 1>/dev/null |
110 |
done |
111 |
|
112 |
[[ -d "${ROOT}${includes}" ]] || die -q "\"${includes}\" does not exist" |
113 |
pushd "${ROOT}/usr/include" 1>/dev/null |
114 |
ln -s ${includes//\/usr\/include\/} boost || die -q "Couldn't create symlink \"/usr/include/boost\"" |
115 |
popd 1>/dev/null |
116 |
|
117 |
for t in ${python} ; do |
118 |
pushd "$(dirname ${ROOT}${t})/.." 1>/dev/null |
119 |
local ts="$(basename $(dirname ${ROOT}${t}))/${t//*\/}" |
120 |
ts="${ts//${suffix}}" |
121 |
local tt=${t//*\/} |
122 |
ln -s "${ts}" "${tt}" || die -q "Couldn't create symlink \"$(pwd)/${tt}\"" |
123 |
popd 1>/dev/null |
124 |
done |
125 |
} |
126 |
|
127 |
### show action ### |
128 |
|
129 |
describe_show() { |
130 |
echo "Show the current boost version used" |
131 |
} |
132 |
|
133 |
do_show() { |
134 |
local include |
135 |
|
136 |
write_list_start "Current boost version:" |
137 |
if [[ -L "${ROOT}"/usr/include/boost ]] ; then |
138 |
include=$(basename $(dirname $(canonicalise "${ROOT}"/usr/include/boost ))) |
139 |
write_kv_list_entry "${include%/}" "" |
140 |
else |
141 |
write_kv_list_entry "(unset)" "" |
142 |
fi |
143 |
} |
144 |
|
145 |
### list action ### |
146 |
|
147 |
describe_list() { |
148 |
echo "List available boost versions" |
149 |
} |
150 |
|
151 |
do_list() { |
152 |
local targets=( $(find_targets ) ) |
153 |
write_list_start "Available boost versions:" |
154 |
if [[ -n "${targets[@]}" ]] ; then |
155 |
local i |
156 |
local active_slot=$(canonicalise "${ROOT}/etc/eselect/boost/active") |
157 |
active_slot=${active_slot/"${ROOT}/usr/share/boost-eselect/profiles/"/boost-} |
158 |
for (( i = 0 ; i < ${#targets[@]} ; i = i + 1 )) ; do |
159 |
if [[ "${targets[${i}]}" == ${active_slot} ]] ; then |
160 |
targets[${i}]="${targets[${i}]} $(highlight '*' )" |
161 |
fi |
162 |
done |
163 |
write_numbered_list "${targets[@]}" |
164 |
else |
165 |
write_kv_list_entry "(none found)" "" |
166 |
fi |
167 |
} |
168 |
|
169 |
### set action ### |
170 |
|
171 |
describe_set() { |
172 |
echo "Set a new boost version" |
173 |
} |
174 |
|
175 |
describe_set_parameters() { |
176 |
echo "<target>" |
177 |
} |
178 |
|
179 |
describe_set_options() { |
180 |
echo "target : Target name or number (from 'list' action)" |
181 |
} |
182 |
|
183 |
do_set() { |
184 |
if [[ -z "${1}" ]] ; then |
185 |
# no parameter |
186 |
die -q "You didn't tell me what to set the version to" |
187 |
fi |
188 |
|
189 |
local target="${1}" |
190 |
if is_number "${target}" ; then |
191 |
targets=($(find_targets)) |
192 |
target="${targets[$((${target} - 1))]}" |
193 |
fi |
194 |
|
195 |
remove_installation |
196 |
set_installation "${target}" |
197 |
} |
198 |
|
199 |
### update action ### |
200 |
|
201 |
describe_update() { |
202 |
echo "Automaticly update boost version used" |
203 |
} |
204 |
|
205 |
do_update() { |
206 |
# set default profile |
207 |
profile="default" |
208 |
|
209 |
# extract profile if there's already one boost version selected |
210 |
if [ -L "${ROOT}"/etc/eselect/boost/active ] ; then |
211 |
profile=$(basename $(canonicalise "${ROOT}/etc/eselect/boost/active")) |
212 |
fi |
213 |
|
214 |
echo "Previously selected profile: ${profile}" |
215 |
|
216 |
remove_installation |
217 |
|
218 |
local targets=($(find_targets)) |
219 |
[[ ${#targets[@]} -gt 0 ]] || die -q "No slotted boost version found" |
220 |
|
221 |
# contains surely the highest available version, but maybe not the right profile |
222 |
local last_target="${targets[@]:(-1)}" |
223 |
# strip profile |
224 |
local target_version="${last_target//\/*}" |
225 |
|
226 |
# in case the previously used profile isn't available anymore |
227 |
local target="${target_version}/default" |
228 |
local matching_profile_found=0 |
229 |
for (( i = 0 ; i < ${#targets[@]} ; i = i + 1 )) ; do |
230 |
if [[ "${targets[${i}]}" == "${target_version}/${profile}" ]] ; then |
231 |
target="${targets[${i}]}" |
232 |
matching_profile_found=1 |
233 |
break |
234 |
fi |
235 |
done |
236 |
|
237 |
if [[ "${matching_profile_found}" == 1 ]] ; then |
238 |
echo "Found a matching profile \"${profile}\" for the new version." |
239 |
else |
240 |
echo "Didn't find the previously selected profile \"${profile}\" for the new version. Resetting to \"default\"." |
241 |
fi |
242 |
|
243 |
set_installation "${target}" |
244 |
} |