Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 287730 - eselect profile is b0rkened
Summary: eselect profile is b0rkened
Status: RESOLVED FIXED
Alias: None
Product: Gentoo/Alt
Classification: Unclassified
Component: Prefix Support (show other bugs)
Hardware: All Other
: High normal
Assignee: Gentoo Prefix
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-05 09:07 UTC by Fabian Groffen
Modified: 2009-10-09 15:55 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
eselect-1.2.3-relative-symlink.patch (eselect-1.2.3-relative-symlink.patch,1.30 KB, patch)
2009-10-06 06:34 UTC, Ulrich Müller
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Fabian Groffen gentoo-dev 2009-10-05 09:07:12 UTC
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
Comment 1 Ulrich Müller gentoo-dev 2009-10-05 15:06:45 UTC
> 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)"?
Comment 2 Fabian Groffen gentoo-dev 2009-10-05 15:11:50 UTC
(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/
Comment 3 Ulrich Müller gentoo-dev 2009-10-05 15:21:53 UTC
> > 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"
Comment 4 Fabian Groffen gentoo-dev 2009-10-05 15:28:28 UTC
(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.
Comment 5 Ulrich Müller gentoo-dev 2009-10-05 17:01:17 UTC
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".
Comment 6 Fabian Groffen gentoo-dev 2009-10-05 18:28:47 UTC
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% 
Comment 7 Ulrich Müller gentoo-dev 2009-10-06 06:34:28 UTC
Created attachment 206218 [details, diff]
eselect-1.2.3-relative-symlink.patch

Does attached patch fix the problem?
Comment 8 Fabian Groffen gentoo-dev 2009-10-08 18:21:14 UTC
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.
Comment 9 Fabian Groffen gentoo-dev 2009-10-09 15:55:54 UTC
1.2.4 was released with the fix.

Converted Prefix users to use gx86 ebuild directly.

Thanks for the fix Ulrich!