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