Contents of /trunk/mage/usr/lib/mage/env-rebuild.sh
Parent Directory | Revision Log
Revision 259 -
(show annotations)
(download)
(as text)
Tue Oct 4 15:07:47 2005 UTC (18 years, 11 months ago) by niro
File MIME type: application/x-sh
File size: 2797 byte(s)
Tue Oct 4 15:07:47 2005 UTC (18 years, 11 months ago) by niro
File MIME type: application/x-sh
File size: 2797 byte(s)
- "better" coding style - secure temp-dirs - fixed noisiness on bootstrap
1 | #!/bin/sh |
2 | |
3 | # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/env-rebuild.sh,v 1.9 2005-10-04 15:07: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 | fi |
29 | |
30 | echo -en "\n>>>> Rebuilding environment... " |
31 | |
32 | # clean existing conf files |
33 | :> ${P}/etc/ld.so.conf |
34 | :> ${P}/etc/profile.env |
35 | |
36 | # gets everything in /etc/env.d |
37 | for file in ${P}/etc/env.d/* |
38 | do |
39 | # abort if "empty" |
40 | [[ ${file} = ${P}/etc/env.d/* ]] && continue |
41 | |
42 | # reads content of every file |
43 | while read path |
44 | do |
45 | # abort if empty |
46 | [[ -z ${path} ]] && continue |
47 | |
48 | # writes LDPATH to ${P}/etc/ld.so.conf, |
49 | # anything else to ${P}/etc/profile.env |
50 | if [[ ${path%%=*} = LDPATH ]] |
51 | then |
52 | #substitudes " from $path if exists |
53 | path="${path//\"}" #}" <--- make code readable again :) |
54 | echo "${path##*=}" >> ${P}/etc/ld.so.conf |
55 | else |
56 | # checks if var exists in specialvars |
57 | for i in ${SPECIALVARS} |
58 | do |
59 | [[ ${path%%=*} = ${i} ]] && SPECVAR="yes" |
60 | done |
61 | |
62 | if [[ ${SPECVAR} = yes ]] |
63 | then |
64 | if [[ ${path%%=*} = CONFIG_PROTECT ]] || [[ ${path%%=*} = CONFIG_PROTECT_MASK ]] |
65 | then |
66 | # CONFIG_PROTECTS has as delimiter not ':' but ' ' |
67 | path="${path//\"}" #}" <--- make code readable again :) |
68 | echo -n "${path##*=} " >> ${TMPDIR}/${path%%=*} |
69 | unset SPECVAR |
70 | else |
71 | # special var are written to tmpfile |
72 | # to substitude them to one variable |
73 | # substitudes " from $path if exists |
74 | path="${path//\"}" #}" <--- make code readable again :) |
75 | echo -n "${path##*=}:" >> ${TMPDIR}/${path%%=*} |
76 | unset SPECVAR |
77 | fi |
78 | else |
79 | # all other vars go directly to /etc/profile.env |
80 | echo "export ${path}" >> ${P}/etc/profile.env |
81 | fi |
82 | fi |
83 | done << EOF |
84 | $(cat ${file}) |
85 | EOF |
86 | |
87 | done |
88 | |
89 | # reads special vars tmp files and writes them to /etc/profile.env |
90 | for i in ${SPECIALVARS} |
91 | do |
92 | if [ -f ${TMPDIR}/${i} ] |
93 | then |
94 | # only OMF_DIR goes to /etc/scrollkeeper.conf |
95 | if [[ ${i} = OMF_DIR ]] |
96 | then |
97 | echo "${i}=$(cat ${TMPDIR}/${i})" > ${P}/etc/scrollkeeper.conf |
98 | else |
99 | echo "export ${i}=\"$(cat ${TMPDIR}/${i})\"" >> ${P}/etc/profile.env |
100 | fi |
101 | rm ${TMPDIR}/${i} |
102 | fi |
103 | done |
104 | |
105 | # rebuilds environment |
106 | ldconfig -r "${P}" -f /etc/ld.so.conf -C /etc/ld.so.cache |
107 | [ -f ${P}/etc/profile ] && source ${P}/etc/profile |
108 | |
109 | # cleanups |
110 | [ -d ${TMPDIR} ] && rm -rf ${TMPDIR} |
111 | |
112 | echo -e "done.\n" |
Properties
Name | Value |
---|---|
svn:executable | * |