Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 223 - (hide annotations) (download) (as text)
Fri Sep 9 16:34:35 2005 UTC (18 years, 8 months ago) by niro
File MIME type: application/x-sh
File size: 2648 byte(s)
added ${MROOT} support for upcoming mage-0.4.x

1 niro 24 #!/bin/sh
2    
3 niro 223 # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/env-rebuild.sh,v 1.8 2005-09-09 16:30:25 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     echo -en "\n>>>> Rebuilding environment... "
23    
24 niro 223 # deletes existing conf files
25 niro 24 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 niro 223 # gets everything in /etc/env.d
36 niro 24 for file in ${P}/etc/env.d/*
37     do
38 niro 223 # reads content of every file
39 niro 24 while read path
40     do
41 niro 223 if [ -n "${path}" ]
42 niro 24 then
43 niro 223 # writes LDPATH to ${P}/etc/ld.so.conf,
44     # anything else to ${P}/etc/profile.env
45     if [[ ${path%%=*} = LDPATH ]]
46 niro 24 then
47     #substitudes " from $path if exists
48 niro 223 path="${path//\"}" #}" <--- make code readable again :)
49 niro 24 echo "${path##*=}" >> ${P}/etc/ld.so.conf
50     else
51 niro 223 # checks if var exists in specialvars
52 niro 24 for i in $SPECIALVARS
53     do
54     if [ "${path%%=*}" == "$i" ]
55     then
56     SPECVAR="yes"
57     fi
58     done
59    
60 niro 223 if [[ ${SPECVAR} = yes ]]
61 niro 24 then
62 niro 223 if [[ ${path%%=*} = CONFIG_PROTECT ]] || [[ ${path%%=*} = CONFIG_PROTECT_MASK ]]
63 niro 24 then
64 niro 223 # CONFIG_PROTECTS has as delimiter not ':' but ' '
65     path="${path//\"}" #}" <--- make code readable again :)
66 niro 24 echo -n "${path##*=} " >> /var/tmp/${path%%=*}
67     unset SPECVAR
68     else
69 niro 223 # special var are written to tmpfile
70 niro 24 # to substitude them to one variable
71 niro 223 # substitudes " from $path if exists
72     path="${path//\"}" #}" <--- make code readable again :)
73 niro 24 echo -n "${path##*=}:" >> /var/tmp/${path%%=*}
74     unset SPECVAR
75     fi
76     else
77 niro 223 # all other vars go directly to /etc/profile.env
78 niro 24 echo "export $path" >> ${P}/etc/profile.env
79     fi
80     fi
81     fi
82     done << EOF
83 niro 223 $(cat ${file})
84 niro 24 EOF
85    
86     done
87    
88 niro 223 # reads special vars tmp files and writes them to /etc/profile.env
89     for i in ${SPECIALVARS}
90 niro 24 do
91     if [ -f /var/tmp/${i} ]
92     then
93 niro 55 # only OMF_DIR goes to /etc/scrollkeeper.conf
94     if [[ ${i} = OMF_DIR ]]
95     then
96     echo "${i}=`cat /var/tmp/${i}`" > ${P}/etc/scrollkeeper.conf
97     else
98     echo "export ${i}=\"`cat /var/tmp/${i}`\"" >> ${P}/etc/profile.env
99     fi
100 niro 24 rm /var/tmp/${i}
101     fi
102     done
103    
104 niro 223 # rebuilds environment
105     ldconfig -r "${P}" -f /etc/ld.so.conf -C /etc/ld.so.cache
106 niro 24 source ${P}/etc/profile
107    
108     echo -e "done.\n"

Properties

Name Value
svn:executable *