Magellan Linux

Diff of /branches/mage-next/src/env-rebuild.sh

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

trunk/mage/usr/lib/mage/env-rebuild.sh revision 1568 by niro, Wed Dec 28 10:16:42 2011 UTC branches/mage-next/usr/lib/mage/env-rebuild.sh revision 2525 by niro, Wed Jan 29 10:42:21 2014 UTC
# Line 24  echo -en "\n>>>> Rebuilding environment. Line 24  echo -en "\n>>>> Rebuilding environment.
24  :> ${MROOT}/etc/ld.so.conf  :> ${MROOT}/etc/ld.so.conf
25  :> ${MROOT}/etc/profile.env  :> ${MROOT}/etc/profile.env
26    
27  # gets everything in /etc/env.d  # read everything from /etc/env.d
28  for file in ${MROOT}/etc/env.d/*  for file in ${MROOT}/etc/env.d/*
29  do  do
30   # abort if "empty"   # abort if "empty"
31   [[ ${file} = ${MROOT}/etc/env.d/\* ]] && continue   [[ ${file} = ${MROOT}/etc/env.d/\* ]] && continue
32    
33   # reads content of every file   # reads content of every file
34   while read path   while read line
35   do   do
36   # ignore if empty or a comment   # ignore if empty or a comment
37   case "${path}" in   case "${line}" in
38   \#*|"") continue ;;   \#*|"") continue ;;
39   esac   esac
40    
41   # writes LDPATH to ${P}/etc/ld.so.conf,   variable="${line%%=*}"
42   # anything else to ${P}/etc/profile.env   value="${line##*=}"
43   if [[ ${path%%=*} = LDPATH ]]  
44     # substitudes " or ' from $value if exists
45     value="${value//\"}" #}" <--- make code readable again :)
46     value="${value//\'}"
47    
48     # writes LDPATH to ${MROOT}/etc/ld.so.conf,
49     # anything else to ${MROOT}/etc/profile.env
50     if [[ ${variable} = LDPATH ]]
51   then   then
52   #substitudes " from $path if exists   echo "${value}" >> ${MROOT}/etc/ld.so.conf
  path="${path//\"}" #}" <--- make code readable again :)  
  echo "${path##*=}" >> ${MROOT}/etc/ld.so.conf  
53   else   else
54   # checks if var exists in specialvars   # checks if var exists in specialvars
55   for i in ${SPECIALVARS}   for i in ${SPECIALVARS}
56   do   do
57   [[ ${path%%=*} = ${i} ]] && SPECVAR="yes"   [[ ${variable} = ${i} ]] && SPECVAR="yes"
58   done   done
59    
60   if [[ ${SPECVAR} = yes ]]   if [[ ${SPECVAR} = yes ]]
61   then   then
62   case ${path%%=*} in   case ${variable} in
63   CONFIG_PROTECT*|XDG*)   CONFIG_PROTECT*)
64   # CONFIG_PROTECT*|XDG* have as delimiter  not ':'  but ' '   # CONFIG_PROTECT** have as delimiter  not ':'  but ' '
65   path="${path//\"}" #}" <--- make code readable again :)   echo -n "${value} " >> ${TMPDIR}/${variable}
  echo -n "${path##*=} " >> ${TMPDIR}/${path%%=*}  
66   unset SPECVAR   unset SPECVAR
67   ;;   ;;
68   *)   *)
69   # special var are written to tmpfile   # special vars are written to tmpfile
70   # to substitude them to one variable   # to substitude them to one variable
71   # substitudes " from $path if exists   echo -n "${value}:" >> ${TMPDIR}/${variable}
  path="${path//\"}" #}" <--- make code readable again :)  
  echo -n "${path##*=}:" >> ${TMPDIR}/${path%%=*}  
72   unset SPECVAR   unset SPECVAR
73   ;;   ;;
74   esac   esac
75   else   else
76   # all other vars go directly to /etc/profile.env   # all other vars go directly to /etc/profile.env
77   echo "export ${path}" >> ${MROOT}/etc/profile.env   echo "export ${line}" >> ${MROOT}/etc/profile.env
78   fi   fi
79   fi   fi
80   done << EOF   done << EOF
# Line 82  EOF Line 84  EOF
84  done  done
85    
86  # reads special vars tmp files and writes them to /etc/profile.env  # reads special vars tmp files and writes them to /etc/profile.env
87  for i in ${SPECIALVARS}  for variable in ${SPECIALVARS}
88  do  do
89   if [ -f ${TMPDIR}/${i} ]   if [ -f ${TMPDIR}/${variable} ]
90   then   then
91   # only OMF_DIR goes to /etc/scrollkeeper.conf   # only OMF_DIR goes to /etc/scrollkeeper.conf
92   if [[ ${i} = OMF_DIR ]]   if [[ ${variable} = OMF_DIR ]]
93   then   then
94   echo "${i}=$(cat ${TMPDIR}/${i})" > ${MROOT}/etc/scrollkeeper.conf   echo "${variable}=$(< ${TMPDIR}/${variable})" > ${MROOT}/etc/scrollkeeper.conf
95   else   else
96   echo "export ${i}=\"$(cat ${TMPDIR}/${i})\"" >> ${MROOT}/etc/profile.env   echo "export ${variable}=\"$(< ${TMPDIR}/${variable})\"" >> ${MROOT}/etc/profile.env
97   fi   fi
98   rm ${TMPDIR}/${i}   rm ${TMPDIR}/${variable}
99   fi   fi
100  done  done
101    

Legend:
Removed from v.1568  
changed lines
  Added in v.2525