Contents of /trunk/mage/usr/lib/mage/env-rebuild.sh
Parent Directory | Revision Log
Revision 43 -
(show annotations)
(download)
(as text)
Mon Jan 10 01:59:03 2005 UTC (19 years, 8 months ago) by niro
File MIME type: application/x-sh
File size: 2202 byte(s)
Mon Jan 10 01:59:03 2005 UTC (19 years, 8 months ago) by niro
File MIME type: application/x-sh
File size: 2202 byte(s)
updated revision tags
1 | #!/bin/sh |
2 | |
3 | # version: 0.3.6-r11 |
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="" |
19 | SPECIALVARS="KDEDIRS PATH CLASSPATH LDPATH MANPATH INFODIR INFOPATH ROOTPATH CONFIG_PROTECT CONFIG_PROTECT_MASK PRELINK_PATH PRELINK_PATH_MASK" |
20 | #SPECIALVARS="KDEDIRS PATH LDPATH MANPATH INFODIR INFOPATH ROOTPATH CLASSPATH" |
21 | |
22 | echo -en "\n>>>> Rebuilding environment... " |
23 | |
24 | #deletes existing conf files |
25 | if [ -f ${P}/etc/ld.so.conf ] |
26 | then |
27 | rm ${P}/etc/ld.so.conf |
28 | fi |
29 | |
30 | if [ -f ${P}/etc/profile.env ] |
31 | then |
32 | rm ${P}/etc/profile.env |
33 | fi |
34 | |
35 | #gets everything in /etc/env.d |
36 | for file in ${P}/etc/env.d/* |
37 | do |
38 | #reads content of every file |
39 | while read path |
40 | do |
41 | if [ -n "$path" ] |
42 | then |
43 | #writes LDPATH to ${P}/etc/ld.so.conf, |
44 | #anything else to ${P}/etc/profile.env |
45 | if [ "${path%%=*}" == LDPATH ] |
46 | then |
47 | #substitudes " from $path if exists |
48 | path="${path//\"}" |
49 | echo "${path##*=}" >> ${P}/etc/ld.so.conf |
50 | else |
51 | #checks if var exists in specialvars |
52 | for i in $SPECIALVARS |
53 | do |
54 | if [ "${path%%=*}" == "$i" ] |
55 | then |
56 | SPECVAR="yes" |
57 | fi |
58 | done |
59 | |
60 | if [ "$SPECVAR" == "yes" ] |
61 | then |
62 | if [ "${path%%=*}" == "CONFIG_PROTECT" -o "${path%%=*}" == "CONFIG_PROTECT_MASK" ] |
63 | then |
64 | #CONFIG_PROTECTS has as delimiter not ':' but ' ' |
65 | path="${path//\"}" |
66 | echo -n "${path##*=} " >> /var/tmp/${path%%=*} |
67 | unset SPECVAR |
68 | else |
69 | #special var are written to tmpfile |
70 | # to substitude them to one variable |
71 | #substitudes " from $path if exists |
72 | path="${path//\"}" |
73 | echo -n "${path##*=}:" >> /var/tmp/${path%%=*} |
74 | unset SPECVAR |
75 | fi |
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 | fi |
82 | done << EOF |
83 | $(cat $file) |
84 | EOF |
85 | |
86 | done |
87 | |
88 | #reads special vars tmp files and writes them to /etc/profile.env |
89 | for i in $SPECIALVARS |
90 | do |
91 | if [ -f /var/tmp/${i} ] |
92 | then |
93 | echo "export ${i}=\"`cat /var/tmp/${i}`\"" >> ${P}/etc/profile.env |
94 | rm /var/tmp/${i} |
95 | fi |
96 | done |
97 | |
98 | #rebuilds environment |
99 | ldconfig |
100 | source ${P}/etc/profile |
101 | |
102 | echo -e "done.\n" |
Properties
Name | Value |
---|---|
svn:executable | * |