Magellan Linux

Annotation of /trunk/mage/usr/lib/mage/env-rebuild.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 259 - (hide annotations) (download) (as text)
Tue Oct 4 15:07:47 2005 UTC (18 years, 7 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 niro 24 #!/bin/sh
2    
3 niro 259 # $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 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 24 fi
29    
30 niro 259 echo -en "\n>>>> Rebuilding environment... "
31 niro 24
32 niro 259 # clean existing conf files
33     :> ${P}/etc/ld.so.conf
34     :> ${P}/etc/profile.env
35    
36 niro 223 # gets everything in /etc/env.d
37 niro 24 for file in ${P}/etc/env.d/*
38     do
39 niro 259 # abort if "empty"
40     [[ ${file} = ${P}/etc/env.d/* ]] && continue
41    
42 niro 223 # reads content of every file
43 niro 24 while read path
44     do
45 niro 259 # 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 niro 24 then
52 niro 259 #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 niro 24 then
64 niro 259 if [[ ${path%%=*} = CONFIG_PROTECT ]] || [[ ${path%%=*} = CONFIG_PROTECT_MASK ]]
65 niro 24 then
66 niro 259 # CONFIG_PROTECTS has as delimiter not ':' but ' '
67     path="${path//\"}" #}" <--- make code readable again :)
68     echo -n "${path##*=} " >> ${TMPDIR}/${path%%=*}
69     unset SPECVAR
70 niro 24 else
71 niro 259 # 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 niro 24 fi
78 niro 259 else
79     # all other vars go directly to /etc/profile.env
80     echo "export ${path}" >> ${P}/etc/profile.env
81 niro 24 fi
82     fi
83     done << EOF
84 niro 223 $(cat ${file})
85 niro 24 EOF
86    
87     done
88    
89 niro 223 # reads special vars tmp files and writes them to /etc/profile.env
90     for i in ${SPECIALVARS}
91 niro 24 do
92 niro 259 if [ -f ${TMPDIR}/${i} ]
93 niro 24 then
94 niro 55 # only OMF_DIR goes to /etc/scrollkeeper.conf
95     if [[ ${i} = OMF_DIR ]]
96     then
97 niro 259 echo "${i}=$(cat ${TMPDIR}/${i})" > ${P}/etc/scrollkeeper.conf
98 niro 55 else
99 niro 259 echo "export ${i}=\"$(cat ${TMPDIR}/${i})\"" >> ${P}/etc/profile.env
100 niro 55 fi
101 niro 259 rm ${TMPDIR}/${i}
102 niro 24 fi
103     done
104    
105 niro 223 # rebuilds environment
106     ldconfig -r "${P}" -f /etc/ld.so.conf -C /etc/ld.so.cache
107 niro 259 [ -f ${P}/etc/profile ] && source ${P}/etc/profile
108 niro 24
109 niro 259 # cleanups
110     [ -d ${TMPDIR} ] && rm -rf ${TMPDIR}
111    
112 niro 24 echo -e "done.\n"

Properties

Name Value
svn:executable *