Magellan Linux

Contents of /trunk/mage/usr/lib/mage/env-rebuild.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 285 - (show annotations) (download) (as text)
Thu Dec 1 12:37:47 2005 UTC (18 years, 5 months ago) by niro
File MIME type: application/x-sh
File size: 2821 byte(s)
missed to create the tmp dir

1 #!/bin/sh
2
3 # $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 $
4 #
5 # rebuilds /etc/{ld.so.conf,profile.env} with given files from /etc/env.d
6 #
7
8 ##
9 # exp. /etc/env.d/kde
10 #
11 # PATH="/opt/kde/bin"
12 # ROOTPATH="/opt/kde/bin"
13 # LDPATH="/opt/kde/lib"
14 #
15 ##
16
17 # sets root path
18 P="${MROOT}"
19 SPECIALVARS="KDEDIRS PATH CLASSPATH LDPATH MANPATH INFODIR INFOPATH ROOTPATH CONFIG_PROTECT CONFIG_PROTECT_MASK PRELINK_PATH PRELINK_PATH_MASK OMF_DIR"
20 #SPECIALVARS="KDEDIRS PATH LDPATH MANPATH INFODIR INFOPATH ROOTPATH CLASSPATH"
21
22 # secure tmp dir
23 if [ -x /bin/mktemp ]
24 then
25 TMPDIR="$(/bin/mktemp -d -p /var/tmp)"
26 else
27 TMPDIR="/var/tmp/tmp.$$"
28 install -d ${TMPDIR}
29 fi
30
31 echo -en "\n>>>> Rebuilding environment... "
32
33 # clean existing conf files
34 :> ${P}/etc/ld.so.conf
35 :> ${P}/etc/profile.env
36
37 # gets everything in /etc/env.d
38 for file in ${P}/etc/env.d/*
39 do
40 # abort if "empty"
41 [[ ${file} = ${P}/etc/env.d/\* ]] && continue
42
43 # reads content of every file
44 while read path
45 do
46 # abort if empty
47 [[ -z ${path} ]] && continue
48
49 # writes LDPATH to ${P}/etc/ld.so.conf,
50 # anything else to ${P}/etc/profile.env
51 if [[ ${path%%=*} = LDPATH ]]
52 then
53 #substitudes " from $path if exists
54 path="${path//\"}" #}" <--- make code readable again :)
55 echo "${path##*=}" >> ${P}/etc/ld.so.conf
56 else
57 # checks if var exists in specialvars
58 for i in ${SPECIALVARS}
59 do
60 [[ ${path%%=*} = ${i} ]] && SPECVAR="yes"
61 done
62
63 if [[ ${SPECVAR} = yes ]]
64 then
65 if [[ ${path%%=*} = CONFIG_PROTECT ]] || [[ ${path%%=*} = CONFIG_PROTECT_MASK ]]
66 then
67 # CONFIG_PROTECTS has as delimiter not ':' but ' '
68 path="${path//\"}" #}" <--- make code readable again :)
69 echo -n "${path##*=} " >> ${TMPDIR}/${path%%=*}
70 unset SPECVAR
71 else
72 # special var are written to tmpfile
73 # to substitude them to one variable
74 # substitudes " from $path if exists
75 path="${path//\"}" #}" <--- make code readable again :)
76 echo -n "${path##*=}:" >> ${TMPDIR}/${path%%=*}
77 unset SPECVAR
78 fi
79 else
80 # all other vars go directly to /etc/profile.env
81 echo "export ${path}" >> ${P}/etc/profile.env
82 fi
83 fi
84 done << EOF
85 $(cat ${file})
86 EOF
87
88 done
89
90 # reads special vars tmp files and writes them to /etc/profile.env
91 for i in ${SPECIALVARS}
92 do
93 if [ -f ${TMPDIR}/${i} ]
94 then
95 # only OMF_DIR goes to /etc/scrollkeeper.conf
96 if [[ ${i} = OMF_DIR ]]
97 then
98 echo "${i}=$(cat ${TMPDIR}/${i})" > ${P}/etc/scrollkeeper.conf
99 else
100 echo "export ${i}=\"$(cat ${TMPDIR}/${i})\"" >> ${P}/etc/profile.env
101 fi
102 rm ${TMPDIR}/${i}
103 fi
104 done
105
106 # rebuilds environment
107 ldconfig -r "${P}" -f /etc/ld.so.conf -C /etc/ld.so.cache
108 [ -f ${P}/etc/profile ] && source ${P}/etc/profile
109
110 # cleanups
111 [ -d ${TMPDIR} ] && rm -rf ${TMPDIR}
112
113 echo -e "done.\n"

Properties

Name Value
svn:executable *