Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1568 - (hide annotations) (download) (as text)
Wed Dec 28 10:16:42 2011 UTC (12 years, 4 months ago) by niro
File MIME type: application/x-sh
File size: 2684 byte(s)
-use MROOT directly instead of P alias
1 niro 1565 #!/bin/bash
2     # $Id$
3 niro 24 #
4     # rebuilds /etc/{ld.so.conf,profile.env} with given files from /etc/env.d
5     #
6    
7 niro 1567 SPECIALVARS="KDEDIRS PATH CLASSPATH LDPATH MANPATH INFODIR INFOPATH ROOTPATH"
8     SPECIALVARS+=" CONFIG_PROTECT CONFIG_PROTECT_MASK CONFIG_PROTECT_IGNORE"
9     SPECIALVARS+=" PRELINK_PATH PRELINK_PATH_MASK"
10     SPECIALVARS+=" OMF_DIR LIBGL_DRIVERS_PATH XDG_CONFIG_DIRS XDG_DATA_DIRS"
11    
12 niro 259 # secure tmp dir
13     if [ -x /bin/mktemp ]
14 niro 24 then
15 niro 259 TMPDIR="$(/bin/mktemp -d -p /var/tmp)"
16     else
17     TMPDIR="/var/tmp/tmp.$$"
18 niro 285 install -d ${TMPDIR}
19 niro 24 fi
20    
21 niro 259 echo -en "\n>>>> Rebuilding environment... "
22 niro 24
23 niro 259 # clean existing conf files
24 niro 1568 :> ${MROOT}/etc/ld.so.conf
25     :> ${MROOT}/etc/profile.env
26 niro 259
27 niro 223 # gets everything in /etc/env.d
28 niro 1568 for file in ${MROOT}/etc/env.d/*
29 niro 24 do
30 niro 259 # abort if "empty"
31 niro 1568 [[ ${file} = ${MROOT}/etc/env.d/\* ]] && continue
32 niro 259
33 niro 223 # reads content of every file
34 niro 24 while read path
35     do
36 niro 1272 # ignore if empty or a comment
37 niro 456 case "${path}" in
38     \#*|"") continue ;;
39     esac
40 niro 259
41     # writes LDPATH to ${P}/etc/ld.so.conf,
42     # anything else to ${P}/etc/profile.env
43     if [[ ${path%%=*} = LDPATH ]]
44 niro 24 then
45 niro 259 #substitudes " from $path if exists
46     path="${path//\"}" #}" <--- make code readable again :)
47 niro 1568 echo "${path##*=}" >> ${MROOT}/etc/ld.so.conf
48 niro 259 else
49     # checks if var exists in specialvars
50     for i in ${SPECIALVARS}
51     do
52     [[ ${path%%=*} = ${i} ]] && SPECVAR="yes"
53     done
54    
55     if [[ ${SPECVAR} = yes ]]
56 niro 24 then
57 niro 1272 case ${path%%=*} in
58     CONFIG_PROTECT*|XDG*)
59     # CONFIG_PROTECT*|XDG* have as delimiter not ':' but ' '
60     path="${path//\"}" #}" <--- make code readable again :)
61     echo -n "${path##*=} " >> ${TMPDIR}/${path%%=*}
62     unset SPECVAR
63     ;;
64     *)
65     # special var are written to tmpfile
66     # to substitude them to one variable
67     # substitudes " from $path if exists
68     path="${path//\"}" #}" <--- make code readable again :)
69     echo -n "${path##*=}:" >> ${TMPDIR}/${path%%=*}
70     unset SPECVAR
71     ;;
72     esac
73 niro 259 else
74     # all other vars go directly to /etc/profile.env
75 niro 1568 echo "export ${path}" >> ${MROOT}/etc/profile.env
76 niro 24 fi
77     fi
78     done << EOF
79 niro 223 $(cat ${file})
80 niro 24 EOF
81    
82     done
83    
84 niro 223 # reads special vars tmp files and writes them to /etc/profile.env
85     for i in ${SPECIALVARS}
86 niro 24 do
87 niro 259 if [ -f ${TMPDIR}/${i} ]
88 niro 24 then
89 niro 55 # only OMF_DIR goes to /etc/scrollkeeper.conf
90     if [[ ${i} = OMF_DIR ]]
91     then
92 niro 1568 echo "${i}=$(cat ${TMPDIR}/${i})" > ${MROOT}/etc/scrollkeeper.conf
93 niro 55 else
94 niro 1568 echo "export ${i}=\"$(cat ${TMPDIR}/${i})\"" >> ${MROOT}/etc/profile.env
95 niro 55 fi
96 niro 259 rm ${TMPDIR}/${i}
97 niro 24 fi
98     done
99    
100 niro 223 # rebuilds environment
101 niro 1568 ldconfig -r "${MROOT}" -f /etc/ld.so.conf -C /etc/ld.so.cache
102     [ -f ${MROOT}/etc/profile ] && source ${MROOT}/etc/profile
103 niro 24
104 niro 259 # cleanups
105     [ -d ${TMPDIR} ] && rm -rf ${TMPDIR}
106    
107 niro 24 echo -e "done.\n"

Properties

Name Value
svn:executable *