aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanny van Dyk <kugelfang@gentoo.org>2006-03-01 22:55:03 +0000
committerDanny van Dyk <kugelfang@gentoo.org>2006-03-01 22:55:03 +0000
commit6f4e8d80ba33f95711ed451672093888373e224e (patch)
treee0610d856b7b2cf5d65a2787595e7a0058cff4d1
parentTag for release 1.0. (diff)
downloadeselect-6f4e8d80ba33f95711ed451672093888373e224e.tar.gz
eselect-6f4e8d80ba33f95711ed451672093888373e224e.tar.bz2
eselect-6f4e8d80ba33f95711ed451672093888373e224e.zip
2006-03-01 Danny van Dyk <kugelfang@gentoo.org>
* modules/env.eselect: Fixed bug #124472. env.eselect now uses a temporarly file, honours a symlinked profile.env and fixes permissions on the final profile.env. diffstat: modules/env.eselect | 36 ++++++++++++++++++++---------------- 1 files changed, 20 insertions(+), 16 deletions(-) svn path=/trunk/; revision=252
-rw-r--r--ChangeLog6
-rw-r--r--modules/env.eselect36
2 files changed, 26 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index bdbb8af..9144638 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
ChangeLog for eselect
+2006-03-01 Danny van Dyk <kugelfang@gentoo.org>
+
+ * modules/env.eselect: Fixed bug #124472. env.eselect now uses a
+ temporarly file, honours a symlinked profile.env and fixes
+ permissions on the final profile.env.
+
2006-02-09 Ciaran McCreesh <ciaranm@gentoo.org>
* Tagged 1.0 release.
diff --git a/modules/env.eselect b/modules/env.eselect
index 3e94f53..e05c685 100644
--- a/modules/env.eselect
+++ b/modules/env.eselect
@@ -26,12 +26,12 @@ LDPATH=""
# create_profile_env()
# Create profile.env file
create_profile_env() {
- local envfiles vars store items
+ local envfiles vars store items tmpprofile
envfiles=( ${ROOT}/etc/env.d/* )
- # Output to a new file first!
- ENVPROFILE=${ENVPROFILE}.new
- rm -f ${ENVPROFILE} &> /dev/null
+ # Blank the file first!
+ tmpprofile="$(mktemp ${ROOT}/tmp/profile.XXXXXX)"
+ [[ $? = 0 ]] || die "Couldn't create temporary file!"
# Parse all files in env.d
for envfile in ${envfiles[@]} ; do
@@ -53,7 +53,7 @@ create_profile_env() {
for var in ${vars} ; do
# Colon separated?...
if has ${var} ${PATH_CLASS} ; then
- store=$(load_config ${ENVPROFILE} ${var})
+ store=$(load_config ${tmpprofile} ${var})
if [[ -z ${store} ]] ; then
store=$(load_config ${envfile} ${var})
else
@@ -64,12 +64,12 @@ create_profile_env() {
store="${store}:${item}"
done
fi
- store_config ${ENVPROFILE} ${var} "${store#:}"
+ store_config ${tmpprofile} ${var} "${store#:}"
continue
fi
# ...everything else is space separated!
if has ${var} ${SPECIAL_CLASS} ; then
- store=( $(load_config ${ENVPROFILE} ${var}) )
+ store=( $(load_config ${tmpprofile} ${var}) )
if [[ -z ${store[@]} ]] ; then
store=( $(load_config ${envfile} ${var}) )
else
@@ -79,13 +79,13 @@ create_profile_env() {
store=( ${store[@]} ${item} )
done
fi
- store_config ${ENVPROFILE} ${var} "${store[@]}"
+ store_config ${tmpprofile} ${var} "${store[@]}"
continue
fi
[[ ${var} == LDPATH ]] && continue
# Ok, just a non-cummultative var.
store_config \
- ${ENVPROFILE} \
+ ${tmpprofile} \
${var} \
"$(load_config ${envfile} ${var})"
done
@@ -101,8 +101,11 @@ create_profile_env() {
done
# Move new file onto old one
- ENVPROFILE=${ENVPROFILE%%.new}
- mv ${ENVPROFILE}.new ${ENVPROFILE}
+ ENVPROFILE=$(readlink -q -f ${ENVPROFILE})
+ chmod g+r ${tmpprofile}
+ mv ${tmpprofile} ${ENVPROFILE} \
+ || die "Couldn't move ${tmpprofile} to ${ENVPROFILE}!\n
+ Original profile.env remains unchanged."
}
# create_ld_so_conf()
@@ -111,11 +114,12 @@ create_ld_so_conf() {
[[ -z ${LDPATH[@]} ]] && die -q 'No LDPATHs found in ${ROOT}/etc/env.d/*'
local str
- str="# ld.so.conf autogenerated by eselect\n# Make all changes to /etc/env.d files\n"
+ str="# ld.so.conf autogenerated by eselect\n"
+ str="${str}# Make all changes to /etc/env.d files\n"
for x in ${LDPATH[@]} ; do
str="${str}${x}\n"
done
- echo -e "${str}" > ${LDCONFIG}
+ echo -e "${str}" > $(readlink -q -f ${LDCONFIG})
}
# create_prelink_conf()
@@ -146,7 +150,7 @@ create_prelink_conf() {
for x in ${prelink_mask[@]} ; do
str="${str}-b ${x}\n"
done
- echo -e "${str}" > ${PRELINK}
+ echo -e "${str}" > $(readlink -q -f ${PRELINK})
}
# need_links()
@@ -207,11 +211,11 @@ do_update() {
sed -i \
-e "s/\"/'/g" \
-e 's/^\(.*=\)/export \1/' \
- ${ENVPROFILE}
+ $(readlink -q -f ${ENVPROFILE})
sed -i \
-e "s/\"/'/g" \
-e 's/^\(.*=\)/setenv \1/' \
- ${ENVPROFILE/.env/.csh}
+ $(readlink -q -f ${ENVPROFILE/.env/.csh})
}
# vim: ft=eselect