1 |
#!/bin/sh |
#!/bin/bash |
2 |
|
# $Id$ |
|
# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/env-rebuild.sh,v 1.11 2005-12-01 12:37:47 niro Exp $ |
|
3 |
# |
# |
4 |
# rebuilds /etc/{ld.so.conf,profile.env} with given files from /etc/env.d |
# rebuilds /etc/{ld.so.conf,profile.env} with given files from /etc/env.d |
5 |
# |
# |
6 |
|
|
|
## |
|
|
# exp. /etc/env.d/kde |
|
|
# |
|
|
# PATH="/opt/kde/bin" |
|
|
# ROOTPATH="/opt/kde/bin" |
|
|
# LDPATH="/opt/kde/lib" |
|
|
# |
|
|
## |
|
|
|
|
7 |
# sets root path |
# sets root path |
8 |
P="${MROOT}" |
P="${MROOT}" |
9 |
SPECIALVARS="KDEDIRS PATH CLASSPATH LDPATH MANPATH INFODIR INFOPATH ROOTPATH CONFIG_PROTECT CONFIG_PROTECT_MASK PRELINK_PATH PRELINK_PATH_MASK OMF_DIR" |
|
10 |
#SPECIALVARS="KDEDIRS PATH LDPATH MANPATH INFODIR INFOPATH ROOTPATH CLASSPATH" |
SPECIALVARS="KDEDIRS PATH CLASSPATH LDPATH MANPATH INFODIR INFOPATH ROOTPATH" |
11 |
|
SPECIALVARS+=" CONFIG_PROTECT CONFIG_PROTECT_MASK CONFIG_PROTECT_IGNORE" |
12 |
|
SPECIALVARS+=" PRELINK_PATH PRELINK_PATH_MASK" |
13 |
|
SPECIALVARS+=" OMF_DIR LIBGL_DRIVERS_PATH XDG_CONFIG_DIRS XDG_DATA_DIRS" |
14 |
|
|
15 |
# secure tmp dir |
# secure tmp dir |
16 |
if [ -x /bin/mktemp ] |
if [ -x /bin/mktemp ] |
36 |
# reads content of every file |
# reads content of every file |
37 |
while read path |
while read path |
38 |
do |
do |
39 |
# abort if empty |
# ignore if empty or a comment |
40 |
[[ -z ${path} ]] && continue |
case "${path}" in |
41 |
|
\#*|"") continue ;; |
42 |
|
esac |
43 |
|
|
44 |
# writes LDPATH to ${P}/etc/ld.so.conf, |
# writes LDPATH to ${P}/etc/ld.so.conf, |
45 |
# anything else to ${P}/etc/profile.env |
# anything else to ${P}/etc/profile.env |
57 |
|
|
58 |
if [[ ${SPECVAR} = yes ]] |
if [[ ${SPECVAR} = yes ]] |
59 |
then |
then |
60 |
if [[ ${path%%=*} = CONFIG_PROTECT ]] || [[ ${path%%=*} = CONFIG_PROTECT_MASK ]] |
case ${path%%=*} in |
61 |
then |
CONFIG_PROTECT*|XDG*) |
62 |
# CONFIG_PROTECTS has as delimiter not ':' but ' ' |
# CONFIG_PROTECT*|XDG* have as delimiter not ':' but ' ' |
63 |
path="${path//\"}" #}" <--- make code readable again :) |
path="${path//\"}" #}" <--- make code readable again :) |
64 |
echo -n "${path##*=} " >> ${TMPDIR}/${path%%=*} |
echo -n "${path##*=} " >> ${TMPDIR}/${path%%=*} |
65 |
unset SPECVAR |
unset SPECVAR |
66 |
else |
;; |
67 |
# special var are written to tmpfile |
*) |
68 |
# to substitude them to one variable |
# special var are written to tmpfile |
69 |
# substitudes " from $path if exists |
# to substitude them to one variable |
70 |
path="${path//\"}" #}" <--- make code readable again :) |
# substitudes " from $path if exists |
71 |
echo -n "${path##*=}:" >> ${TMPDIR}/${path%%=*} |
path="${path//\"}" #}" <--- make code readable again :) |
72 |
unset SPECVAR |
echo -n "${path##*=}:" >> ${TMPDIR}/${path%%=*} |
73 |
fi |
unset SPECVAR |
74 |
|
;; |
75 |
|
esac |
76 |
else |
else |
77 |
# all other vars go directly to /etc/profile.env |
# all other vars go directly to /etc/profile.env |
78 |
echo "export ${path}" >> ${P}/etc/profile.env |
echo "export ${path}" >> ${P}/etc/profile.env |