Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:executable *