1 |
george 07/12/29 09:54:07 |
2 |
|
3 |
Added: gnat-common-1.3-r1.bash digest-eselect-gnat-1.3-r1 |
4 |
Log: |
5 |
fixed problem with ADA_PROJECT_PATH when no libs are installed (203628) |
6 |
(Portage version: 2.1.4_rc11) |
7 |
|
8 |
Revision Changes Path |
9 |
1.1 app-admin/eselect-gnat/files/gnat-common-1.3-r1.bash |
10 |
|
11 |
file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/app-admin/eselect-gnat/files/gnat-common-1.3-r1.bash?rev=1.1&view=markup |
12 |
plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/app-admin/eselect-gnat/files/gnat-common-1.3-r1.bash?rev=1.1&content-type=text/plain |
13 |
|
14 |
Index: gnat-common-1.3-r1.bash |
15 |
=================================================================== |
16 |
# Copyright 1999-2007 Gentoo Foundation |
17 |
# Distributed under the terms of the GNU General Public License v2 |
18 |
# $Header: /var/cvsroot/gentoo-x86/app-admin/eselect-gnat/files/gnat-common-1.3-r1.bash,v 1.1 2007/12/29 09:54:07 george Exp $ |
19 |
|
20 |
# |
21 |
# Original Author: George Shapovalov <george@g.o> |
22 |
# Purpose: Contains common vars/locations and functions for use by gnat.eclass, |
23 |
# gnat.eselect and gnatbuild.eclass. |
24 |
# |
25 |
# NOTE!!! |
26 |
# This code should just define vars (try to limit these!) and simple functions. |
27 |
# No bash extensions!! |
28 |
# That is, no portage or eclass constructs are allowed! |
29 |
# |
30 |
|
31 |
|
32 |
|
33 |
# ---------------------------------- |
34 |
# Globals |
35 |
|
36 |
# Environmantal stuff (for env update) |
37 |
SPECSDIR="/usr/share/gnat/eselect" |
38 |
ENVDIR="/etc/env.d" |
39 |
MARKER="55gnat-" |
40 |
|
41 |
# User configurable settings |
42 |
SETTINGSDIR="/etc/ada" |
43 |
PRIMELIST="${SETTINGSDIR}/primary_compilers" |
44 |
|
45 |
## Lib install locations |
46 |
## |
47 |
## Gnat profile dependent files go under under ${LibTop}/${Gnat_Profile}/${PN} |
48 |
## and common files go unde SpecsDir, DataDir |
49 |
#PREFIX=/usr |
50 |
## Replace %LIBDIR% below with $(get_libdir) in eclasses and ebuilds (top level Ok, inherit multilib) |
51 |
## or $(profile2libdir ${profile}) in this code, eselect module or anywhere |
52 |
## outside portage (as profile will be available only during actual execution, this only should |
53 |
## be done inside corresponding functions). |
54 |
#AdalibSpecsDir=${PREFIX}/include/ada |
55 |
#AdalibDataDir=${PREFIX}/share/ada |
56 |
#AdalibLibTop=${PREFIX}/%LIBDIR%/ada |
57 |
|
58 |
|
59 |
# ------------------------------------ |
60 |
# Helpers |
61 |
# |
62 |
|
63 |
# get_all_profile_components splits gnat profile and returns pace separated list of its components: |
64 |
# x86_64-pc-linux-gnu-gnat-gcc-4.1 -> x86_64-pc-linux-gnu gcc 4.1 |
65 |
# args: |
66 |
# $1 - the string to split |
67 |
get_all_profile_components() { |
68 |
local GnatSLOT=${1##*-} |
69 |
local remainder=${1%-*} |
70 |
local GnatPkg=${remainder##*-} |
71 |
remainder=${remainder%-gnat-*} |
72 |
echo "${remainder} ${GnatPkg} ${GnatSLOT}" |
73 |
} |
74 |
|
75 |
# similar to above, returns only SLOT component: |
76 |
# x86_64-pc-linux-gnu-gnat-gcc-4.1 -> 4.1 |
77 |
# args: |
78 |
# $1 - the string to extract the slot from |
79 |
get_gnat_SLOT() { |
80 |
echo "${1##*-}" |
81 |
} |
82 |
|
83 |
# returns only Pkg component: |
84 |
# x86_64-pc-linux-gnu-gnat-gcc-4.1 -> gcc |
85 |
# args: |
86 |
# $1 - the string to extract the slot from |
87 |
get_gnat_Pkg() { |
88 |
local remainder=${1%-*} |
89 |
echo "${remainder##*-}" |
90 |
} |
91 |
|
92 |
# returns only Arch component: |
93 |
# x86_64-pc-linux-gnu-gnat-gcc-4.1 -> x86_64-pc-linux-gnu |
94 |
# args: |
95 |
# $1 - the string to extract the slot from |
96 |
get_gnat_Arch() { |
97 |
echo ${1%-gnat-*} |
98 |
} |
99 |
|
100 |
|
101 |
|
102 |
## ------------------------------------------- |
103 |
# gnat profile and lib detection functions |
104 |
|
105 |
|
106 |
# create a list of all gnat env.d files |
107 |
# for now use trivial implementation - store name of active profile in the |
108 |
# env file name, so it gets called 55gnat-${ARCH}-${PN}-${SLOT} |
109 |
get_env_list() { |
110 |
for fn in ${ENVDIR}/${MARKER}*; do |
111 |
echo $(basename ${fn}) |
112 |
done |
113 |
} |
114 |
|
115 |
|
116 |
|
117 |
# find all installed compilers and return a list |
118 |
find_all_compilers() { |
119 |
[[ ! -d ${SPECSDIR} ]] && exit |
120 |
for fn in ${SPECSDIR}/*; do |
121 |
[[ ! -d ${fn} ]] && echo $(basename ${fn}); |
122 |
done |
123 |
} |
124 |
|
125 |
# find installed primary compilers and return a list |
126 |
find_primary_compilers() { |
127 |
[[ ! -f ${PRIMELIST} ]] && exit |
128 |
for fn in $(cat ${PRIMELIST}); do |
129 |
[[ -f ${SPECSDIR}/${fn} ]] && echo ${fn}; |
130 |
done |
131 |
} |
132 |
|
133 |
# find installed libs and return a list |
134 |
find_all_libs() { |
135 |
[[ ! -d ${SPECSDIR} ]] && exit |
136 |
for fn in ${SPECSDIR}/*; do |
137 |
[[ -d ${fn} ]] && echo $(basename ${fn}); |
138 |
done |
139 |
} |
140 |
|
141 |
# find libs that have been built for a given profile |
142 |
# Arguments: |
143 |
# $1 - gnat profile for which to detect active libs |
144 |
find_libs4profile() { |
145 |
libs=( $(find_all_libs) ) |
146 |
|
147 |
for (( i = 0 ; i < ${#libs[@]} ; i = i + 1 )) ; do |
148 |
[[ -f ${SPECSDIR}/${libs[$i]}/$1 ]] && echo "${libs[$i]}" |
149 |
done |
150 |
} |
151 |
|
152 |
|
153 |
|
154 |
|
155 |
## ----------------------- |
156 |
# main action - central part of do_set and helpers |
157 |
|
158 |
|
159 |
# extracts values of the passed var definition from given spec file |
160 |
# params: |
161 |
# $1: spec file (as generated by gnabuild.eclass) |
162 |
# $2: variable name |
163 |
get_var_from_spec() { |
164 |
local var=$(grep -e "^ *$2=" $1|cut -d= -f2) |
165 |
echo ${var} |
166 |
} |
167 |
|
168 |
|
169 |
# Cycle through given libs and form a ':' separated list of settings for the given |
170 |
# var. Returned string starts with ':' if there is any non-empty setting, |
171 |
# otherwise returns empty string. Repeating settings are omitted, that is |
172 |
# unique entry is added only first time it is encountered. No need to have some |
173 |
# common dir listed many times in PATH for example. |
174 |
# |
175 |
# params: |
176 |
# $1 - name of env var to process |
177 |
# $2 - name of gnat profile |
178 |
# $3.. - list of libs to check (to avoid its composition every time) |
179 |
# - the list is expanded to list of args at the point of call |
180 |
get_lib_var_settings() { |
181 |
local envVar=$1 |
182 |
local toset=$2 |
183 |
#echo "get_lib_var_settings params:$@" >> /tmp/eselect-gnat.rep |
184 |
if [[ "none" != ${3} ]]; then |
185 |
local envString |
186 |
local specLine |
187 |
while [[ -n $3 ]]; do |
188 |
specLine=$(get_var_from_spec ${SPECSDIR}/$3/${toset} ${envVar}) |
189 |
#echo "$3:${specLine}." >> /tmp/eselect-gnat.rep |
190 |
if [[ -n ${specLine} ]] && [[ ! ${envString} =~ ${specLine} ]]; then |
191 |
envString="${envString}:${specLine}" |
192 |
fi |
193 |
shift |
194 |
done |
195 |
echo "${envString}" |
196 |
fi |
197 |
} |
198 |
|
199 |
|
200 |
|
201 |
# The action! |
202 |
# Part common for do_set and do_update of gnat.eselect, also used in gnat.eclass |
203 |
# to set environment during lib build and installation |
204 |
# |
205 |
# params: |
206 |
# $1 - profile to set (toset param inside) |
207 |
# $2 - envfile |
208 |
|
209 |
generate_envFile() { |
210 |
local toset=$1 |
211 |
local envfile=$2 |
212 |
|
213 |
local binpath="$(get_var_from_spec ${SPECSDIR}/${toset} binpath)" |
214 |
local libexecpath="$(get_var_from_spec ${SPECSDIR}/${toset} libexecpath)" |
215 |
local libs=( $(find_libs4profile ${toset}) ) |
216 |
#echo "generate_envFile: ${libs[@]}" >> /tmp/eselect-gnat.rep |
217 |
if (( 0 == ${#libs[@]} )); then |
218 |
libs="none" |
219 |
fi |
220 |
|
221 |
local MyPath="${binpath}:${libexecpath}$(get_lib_var_settings PATH ${toset} ${libs[@]})" |
222 |
echo "PATH=${MyPath}" > "${envfile}" |
223 |
echo "ROOTPATH=${MyPath}" >> "${envfile}" |
224 |
echo "MANPATH=$(get_var_from_spec ${SPECSDIR}/${toset} manpath)$(get_lib_var_settings MANPATH ${toset} ${libs[@]})" >> "${envfile}" |
225 |
echo "INFOPATH=$(get_var_from_spec ${SPECSDIR}/${toset} infopath)$(get_lib_var_settings INFOPATH ${toset} ${libs[@]})" >> "${envfile}" |
226 |
# the next three use the common base |
227 |
local libBase=$(get_var_from_spec ${SPECSDIR}/${toset} ldpath) |
228 |
echo "LDPATH=${libBase}:${libBase}/adalib$(get_lib_var_settings LDPATH ${toset} ${libs[@]})" >> "${envfile}" |
229 |
echo "ADA_INCLUDE_PATH=${libBase}/adainclude$(get_lib_var_settings ADA_INCLUDE_PATH ${toset} ${libs[@]})" >> "${envfile}" |
230 |
echo "ADA_OBJECTS_PATH=${libBase}/adalib$(get_lib_var_settings ADA_OBJECTS_PATH ${toset} ${libs[@]})" >> "${envfile}" |
231 |
# ADA_PROJECT_PATH may not be set in any of the installed packages, |
232 |
# we should only create this line if cumulative var is non-empty |
233 |
My_ProjectPath=$(get_lib_var_settings ADA_PROJECT_PATH ${toset} ${libs[@]}) |
234 |
if [[ -n ${My_ProjectPath} ]]; then |
235 |
echo "ADA_PROJECT_PATH=${My_ProjectPath}" >> "${envfile}" |
236 |
fi |
237 |
} |
238 |
|
239 |
|
240 |
|
241 |
|
242 |
1.1 app-admin/eselect-gnat/files/digest-eselect-gnat-1.3-r1 |
243 |
|
244 |
<<Binary file>> |
245 |
|
246 |
|
247 |
-- |
248 |
gentoo-commits@g.o mailing list |