Magellan Linux

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

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

revision 456 by niro, Sun Apr 1 01:26:34 2007 UTC revision 1568 by niro, Wed Dec 28 10:16:42 2011 UTC
# Line 1  Line 1 
1  #!/bin/sh  #!/bin/bash
2    # $Id$
 # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/env-rebuild.sh,v 1.12 2007-04-01 01:26:34 niro Exp $  
3  #  #
4  # 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
5  #  #
6    
7  ##  SPECIALVARS="KDEDIRS PATH CLASSPATH LDPATH MANPATH INFODIR INFOPATH ROOTPATH"
8  # exp. /etc/env.d/kde  SPECIALVARS+=" CONFIG_PROTECT CONFIG_PROTECT_MASK CONFIG_PROTECT_IGNORE"
9  #  SPECIALVARS+=" PRELINK_PATH PRELINK_PATH_MASK"
10  # PATH="/opt/kde/bin"  SPECIALVARS+=" OMF_DIR LIBGL_DRIVERS_PATH XDG_CONFIG_DIRS XDG_DATA_DIRS"
 # ROOTPATH="/opt/kde/bin"  
 # LDPATH="/opt/kde/lib"  
 #  
 ##  
   
 # sets root path  
 P="${MROOT}"  
 SPECIALVARS="KDEDIRS PATH CLASSPATH LDPATH MANPATH INFODIR INFOPATH ROOTPATH CONFIG_PROTECT CONFIG_PROTECT_MASK PRELINK_PATH PRELINK_PATH_MASK OMF_DIR"  
 #SPECIALVARS="KDEDIRS PATH LDPATH MANPATH INFODIR INFOPATH ROOTPATH CLASSPATH"  
11    
12  # secure tmp dir  # secure tmp dir
13  if [ -x /bin/mktemp ]  if [ -x /bin/mktemp ]
# Line 31  fi Line 21  fi
21  echo -en "\n>>>> Rebuilding environment... "  echo -en "\n>>>> Rebuilding environment... "
22    
23  # clean existing conf files  # clean existing conf files
24  :> ${P}/etc/ld.so.conf  :> ${MROOT}/etc/ld.so.conf
25  :> ${P}/etc/profile.env  :> ${MROOT}/etc/profile.env
26    
27  # gets everything in /etc/env.d  # gets everything in /etc/env.d
28  for file in ${P}/etc/env.d/*  for file in ${MROOT}/etc/env.d/*
29  do  do
30   # abort if "empty"   # abort if "empty"
31   [[ ${file} = ${P}/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 path
35   do   do
36   # abort if empty or an comment   # ignore if empty or a comment
37   case "${path}" in   case "${path}" in
38   \#*|"") continue ;;   \#*|"") continue ;;
39   esac   esac
# Line 54  do Line 44  do
44   then   then
45   #substitudes " from $path if exists   #substitudes " from $path if exists
46   path="${path//\"}" #}" <--- make code readable again :)   path="${path//\"}" #}" <--- make code readable again :)
47   echo "${path##*=}" >> ${P}/etc/ld.so.conf   echo "${path##*=}" >> ${MROOT}/etc/ld.so.conf
48   else   else
49   # checks if var exists in specialvars   # checks if var exists in specialvars
50   for i in ${SPECIALVARS}   for i in ${SPECIALVARS}
# Line 64  do Line 54  do
54    
55   if [[ ${SPECVAR} = yes ]]   if [[ ${SPECVAR} = yes ]]
56   then   then
57   if [[ ${path%%=*} = CONFIG_PROTECT ]] || [[ ${path%%=*} = CONFIG_PROTECT_MASK ]]   case ${path%%=*} in
58   then   CONFIG_PROTECT*|XDG*)
59   # CONFIG_PROTECTS has as delimiter  not ':'  but ' '   # CONFIG_PROTECT*|XDG* have as delimiter  not ':'  but ' '
60   path="${path//\"}" #}" <--- make code readable again :)   path="${path//\"}" #}" <--- make code readable again :)
61   echo -n "${path##*=} " >> ${TMPDIR}/${path%%=*}   echo -n "${path##*=} " >> ${TMPDIR}/${path%%=*}
62   unset SPECVAR   unset SPECVAR
63   else   ;;
64   # special var are written to tmpfile   *)
65   # to substitude them to one variable   # special var are written to tmpfile
66   # substitudes " from $path if exists   # to substitude them to one variable
67   path="${path//\"}" #}" <--- make code readable again :)   # substitudes " from $path if exists
68   echo -n "${path##*=}:" >> ${TMPDIR}/${path%%=*}   path="${path//\"}" #}" <--- make code readable again :)
69   unset SPECVAR   echo -n "${path##*=}:" >> ${TMPDIR}/${path%%=*}
70   fi   unset SPECVAR
71     ;;
72     esac
73   else   else
74   # all other vars go directly to /etc/profile.env   # all other vars go directly to /etc/profile.env
75   echo "export ${path}" >> ${P}/etc/profile.env   echo "export ${path}" >> ${MROOT}/etc/profile.env
76   fi   fi
77   fi   fi
78   done << EOF   done << EOF
# Line 97  do Line 89  do
89   # only OMF_DIR goes to /etc/scrollkeeper.conf   # only OMF_DIR goes to /etc/scrollkeeper.conf
90   if [[ ${i} = OMF_DIR ]]   if [[ ${i} = OMF_DIR ]]
91   then   then
92   echo "${i}=$(cat ${TMPDIR}/${i})" > ${P}/etc/scrollkeeper.conf   echo "${i}=$(cat ${TMPDIR}/${i})" > ${MROOT}/etc/scrollkeeper.conf
93   else   else
94   echo "export ${i}=\"$(cat ${TMPDIR}/${i})\"" >> ${P}/etc/profile.env   echo "export ${i}=\"$(cat ${TMPDIR}/${i})\"" >> ${MROOT}/etc/profile.env
95   fi   fi
96   rm ${TMPDIR}/${i}   rm ${TMPDIR}/${i}
97   fi   fi
98  done  done
99    
100  # rebuilds environment  # rebuilds environment
101  ldconfig -r "${P}" -f /etc/ld.so.conf -C /etc/ld.so.cache  ldconfig -r "${MROOT}" -f /etc/ld.so.conf -C /etc/ld.so.cache
102  [ -f ${P}/etc/profile ] && source ${P}/etc/profile  [ -f ${MROOT}/etc/profile ] && source ${MROOT}/etc/profile
103    
104  # cleanups  # cleanups
105  [ -d ${TMPDIR} ] && rm -rf ${TMPDIR}  [ -d ${TMPDIR} ] && rm -rf ${TMPDIR}

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