Contents of /branches/mage-next/src/env-rebuild.in
Parent Directory | Revision Log
Revision 1567 -
(show annotations)
(download)
(as text)
Wed Dec 28 10:13:52 2011 UTC (12 years, 8 months ago) by niro
Original Path: trunk/mage/usr/lib/mage/env-rebuild.sh
File MIME type: application/x-sh
File size: 2671 byte(s)
Wed Dec 28 10:13:52 2011 UTC (12 years, 8 months ago) by niro
Original Path: trunk/mage/usr/lib/mage/env-rebuild.sh
File MIME type: application/x-sh
File size: 2671 byte(s)
-make SPECIALVARS more readable
1 | #!/bin/bash |
2 | # $Id$ |
3 | # |
4 | # rebuilds /etc/{ld.so.conf,profile.env} with given files from /etc/env.d |
5 | # |
6 | |
7 | # sets root path |
8 | P="${MROOT}" |
9 | |
10 | 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 |
16 | if [ -x /bin/mktemp ] |
17 | then |
18 | TMPDIR="$(/bin/mktemp -d -p /var/tmp)" |
19 | else |
20 | TMPDIR="/var/tmp/tmp.$$" |
21 | install -d ${TMPDIR} |
22 | fi |
23 | |
24 | echo -en "\n>>>> Rebuilding environment... " |
25 | |
26 | # clean existing conf files |
27 | :> ${P}/etc/ld.so.conf |
28 | :> ${P}/etc/profile.env |
29 | |
30 | # gets everything in /etc/env.d |
31 | for file in ${P}/etc/env.d/* |
32 | do |
33 | # abort if "empty" |
34 | [[ ${file} = ${P}/etc/env.d/\* ]] && continue |
35 | |
36 | # reads content of every file |
37 | while read path |
38 | do |
39 | # ignore if empty or a comment |
40 | case "${path}" in |
41 | \#*|"") continue ;; |
42 | esac |
43 | |
44 | # writes LDPATH to ${P}/etc/ld.so.conf, |
45 | # anything else to ${P}/etc/profile.env |
46 | if [[ ${path%%=*} = LDPATH ]] |
47 | then |
48 | #substitudes " from $path if exists |
49 | path="${path//\"}" #}" <--- make code readable again :) |
50 | echo "${path##*=}" >> ${P}/etc/ld.so.conf |
51 | else |
52 | # checks if var exists in specialvars |
53 | for i in ${SPECIALVARS} |
54 | do |
55 | [[ ${path%%=*} = ${i} ]] && SPECVAR="yes" |
56 | done |
57 | |
58 | if [[ ${SPECVAR} = yes ]] |
59 | then |
60 | case ${path%%=*} in |
61 | CONFIG_PROTECT*|XDG*) |
62 | # CONFIG_PROTECT*|XDG* have as delimiter not ':' but ' ' |
63 | path="${path//\"}" #}" <--- make code readable again :) |
64 | echo -n "${path##*=} " >> ${TMPDIR}/${path%%=*} |
65 | unset SPECVAR |
66 | ;; |
67 | *) |
68 | # special var are written to tmpfile |
69 | # to substitude them to one variable |
70 | # substitudes " from $path if exists |
71 | path="${path//\"}" #}" <--- make code readable again :) |
72 | echo -n "${path##*=}:" >> ${TMPDIR}/${path%%=*} |
73 | unset SPECVAR |
74 | ;; |
75 | esac |
76 | else |
77 | # all other vars go directly to /etc/profile.env |
78 | echo "export ${path}" >> ${P}/etc/profile.env |
79 | fi |
80 | fi |
81 | done << EOF |
82 | $(cat ${file}) |
83 | EOF |
84 | |
85 | done |
86 | |
87 | # reads special vars tmp files and writes them to /etc/profile.env |
88 | for i in ${SPECIALVARS} |
89 | do |
90 | if [ -f ${TMPDIR}/${i} ] |
91 | then |
92 | # only OMF_DIR goes to /etc/scrollkeeper.conf |
93 | if [[ ${i} = OMF_DIR ]] |
94 | then |
95 | echo "${i}=$(cat ${TMPDIR}/${i})" > ${P}/etc/scrollkeeper.conf |
96 | else |
97 | echo "export ${i}=\"$(cat ${TMPDIR}/${i})\"" >> ${P}/etc/profile.env |
98 | fi |
99 | rm ${TMPDIR}/${i} |
100 | fi |
101 | done |
102 | |
103 | # rebuilds environment |
104 | ldconfig -r "${P}" -f /etc/ld.so.conf -C /etc/ld.so.cache |
105 | [ -f ${P}/etc/profile ] && source ${P}/etc/profile |
106 | |
107 | # cleanups |
108 | [ -d ${TMPDIR} ] && rm -rf ${TMPDIR} |
109 | |
110 | echo -e "done.\n" |
Properties
Name | Value |
---|---|
svn:executable | * |