Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 222 by niro, Wed Jun 1 15:48:52 2005 UTC revision 223 by niro, Fri Sep 9 16:34:35 2005 UTC
# Line 1  Line 1 
1  #!/bin/sh  #!/bin/sh
2    
3  # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/env-rebuild.sh,v 1.7 2005-06-01 15:48:11 niro Exp $  # $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  #  #
5  # rebuilds /etc/{ld.so.conf,profile.env} with given files from /etc/env.d  # rebuilds /etc/{ld.so.conf,profile.env} with given files from /etc/env.d
6  #  #
# Line 14  Line 14 
14  #  #
15  ##  ##
16    
17  #sets root path  # sets root path
18  P=""  P="${MROOT}"
19  SPECIALVARS="KDEDIRS PATH CLASSPATH LDPATH MANPATH INFODIR INFOPATH ROOTPATH CONFIG_PROTECT CONFIG_PROTECT_MASK PRELINK_PATH PRELINK_PATH_MASK OMF_DIR"  SPECIALVARS="KDEDIRS PATH CLASSPATH LDPATH MANPATH INFODIR INFOPATH ROOTPATH CONFIG_PROTECT CONFIG_PROTECT_MASK PRELINK_PATH PRELINK_PATH_MASK OMF_DIR"
20  #SPECIALVARS="KDEDIRS PATH LDPATH MANPATH INFODIR INFOPATH ROOTPATH CLASSPATH"  #SPECIALVARS="KDEDIRS PATH LDPATH MANPATH INFODIR INFOPATH ROOTPATH CLASSPATH"
21    
22  echo -en "\n>>>> Rebuilding environment... "  echo -en "\n>>>> Rebuilding environment... "
23    
24  #deletes existing conf files  # deletes existing conf files
25  if [ -f ${P}/etc/ld.so.conf ]  if [ -f ${P}/etc/ld.so.conf ]
26  then  then
27   rm ${P}/etc/ld.so.conf   rm ${P}/etc/ld.so.conf
# Line 32  then Line 32  then
32   rm ${P}/etc/profile.env   rm ${P}/etc/profile.env
33  fi  fi
34    
35  #gets everything in /etc/env.d  # gets everything in /etc/env.d
36  for file in ${P}/etc/env.d/*  for file in ${P}/etc/env.d/*
37  do  do
38   #reads content of every file   # reads content of every file
39   while read path   while read path
40   do   do
41   if [ -n "$path" ]   if [ -n "${path}" ]
42   then   then
43   #writes LDPATH to ${P}/etc/ld.so.conf,   # writes LDPATH to ${P}/etc/ld.so.conf,
44   #anything else to ${P}/etc/profile.env   # anything else to ${P}/etc/profile.env
45   if [ "${path%%=*}" == LDPATH ]   if [[ ${path%%=*} = LDPATH ]]
46   then   then
47   #substitudes " from $path if exists   #substitudes " from $path if exists
48   path="${path//\"}"   path="${path//\"}" #}" <--- make code readable again :)
49   echo "${path##*=}" >> ${P}/etc/ld.so.conf   echo "${path##*=}" >> ${P}/etc/ld.so.conf
50   else   else
51   #checks if var exists in specialvars   # checks if var exists in specialvars
52   for i in $SPECIALVARS   for i in $SPECIALVARS
53   do   do
54   if [ "${path%%=*}" == "$i" ]   if [ "${path%%=*}" == "$i" ]
# Line 57  do Line 57  do
57   fi   fi
58   done   done
59    
60   if [ "$SPECVAR" == "yes" ]   if [[ ${SPECVAR} = yes ]]
61   then   then
62   if [ "${path%%=*}" == "CONFIG_PROTECT" -o "${path%%=*}" == "CONFIG_PROTECT_MASK" ]   if [[ ${path%%=*} = CONFIG_PROTECT ]] || [[ ${path%%=*} = CONFIG_PROTECT_MASK ]]
63   then   then
64   #CONFIG_PROTECTS has as delimiter  not ':'  but ' '   # CONFIG_PROTECTS has as delimiter  not ':'  but ' '
65   path="${path//\"}"   path="${path//\"}" #}" <--- make code readable again :)
66   echo -n "${path##*=} " >> /var/tmp/${path%%=*}   echo -n "${path##*=} " >> /var/tmp/${path%%=*}
67   unset SPECVAR   unset SPECVAR
68   else   else
69   #special var are written to tmpfile   # special var are written to tmpfile
70   # to substitude them to one variable   # to substitude them to one variable
71   #substitudes " from $path if exists   # substitudes " from $path if exists
72   path="${path//\"}"   path="${path//\"}" #}" <--- make code readable again :)
73   echo -n "${path##*=}:" >> /var/tmp/${path%%=*}   echo -n "${path##*=}:" >> /var/tmp/${path%%=*}
74   unset SPECVAR   unset SPECVAR
75   fi   fi
76   else   else
77   #all other vars go directly to /etc/profile.env   # all other vars go directly to /etc/profile.env
78   echo "export $path" >> ${P}/etc/profile.env   echo "export $path" >> ${P}/etc/profile.env
79   fi   fi
80   fi   fi
81   fi   fi
82   done << EOF   done << EOF
83  $(cat $file)  $(cat ${file})
84  EOF  EOF
85    
86  done  done
87    
88  #reads special vars tmp files and writes them to /etc/profile.env  # reads special vars tmp files and writes them to /etc/profile.env
89  for i in $SPECIALVARS  for i in ${SPECIALVARS}
90  do  do
91   if [ -f /var/tmp/${i} ]   if [ -f /var/tmp/${i} ]
92   then   then
# Line 101  do Line 101  do
101   fi   fi
102  done  done
103    
104  #rebuilds environment  # rebuilds environment
105  ldconfig  ldconfig -r "${P}" -f /etc/ld.so.conf -C /etc/ld.so.cache
106  source ${P}/etc/profile  source ${P}/etc/profile
107    
108  echo -e "done.\n"  echo -e "done.\n"

Legend:
Removed from v.222  
changed lines
  Added in v.223