|
Lines 16-38
Link Here
|
| 16 |
fi |
16 |
fi |
| 17 |
|
17 |
|
| 18 |
# Some functions to parse and check path correctly ... |
18 |
# Some functions to parse and check path correctly ... |
|
|
19 |
# Usage: is_in_path PATH /usr/bin |
| 19 |
is_in_path() { |
20 |
is_in_path() { |
| 20 |
search="$1"; ifs="$IFS"; IFS=":"; set $PATH; IFS="$ifs" |
21 |
var="$1"; search="$2"; |
|
|
22 |
if eval test -z \$$1; then return 1; fi |
| 23 |
ifs="$IFS"; IFS=":"; eval set \$$var; IFS="$ifs" |
| 21 |
for i in $*; do |
24 |
for i in $*; do |
| 22 |
[ "${i}" = "${search}" ] && return 0 |
25 |
[ "${i}" = "${search}" ] && return 0 |
| 23 |
done |
26 |
done |
| 24 |
return 1 |
27 |
return 1 |
| 25 |
} |
28 |
} |
| 26 |
|
29 |
|
| 27 |
# Usage: place_before_in_path /opt/trinity/games /usr/games |
30 |
# Usage: place_before_in_path PATH /opt/trinity/games /usr/games |
| 28 |
place_before_in_path() { |
31 |
place_before_in_path() { |
| 29 |
insert="$1"; before="$2"; ifs="$IFS"; IFS=":"; set $PATH; IFS="$ifs" |
32 |
var="$1"; insert="$2"; |
|
|
33 |
if eval test -z \$$1; then |
| 34 |
eval export $var=${insert} |
| 35 |
else |
| 36 |
before="$3"; ifs="$IFS"; IFS=":"; eval set \$$var; IFS="$ifs" |
| 37 |
NPATH="" |
| 38 |
for i in $*; do |
| 39 |
[ "${i}" = "${before}" ] && NPATH="${NPATH}:${insert}" |
| 40 |
NPATH="${NPATH}:${i}" |
| 41 |
done |
| 42 |
eval export $var=${NPATH#:} |
| 43 |
fi |
| 44 |
} |
| 45 |
|
| 46 |
# Usage: remove_from_path PATH /opt/trinity/games |
| 47 |
remove_from_path() { |
| 48 |
var="$1"; remove="$2"; |
| 49 |
if eval test -z \$$1; then return 1; fi |
| 50 |
ifs="$IFS"; IFS=":"; eval set \$$var; IFS="$ifs" |
| 30 |
NPATH="" |
51 |
NPATH="" |
| 31 |
for i in $*; do |
52 |
for i in $*; do |
| 32 |
[ "${i}" = "${before}" ] && NPATH="${NPATH}:${insert}" |
53 |
[ "${i}" != "${remove}" ] && NPATH="${NPATH}:${i}" |
| 33 |
NPATH="${NPATH}:${i}" |
|
|
| 34 |
done |
54 |
done |
| 35 |
export PATH=${NPATH#:} |
55 |
eval export $var=${NPATH#:} |
| 36 |
} |
56 |
} |
| 37 |
|
57 |
|
| 38 |
echo "[starttde] Starting starttde." 1>&2 |
58 |
echo "[starttde] Starting starttde." 1>&2 |
|
Lines 143-172
Link Here
|
| 143 |
|
163 |
|
| 144 |
# Modify the following environment variables only as necessary. |
164 |
# Modify the following environment variables only as necessary. |
| 145 |
if [ -d $TDEDIR/games ]; then |
165 |
if [ -d $TDEDIR/games ]; then |
| 146 |
if ! is_in_path "$TDEDIR/games" ; then |
166 |
if ! is_in_path PATH "$TDEDIR/games" ; then |
| 147 |
# Respect the traditional path order. Don't blindly place $TDEDIR/games |
167 |
# Respect the traditional path order. Don't blindly place $TDEDIR/games |
| 148 |
# first in the path. Only place $TDEDIR/games before /usr/games. If packagers |
168 |
# first in the path. Only place $TDEDIR/games before /usr/games. If packagers |
| 149 |
# are adding $TDEDIR/games elsewhere, then they need to ensure the traditional |
169 |
# are adding $TDEDIR/games elsewhere, then they need to ensure the traditional |
| 150 |
# search patch is respected. |
170 |
# search patch is respected. |
| 151 |
# Is there a way we can check that $TDEDIR/games is always placed only just before |
171 |
# Is there a way we can check that $TDEDIR/games is always placed only just before |
| 152 |
# /usr/games in the search path? |
172 |
# /usr/games in the search path? |
| 153 |
if is_in_path "/usr/games"; then |
173 |
if is_in_path PATH "/usr/games"; then |
| 154 |
place_before_in_path "$TDEDIR/games" "/usr/games" |
174 |
place_before_in_path PATH "$TDEDIR/games" "/usr/games" |
| 155 |
else |
175 |
else |
| 156 |
export PATH=$TDEDIR/games:$PATH |
176 |
export PATH=$TDEDIR/games:$PATH |
| 157 |
fi |
177 |
fi |
| 158 |
fi |
178 |
fi |
| 159 |
fi |
179 |
fi |
| 160 |
if [ -d $TDEDIR/bin ]; then |
180 |
if [ -d $TDEDIR/bin ]; then |
| 161 |
if ! is_in_path "$TDEDIR/bin" ]; then |
181 |
if ! is_in_path PATH "$TDEDIR/bin" ]; then |
| 162 |
# Respect the traditional path order. Don't blindly place $TDEDIR/bin |
182 |
# Respect the traditional path order. Don't blindly place $TDEDIR/bin |
| 163 |
# first in the path. Only place $TDEDIR/bin before /usr/bin. This order is |
183 |
# first in the path. Only place $TDEDIR/bin before /usr/bin. This order is |
| 164 |
# consistent with tdelibs/tdesu/stub.cpp. If packagers are adding $TDEDIR/bin |
184 |
# consistent with tdelibs/tdesu/stub.cpp. If packagers are adding $TDEDIR/bin |
| 165 |
# elsewhere, then they need to ensure the traditional search patch is respected. |
185 |
# elsewhere, then they need to ensure the traditional search patch is respected. |
| 166 |
# Is there a way we can check that $TDEDIR/bin is always placed only just before |
186 |
# Is there a way we can check that $TDEDIR/bin is always placed only just before |
| 167 |
# /usr/bin in the search path? |
187 |
# /usr/bin in the search path? |
| 168 |
if is_in_path "/usr/bin"; then |
188 |
if is_in_path PATH "/usr/bin"; then |
| 169 |
place_before_in_path "$TDEDIR/bin" "/usr/bin" |
189 |
place_before_in_path PATH "$TDEDIR/bin" "/usr/bin" |
| 170 |
else |
190 |
else |
| 171 |
export PATH=$TDEDIR/bin:$PATH |
191 |
export PATH=$TDEDIR/bin:$PATH |
| 172 |
fi |
192 |
fi |
|
Lines 229-255
Link Here
|
| 229 |
# set in $TDEDIRS are intended to override data files found in $TDEDIR. Those additional |
249 |
# set in $TDEDIRS are intended to override data files found in $TDEDIR. Those additional |
| 230 |
# directories should be placed before $TDEDIR and before /usr/share. |
250 |
# directories should be placed before $TDEDIR and before /usr/share. |
| 231 |
if [ "$TDEDIR" != "/usr" ] && [ -d $TDEDIR/share ]; then |
251 |
if [ "$TDEDIR" != "/usr" ] && [ -d $TDEDIR/share ]; then |
| 232 |
if [ "$XDG_DATA_DIRS" = "" ]; then |
252 |
# If '/usr/share' is not already here, we include it at the last position. |
| 233 |
# Ensure the standard location of /usr/share is included. |
253 |
if ! is_in_path XDG_DATA_DIRS "/usr/share"; then |
| 234 |
XDG_DATA_DIRS=/usr/share |
254 |
XDG_DATA_DIRS=$XDG_DATA_DIRS:/usr/share |
| 235 |
else |
|
|
| 236 |
if [ "`echo $XDG_DATA_DIRS | grep \"/usr/share\"`" = "" ]; then |
| 237 |
XDG_DATA_DIRS=$XDG_DATA_DIRS:/usr/share |
| 238 |
fi |
| 239 |
fi |
| 240 |
if [ "`echo $XDG_DATA_DIRS | grep \"$TDEDIR/share\"`" = "" ]; then |
| 241 |
XDG_DATA_DIRS=$TDEDIR/share:$XDG_DATA_DIRS |
| 242 |
fi |
255 |
fi |
| 243 |
if [ "$TDEDIRS" != "" ]; then |
256 |
|
| 244 |
for i in `seq \`echo $TDEDIRS | awk -F : '{print NF}'\` -1 1`; do |
257 |
# Ensure that $TDEDIR/share is always before '/usr/share'. |
| 245 |
if [ "`echo $XDG_DATA_DIRS | grep \"\`echo $TDEDIRS | cut -d: -f${i}\`\"`" = "" ]; then |
258 |
remove_from_path XDG_DATA_DIRS $TDEDIR/share |
| 246 |
XDG_DATA_DIRS=`echo $TDEDIRS | cut -d: -f${i}`/share:$XDG_DATA_DIRS |
259 |
place_before_in_path XDG_DATA_DIRS "$TDEDIR/share" "/usr/share" |
|
|
260 |
|
| 261 |
# Adds supplementary directories from TDEDIRS, if any, before TDEDIR. |
| 262 |
if [ "$TDEDIRS" != "" ]; then |
| 263 |
ifs="$IFS"; IFS=":"; set $TDEDIRS; IFS="$ifs" |
| 264 |
for dir in $*; do |
| 265 |
if ! is_in_path XDG_DATA_DIRS "$dir/share" && [ -d "$dir/share" ]; then |
| 266 |
XDG_DATA_DIRS=$dir/share:$XDG_DATA_DIRS |
| 247 |
fi |
267 |
fi |
| 248 |
done |
268 |
done |
| 249 |
fi |
269 |
fi |
| 250 |
export XDG_DATA_DIRS |
270 |
export XDG_DATA_DIRS |
| 251 |
fi |
271 |
fi |
| 252 |
|
272 |
|
|
|
273 |
echo "[starttde] XDG_DATA_DIRS: $XDG_DATA_DIRS" 1>&2 |
| 274 |
|
| 253 |
test -n "$TDEHOME" && tdehome=`echo "$TDEHOME" | sed "s,^~/,$HOME/,"` |
275 |
test -n "$TDEHOME" && tdehome=`echo "$TDEHOME" | sed "s,^~/,$HOME/,"` |
| 254 |
|
276 |
|
| 255 |
# Allow interested applications, such as the Plasma control wrapper, |
277 |
# Allow interested applications, such as the Plasma control wrapper, |