eselect profile list - works eselect profile show - b0rkened, shows /etc/make.profile eselect profile set X - b0rkened, fscks up entire system by creating a totally b0rkened symlink e.g. /net/pegasus.ins.cwi.nl/export/scratch/stripe/fabian/gentoo/prefix64/etc/make.profile -> ../export/scratch/stripe/fabian/gentoo/prefix-rsync/profiles/prefix/sunos/solaris/5.11/x64 this is a problem since Portage will soon start to suggest to use eselect profile
> eselect profile list - works Good. :-) > eselect profile show - b0rkened, shows /etc/make.profile Does it work if you change do_show() as follows? - local link=$(canonicalise "${ROOT}/etc/make.profile") + local link=$(canonicalise "${EROOT}/etc/make.profile") > eselect profile set X - b0rkened, fscks up entire system by creating a totally > b0rkened symlink e.g. > /net/pegasus.ins.cwi.nl/export/scratch/stripe/fabian/gentoo/prefix64/etc/make.profile > -> > ../export/scratch/stripe/fabian/gentoo/prefix-rsync/profiles/prefix/sunos/solaris/5.11/x64 This line in set_symlink() looks suspicious: ln -s "..${portdir#"${EPREFIX}"}/profiles/${target}" \ "${EROOT}/etc/make.profile" Probably I've got something wrong when adapting it from your patch that is attached to bug 274760. What are the values of "${EPREFIX}", "${EROOT}", and "$(portageq portdir)"?
(In reply to comment #1) > > eselect profile show - b0rkened, shows /etc/make.profile > > Does it work if you change do_show() as follows? > > - local link=$(canonicalise "${ROOT}/etc/make.profile") > + local link=$(canonicalise "${EROOT}/etc/make.profile") > that makes it work (obvious fix, thx) > > eselect profile set X - b0rkened, fscks up entire system by creating a totally > > b0rkened symlink e.g. > > /net/pegasus.ins.cwi.nl/export/scratch/stripe/fabian/gentoo/prefix64/etc/make.profile > > -> > > ../export/scratch/stripe/fabian/gentoo/prefix-rsync/profiles/prefix/sunos/solaris/5.11/x64 > > This line in set_symlink() looks suspicious: > > ln -s "..${portdir#"${EPREFIX}"}/profiles/${target}" \ > "${EROOT}/etc/make.profile" > > Probably I've got something wrong when adapting it from your patch that is > attached to bug 274760. > > What are the values of "${EPREFIX}", "${EROOT}", and "$(portageq portdir)"? (pegasus:portage-svn/dev-lang/python) fabian% portageq portdir /export/scratch/stripe/fabian/gentoo/prefix-rsync (pegasus:portage-svn/dev-lang/python) fabian% portageq envvar EPREFIX EROOT /export/scratch/stripe/fabian/gentoo/prefix64 /export/scratch/stripe/fabian/gentoo/prefix64/
> > This line in set_symlink() looks suspicious: > > > > ln -s "..${portdir#"${EPREFIX}"}/profiles/${target}" \ > > "${EROOT}/etc/make.profile" > > (pegasus:portage-svn/dev-lang/python) fabian% portageq portdir > /export/scratch/stripe/fabian/gentoo/prefix-rsync > (pegasus:portage-svn/dev-lang/python) fabian% portageq envvar EPREFIX EROOT > /export/scratch/stripe/fabian/gentoo/prefix64 > /export/scratch/stripe/fabian/gentoo/prefix64/ Seems I had assumed for some reason that portdir must share a common prefix with EPREFIX ... Crude fix (only to make sure where the problem is), does it work if you replace above-mentioned ln command by the following? ln -s "${portdir}/profiles/${target}" "${EROOT}/etc/make.profile"
(In reply to comment #3) > > > This line in set_symlink() looks suspicious: > > > > > > ln -s "..${portdir#"${EPREFIX}"}/profiles/${target}" \ > > > "${EROOT}/etc/make.profile" > > > > (pegasus:portage-svn/dev-lang/python) fabian% portageq portdir > > /export/scratch/stripe/fabian/gentoo/prefix-rsync > > (pegasus:portage-svn/dev-lang/python) fabian% portageq envvar EPREFIX EROOT > > /export/scratch/stripe/fabian/gentoo/prefix64 > > /export/scratch/stripe/fabian/gentoo/prefix64/ > > Seems I had assumed for some reason that portdir must share a common prefix > with EPREFIX ... actually, that is true in a normal case, but since you dereferenced all symlinks you found out where I really store *my precious*... > Crude fix (only to make sure where the problem is), does it work if you replace > above-mentioned ln command by the following? > > ln -s "${portdir}/profiles/${target}" "${EROOT}/etc/make.profile" This will make an absolute symlink. I think the problem is however Prefix specific, as I just have either set PORTDIR, or made a symlink somewhere outside of the EPREFIX, which means you cannot relatively resolve back to the root, and go from there to the new path.
I've committed the fix for do_show to the eselect SVN repo (r680). About the other problem, please tell me when there's anything to do for eselect "upstream".
Ulrich, this would do: --- /var/tmp/profile.eselect 2009-10-05 20:09:11 +0200 +++ /Library/Gentoo/usr/share/eselect/modules/profile.eselect 2009-10-05 20:27:06 +0200 @@ -67,8 +67,24 @@ remove_symlink \ || die -q "Couldn't remove current make.profile symlink" fi - ln -s "..${portdir#"${EPREFIX}"}/profiles/${target}" \ - "${EROOT}/etc/make.profile" + # we want to make a relative symlink in etc/ (why?) + # because in Prefix portdir can be "under" the EPREFIX, we + # need to calculate how many levels we need to traverse back + local profile=${portdir}/profiles/${target} + local etcmake=${EROOT}/etc/make.profile + # strip off the common part of both + while [[ ${profile%%/*} == ${etcmake%%/*} ]] ; do + profile=${profile#*/} + etcmake=${etcmake#*/} + done + # generate the path back + while [[ ${etcmake} == */* ]] ; do + etcmake=${etcmake#*/} + profile=../${profile} + done + pushd "${EROOT}"/etc > /dev/null || die -q "Couldn't move to ${EROOT}/etc" + ln -s "${profile}" make.profile || die -q "Couldn't make symlink" + popd > /dev/null else die -q "Target \"${1}\" doesn't appear to be valid!" fi @@ -83,7 +99,7 @@ do_show() { write_list_start "Current make.profile symlink:" if [[ -L ${EROOT}/etc/make.profile ]] ; then - local link=$(canonicalise "${ROOT}/etc/make.profile") + local link=$(canonicalise "${EROOT}/etc/make.profile") local portdir=$(portageq portdir) local profiledir=$(canonicalise "${ROOT}${portdir}/profiles") link=${link##${profiledir}/} [tefnut:/Library/Gentoo/etc] ruurd%
Created attachment 206218 [details, diff] eselect-1.2.3-relative-symlink.patch Does attached patch fix the problem?
That patch works as expected I'd say. It creates a wrong symlink (to an internal automounter path) but it can't help doing that, as that's what the path resolves to eventually. However, this is pretty uncommon, and I'd say that eselect does the best efforts it can to create a valid symlink. if the patch is added to 1.2.4 then I think we can resolve this bug.
1.2.4 was released with the fix. Converted Prefix users to use gx86 ebuild directly. Thanks for the fix Ulrich!