Magellan Linux

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

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

trunk/mage/usr/lib/mage/env-rebuild.sh revision 260 by niro, Tue Oct 4 15:24:33 2005 UTC branches/mage-next/src/env-rebuild.in revision 2549 by niro, Wed Jan 29 11:47:55 2014 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.10 2005-10-04 15:24:33 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 25  then Line 15  then
15   TMPDIR="$(/bin/mktemp -d -p /var/tmp)"   TMPDIR="$(/bin/mktemp -d -p /var/tmp)"
16  else  else
17   TMPDIR="/var/tmp/tmp.$$"   TMPDIR="/var/tmp/tmp.$$"
18     install -d ${TMPDIR}
19  fi  fi
20    
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  # read everything from /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 line
35   do   do
36   # abort if empty   # ignore if empty or a comment
37   [[ -z ${path} ]] && continue   case "${line}" in
38     \#*|"") continue ;;
39   # writes LDPATH to ${P}/etc/ld.so.conf,   esac
40   # anything else to ${P}/etc/profile.env  
41   if [[ ${path%%=*} = LDPATH ]]   variable="${line%%=*}"
42     value="${line##*=}"
43    
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##*=}" >> ${P}/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   if [[ ${path%%=*} = CONFIG_PROTECT ]] || [[ ${path%%=*} = CONFIG_PROTECT_MASK ]]   case ${variable} in
63   then   CONFIG_PROTECT*)
64   # CONFIG_PROTECTS has as delimiter  not ':'  but ' '   # CONFIG_PROTECT** have as delimiter  not ':'  but ' '
65   path="${path//\"}" #}" <--- make code readable again :)   echo -n "${value} " >> ${TMPDIR}/${variable}
66   echo -n "${path##*=} " >> ${TMPDIR}/${path%%=*}   unset SPECVAR
67   unset SPECVAR   ;;
68   else   *)
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}
72   path="${path//\"}" #}" <--- make code readable again :)   unset SPECVAR
73   echo -n "${path##*=}:" >> ${TMPDIR}/${path%%=*}   ;;
74   unset SPECVAR   esac
  fi  
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}" >> ${P}/etc/profile.env   echo "export ${line}" >> ${MROOT}/etc/profile.env
78   fi   fi
79   fi   fi
80   done << EOF   done << EOF
# Line 87  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})" > ${P}/etc/scrollkeeper.conf   echo "${variable}=$(< ${TMPDIR}/${variable})" > ${MROOT}/etc/scrollkeeper.conf
95   else   else
96   echo "export ${i}=\"$(cat ${TMPDIR}/${i})\"" >> ${P}/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    
102  # rebuilds environment  # rebuilds environment
103  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
104  [ -f ${P}/etc/profile ] && source ${P}/etc/profile  [ -f ${MROOT}/etc/profile ] && source ${MROOT}/etc/profile
105    
106  # cleanups  # cleanups
107  [ -d ${TMPDIR} ] && rm -rf ${TMPDIR}  [ -d ${TMPDIR} ] && rm -rf ${TMPDIR}

Legend:
Removed from v.260  
changed lines
  Added in v.2549