Annotation of /trunk/mage/usr/lib/mage/env-rebuild.sh
Parent Directory | Revision Log
Revision 285 -
(hide annotations)
(download)
(as text)
Thu Dec 1 12:37:47 2005 UTC (18 years, 9 months ago) by niro
File MIME type: application/x-sh
File size: 2821 byte(s)
Thu Dec 1 12:37:47 2005 UTC (18 years, 9 months ago) by niro
File MIME type: application/x-sh
File size: 2821 byte(s)
missed to create the tmp dir
1 | niro | 24 | #!/bin/sh |
2 | |||
3 | niro | 285 | # $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 | 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 | 259 | # 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 | niro | 24 | then |
53 | niro | 259 | #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 | niro | 24 | then |
65 | niro | 259 | if [[ ${path%%=*} = CONFIG_PROTECT ]] || [[ ${path%%=*} = CONFIG_PROTECT_MASK ]] |
66 | niro | 24 | then |
67 | niro | 259 | # CONFIG_PROTECTS has as delimiter not ':' but ' ' |
68 | path="${path//\"}" #}" <--- make code readable again :) | ||
69 | echo -n "${path##*=} " >> ${TMPDIR}/${path%%=*} | ||
70 | unset SPECVAR | ||
71 | niro | 24 | else |
72 | niro | 259 | # 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 | niro | 24 | fi |
79 | niro | 259 | else |
80 | # all other vars go directly to /etc/profile.env | ||
81 | echo "export ${path}" >> ${P}/etc/profile.env | ||
82 | niro | 24 | fi |
83 | fi | ||
84 | done << EOF | ||
85 | niro | 223 | $(cat ${file}) |
86 | niro | 24 | EOF |
87 | |||
88 | done | ||
89 | |||
90 | niro | 223 | # reads special vars tmp files and writes them to /etc/profile.env |
91 | for i in ${SPECIALVARS} | ||
92 | niro | 24 | do |
93 | niro | 259 | if [ -f ${TMPDIR}/${i} ] |
94 | niro | 24 | then |
95 | niro | 55 | # only OMF_DIR goes to /etc/scrollkeeper.conf |
96 | if [[ ${i} = OMF_DIR ]] | ||
97 | then | ||
98 | niro | 259 | echo "${i}=$(cat ${TMPDIR}/${i})" > ${P}/etc/scrollkeeper.conf |
99 | niro | 55 | else |
100 | niro | 259 | echo "export ${i}=\"$(cat ${TMPDIR}/${i})\"" >> ${P}/etc/profile.env |
101 | niro | 55 | fi |
102 | niro | 259 | rm ${TMPDIR}/${i} |
103 | niro | 24 | fi |
104 | done | ||
105 | |||
106 | niro | 223 | # rebuilds environment |
107 | ldconfig -r "${P}" -f /etc/ld.so.conf -C /etc/ld.so.cache | ||
108 | niro | 259 | [ -f ${P}/etc/profile ] && source ${P}/etc/profile |
109 | niro | 24 | |
110 | niro | 259 | # cleanups |
111 | [ -d ${TMPDIR} ] && rm -rf ${TMPDIR} | ||
112 | |||
113 | niro | 24 | echo -e "done.\n" |
Properties
Name | Value |
---|---|
svn:executable | * |