Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 446648 - distutils-r1: distutils-r1_python_install() has trouble with Prefix directories
Summary: distutils-r1: distutils-r1_python_install() has trouble with Prefix directories
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All Other
: High major (vote)
Assignee: Michał Górny
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-09 19:56 UTC by Michał Górny
Modified: 2012-12-09 20:56 UTC (History)
2 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2012-12-09 19:56:25 UTC
As noticed in bug 420579, the updated code in distutils-r1 tries to symlink python-exec from outside of EPREFIX.

However, looking at the code I'm starting to think it would even install the whole package ignoring EPREFIX. Does Prefix Portage have some auto-fixing for that or am I missing something?

The relevant code pieces:

distutils-r1_python_install() {
    # [...]

    local root=${D}/_${EPYTHON}

    esetup.py install "${flags[@]}" --root="${root}" "${@}"
    _distutils-r1_rename_scripts "${root}"

    # merge
    cp -a -l -n "${root}"/* "${D}"/ || die "Merging ${EPYTHON} image failed."
    rm -rf "${root}"
}

...so assuming that the package would land in $D/_python2.7/usr/bin/flaggie-python2.7, then get copied to $D/usr/bin/...

...or am I missing something?
Comment 1 Fabian Groffen gentoo-dev 2012-12-09 20:01:14 UTC
My personal observation was that _python_ln_rel from python-utils-r1 is adding too many ../ pairs because it takes the EPREFIX into account, which it shouldn't, or it'll point beyond the prefix entry point.

For that case a simple X -> python-exec symlink would've been sufficient.
Comment 2 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2012-12-09 20:11:44 UTC
(In reply to comment #1)
> My personal observation was that _python_ln_rel from python-utils-r1 is
> adding too many ../ pairs because it takes the EPREFIX into account, which
> it shouldn't, or it'll point beyond the prefix entry point.
> 
> For that case a simple X -> python-exec symlink would've been sufficient.

I'm afraid I don't understand you. _python_ln_rel just works on two absolute paths, and it isn't Prefix-aware by itself. The distutils-r1 functions should be (but aren't) as I pointed out.

However, I don't want to change them without making sure that I understand it all correctly.

I've added two elog lines to the find loop in distutils_rename_scripts like:

    while IFS= read -r -d '' f; do
        debug-print "${FUNCNAME}: found executable at ${f#${D}/}"

        elog "$f"
        elog "$path/usr/bin/python-exec"
        
and they give for me:

 * /tmp/portage/app-portage/flaggie-0.2-r2/image//_python2.6/usr/bin/flaggie
 * /tmp/portage/app-portage/flaggie-0.2-r2/image//_python2.6/usr/bin/python-exec
 * /tmp/portage/app-portage/flaggie-0.2-r2/image//_python3.1/usr/bin/flaggie
 * /tmp/portage/app-portage/flaggie-0.2-r2/image//_python3.1/usr/bin/python-exec
 * /tmp/portage/app-portage/flaggie-0.2-r2/image//_python3.2/usr/bin/flaggie
 * /tmp/portage/app-portage/flaggie-0.2-r2/image//_python3.2/usr/bin/python-exec

I'd assume the output for Prefix portage would be the same, unless I'm missing something hidden.
Comment 3 Fabian Groffen gentoo-dev 2012-12-09 20:24:07 UTC
 * /Library/Gentoo/var/tmp/portage/app-portage/flaggie-0.2-r2/image//_python2.7/Library/Gentoo/usr/bin/flaggie
 * /Library/Gentoo/var/tmp/portage/app-portage/flaggie-0.2-r2/image//_python2.7/usr/bin/python-exec

so, the esetup.py stuff adds (correctly) the full installation prefix (/usr in your case)

Hence, seems we can solve it by

Index: distutils-r1.eclass
===================================================================
RCS file: /var/cvsroot/gentoo-x86/eclass/distutils-r1.eclass,v
retrieving revision 1.30
diff -u -r1.30 distutils-r1.eclass
--- distutils-r1.eclass 7 Dec 2012 22:23:04 -0000       1.30
+++ distutils-r1.eclass 9 Dec 2012 20:22:48 -0000
@@ -295,7 +295,7 @@
                        mv "${f}" "${newf}" || die
 
                        debug-print "${FUNCNAME}: installing wrapper at ${f#${D}/}"
-                       _python_ln_rel "${path}"/usr/bin/python-exec "${f}" || die
+                       _python_ln_rel "${path}${EPREFIX}"/usr/bin/python-exec "${f}" || die
                fi
        done < <(find "${path}" -type f -executable -print0)
 }

which results in the symlink:

flaggie -> python-exec
Comment 4 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2012-12-09 20:42:16 UTC
(In reply to comment #3)
>  *
> /Library/Gentoo/var/tmp/portage/app-portage/flaggie-0.2-r2/image//_python2.7/
> Library/Gentoo/usr/bin/flaggie
>  *
> /Library/Gentoo/var/tmp/portage/app-portage/flaggie-0.2-r2/image//_python2.7/
> usr/bin/python-exec
> 
> so, the esetup.py stuff adds (correctly) the full installation prefix (/usr
> in your case)

Ah, yes, I get it.

> Hence, seems we can solve it by
> 
> Index: distutils-r1.eclass
> ===================================================================
> RCS file: /var/cvsroot/gentoo-x86/eclass/distutils-r1.eclass,v
> retrieving revision 1.30
> diff -u -r1.30 distutils-r1.eclass
> --- distutils-r1.eclass 7 Dec 2012 22:23:04 -0000       1.30
> +++ distutils-r1.eclass 9 Dec 2012 20:22:48 -0000
> @@ -295,7 +295,7 @@
>                         mv "${f}" "${newf}" || die
>  
>                         debug-print "${FUNCNAME}: installing wrapper at
> ${f#${D}/}"
> -                       _python_ln_rel "${path}"/usr/bin/python-exec "${f}"
> || die
> +                       _python_ln_rel
> "${path}${EPREFIX}"/usr/bin/python-exec "${f}" || die
>                 fi
>         done < <(find "${path}" -type f -executable -print0)
>  }
> 
> which results in the symlink:
> 
> flaggie -> python-exec

Indeed. Thanks for the help.
Comment 5 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2012-12-09 20:56:39 UTC
/var/cvsroot/gentoo-x86/eclass/distutils-r1.eclass,v  <--  distutils-r1.eclass
new revision: 1.31; previous revision: 1.30