1 |
#!/bin/bash |
#!/bin/bash |
2 |
# $Id$ |
# $Id$ |
3 |
# |
# |
4 |
# rebuilds /etc/{ld.so.conf,profile.env} with given files from /etc/env.d |
# rebuilds @@SYSCONFDIR@@/{ld.so.conf,profile.env} with given files from @@ENVDDIR@@ |
5 |
# |
# |
6 |
|
|
7 |
SPECIALVARS="KDEDIRS PATH CLASSPATH LDPATH MANPATH INFODIR INFOPATH ROOTPATH" |
SPECIALVARS="KDEDIRS PATH CLASSPATH LDPATH MANPATH INFODIR INFOPATH ROOTPATH" |
21 |
echo -en "\n>>>> Rebuilding environment... " |
echo -en "\n>>>> Rebuilding environment... " |
22 |
|
|
23 |
# clean existing conf files |
# clean existing conf files |
24 |
:> ${MROOT}/etc/ld.so.conf |
:> ${MROOT}@@SYSCONFDIR@@/ld.so.conf |
25 |
:> ${MROOT}/etc/profile.env |
:> ${MROOT}@@SYSCONFDIR@@/profile.env |
26 |
|
|
27 |
# read everything from /etc/env.d |
# read everything from @@ENDDIR@@ |
28 |
for file in ${MROOT}/etc/env.d/* |
for file in ${MROOT}@@ENVDDIR@@/* |
29 |
do |
do |
30 |
# abort if "empty" |
# abort if "empty" |
31 |
[[ ${file} = ${MROOT}/etc/env.d/\* ]] && continue |
[[ ${file} = ${MROOT}@@ENVDDIR@@/\* ]] && continue |
32 |
|
|
33 |
# reads content of every file |
# reads content of every file |
34 |
while read line |
while read line |
45 |
value="${value//\"}" #}" <--- make code readable again :) |
value="${value//\"}" #}" <--- make code readable again :) |
46 |
value="${value//\'}" |
value="${value//\'}" |
47 |
|
|
48 |
# writes LDPATH to ${MROOT}/etc/ld.so.conf, |
# writes LDPATH to ${MROOT}@@SYSCONFDIR@@/ld.so.conf, |
49 |
# anything else to ${MROOT}/etc/profile.env |
# anything else to ${MROOT}@@SYSCONFDIR@@/profile.env |
50 |
if [[ ${variable} = LDPATH ]] |
if [[ ${variable} = LDPATH ]] |
51 |
then |
then |
52 |
echo "${value}" >> ${MROOT}/etc/ld.so.conf |
echo "${value}" >> ${MROOT}@@SYSCONFDIR@@/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} |
60 |
if [[ ${SPECVAR} = yes ]] |
if [[ ${SPECVAR} = yes ]] |
61 |
then |
then |
62 |
case ${variable} in |
case ${variable} in |
63 |
CONFIG_PROTECT*|XDG*) |
CONFIG_PROTECT*) |
64 |
# CONFIG_PROTECT*|XDG* have as delimiter not ':' but ' ' |
# CONFIG_PROTECT** have as delimiter not ':' but ' ' |
65 |
echo -n "${value} " >> ${TMPDIR}/${variable} |
echo -n "${value} " >> ${TMPDIR}/${variable} |
66 |
unset SPECVAR |
unset SPECVAR |
67 |
;; |
;; |
100 |
done |
done |
101 |
|
|
102 |
# rebuilds environment |
# rebuilds environment |
103 |
ldconfig -r "${MROOT}" -f /etc/ld.so.conf -C /etc/ld.so.cache |
ldconfig -r "${MROOT}" -f @@SYSCONFDIR@@/ld.so.conf -C @@SYSCONFDIR@@/ld.so.cache |
104 |
[ -f ${MROOT}/etc/profile ] && source ${MROOT}/etc/profile |
[ -f ${MROOT}@@SYSCONFDIR@@/profile ] && source ${MROOT}@@SYSCONFDIR@@/profile |
105 |
|
|
106 |
# cleanups |
# cleanups |
107 |
[ -d ${TMPDIR} ] && rm -rf ${TMPDIR} |
[ -d ${TMPDIR} ] && rm -rf ${TMPDIR} |