aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Müller <ulm@gentoo.org>2011-03-13 12:22:08 +0000
committerUlrich Müller <ulm@gentoo.org>2011-03-13 12:22:08 +0000
commit0525b9ee52646f826d7131e480feec54bcb551f6 (patch)
treed6801a474082fb7eb60cf08d34b02e3a56682ec3 /modules/profile.eselect
parentCoding style. (diff)
downloadeselect-0525b9ee52646f826d7131e480feec54bcb551f6.tar.gz
eselect-0525b9ee52646f826d7131e480feec54bcb551f6.tar.bz2
eselect-0525b9ee52646f826d7131e480feec54bcb551f6.zip
profile.eselect: Support make.profile in the /etc/portage directory.
svn path=/trunk/; revision=810
Diffstat (limited to 'modules/profile.eselect')
-rw-r--r--modules/profile.eselect48
1 files changed, 33 insertions, 15 deletions
diff --git a/modules/profile.eselect b/modules/profile.eselect
index c07ceed..f89a8ba 100644
--- a/modules/profile.eselect
+++ b/modules/profile.eselect
@@ -6,11 +6,27 @@
# This is a portage-only module.
inherit package-manager
-DESCRIPTION="Manage the /etc/make.profile symlink"
+DESCRIPTION="Manage the make.profile symlink"
MAINTAINER="eselect@gentoo.org"
SVN_DATE='$Date$'
VERSION=$(svn_date_to_version "${SVN_DATE}")
+# get location of make.profile symlink
+get_symlink_location() {
+ local oldloc=${EROOT%/}/etc/make.profile
+ local newloc=${EROOT%/}/etc/portage/make.profile
+
+ if [[ -e ${oldloc} ]]; then
+ MAKE_PROFILE=${oldloc}
+ if [[ -e ${newloc} ]]; then
+ write_warning_msg "Both ${oldloc} and ${newloc} exist."
+ write_warning_msg "Using ${MAKE_PROFILE} for now."
+ fi
+ else
+ MAKE_PROFILE=${newloc}
+ fi
+}
+
# get a list of valid profiles
find_targets() {
local arch p portdir=$1
@@ -28,7 +44,7 @@ find_targets() {
# remove make.profile symlink
remove_symlink() {
- rm "${EROOT}/etc/make.profile"
+ rm "${MAKE_PROFILE}"
}
# set the make.profile symlink
@@ -62,18 +78,18 @@ set_symlink() {
# we must call remove_symlink() here instead of calling
# it from do_set(), since if the link is removed, we
# cannot determine $ARCH in find_targets()
- if [[ -L ${EROOT}/etc/make.profile ]]; then
+ if [[ -L ${MAKE_PROFILE} ]]; then
remove_symlink \
- || die -q "Couldn't remove current make.profile symlink"
+ || die -q "Couldn't remove current ${MAKE_PROFILE} symlink"
fi
ln -s "$(relative_name \
- "${ROOT}${portdir}" "${EROOT}/etc")/profiles/${target}" \
- "${EROOT}/etc/make.profile"
+ "${ROOT}${portdir}" "${MAKE_PROFILE%/*}")/profiles/${target}" \
+ "${MAKE_PROFILE}"
# check if the resulting symlink is sane
- if [[ $(canonicalise "${EROOT}/etc/make.profile") \
+ if [[ $(canonicalise "${MAKE_PROFILE}") \
!= "$(canonicalise "${EROOT}")"/* ]]; then
write_warning_msg \
- "Strange path. Check ${EROOT}/etc/make.profile symlink"
+ "Strange path. Check ${MAKE_PROFILE} symlink"
fi
else
die -q "Target \"$1\" doesn't appear to be valid!"
@@ -87,9 +103,10 @@ describe_show() {
}
do_show() {
- write_list_start "Current make.profile symlink:"
- if [[ -L ${EROOT}/etc/make.profile ]]; then
- local link=$(canonicalise "${EROOT}/etc/make.profile")
+ get_symlink_location
+ write_list_start "Current ${MAKE_PROFILE} symlink:"
+ if [[ -L ${MAKE_PROFILE} ]]; then
+ local link=$(canonicalise "${MAKE_PROFILE}")
local portdir=$(portageq portdir)
local profiledir=$(canonicalise "${ROOT}${portdir}/profiles")
link=${link##${profiledir}/}
@@ -111,9 +128,10 @@ do_list() {
[[ -z ${targets} ]] && die -q "Failed to get a list of valid profiles"
+ get_symlink_location
portdir=$(portageq portdir)
profiledir=$(canonicalise "${ROOT}${portdir}/profiles")
- active=$(canonicalise "${EROOT}/etc/make.profile")
+ active=$(canonicalise "${MAKE_PROFILE}")
active=${active##${profiledir}/}
if [[ -n ${targets[@]} ]]; then
local i
@@ -151,9 +169,9 @@ do_set() {
[[ -z $1 ]] && die -q "You didn't tell me what to set the symlink to"
[[ $# -gt 1 ]] && die -q "Too many parameters"
- if [[ -e ${EROOT}/etc/make.profile ]] &&
- [[ ! -L ${EROOT}/etc/make.profile ]]; then
- die -q "${EROOT}/etc/make.profile isn't a symlink"
+ get_symlink_location
+ if [[ -e ${MAKE_PROFILE} ]] && [[ ! -L ${MAKE_PROFILE} ]]; then
+ die -q "${MAKE_PROFILE} exists but is not a symlink"
else
set_symlink "$1" ${force} || die -q "Couldn't set a new symlink"
fi