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