Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:executable *