Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 568974 - app-eselect/eselect-python-20151117-r2 uses recursive shebangs which only works on Linux
Summary: app-eselect/eselect-python-20151117-r2 uses recursive shebangs which only wor...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo/Alt
Classification: Unclassified
Component: Prefix Support (show other bugs)
Hardware: All Other
: Normal blocker (vote)
Assignee: Gentoo Prefix
URL:
Whiteboard:
Keywords: PMASKED
Depends on:
Blocks:
 
Reported: 2015-12-21 11:15 UTC by Qiming Wang
Modified: 2016-02-23 11:59 UTC (History)
1 user (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 Qiming Wang 2015-12-21 11:15:01 UTC
Every time I reinstall portage, the shebang line in emerge and portageq is something like:
`#!/Users/dom/Gentoo/usr/bin/python -b`
which doesn't always work, because `python` is also a shebang script, and shebang nesting is not supported by darwin kernel (and other kernels). Although lots of shells calls the interpreter before the kernel by reading the first line.
So why not the following?
`#!/Users/dom/Gentoo/usr/bin/env /Users/dom/Gentoo/usr/bin/python -b`
I change it manually every time, but I'm worried if portage is broken during an upgrade there may be some unexpected conseqences.
Comment 1 Guilherme Amadio gentoo-dev 2015-12-21 12:00:32 UTC
Your suggestion will not work on Linux, because it doesn't split shebang arguments, it will fail with file not found for "/Users/dom/Gentoo/usr/bin/python -b".
Comment 2 Benda Xu gentoo-dev 2015-12-21 13:46:18 UTC
(In reply to Qiming Wang from comment #0)
> Every time I reinstall portage, the shebang line in emerge and portageq is
> something like:
> `#!/Users/dom/Gentoo/usr/bin/python -b`
> which doesn't always work, because `python` is also a shebang script, and
> shebang nesting is not supported by darwin kernel (and other kernels).

Why python is a shebang script?  On my system,

python: symbolic link to python-wrapper

python-wrapper: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked

Or is it specific to MacOSX?
Comment 3 Fabian Groffen gentoo-dev 2015-12-21 15:07:41 UTC
I have the same, not a wrapper on wrapper.  I recall this used to be the case in a previous incarnation of python-exec, is your system uptodate?
Comment 4 Qiming Wang 2015-12-22 08:35:14 UTC
I just recently bootstrapped. I installed:
$equery l -f 'python'
[IP-] [  ] app-admin/python-updater-0.14:0
[IP-] [  ] app-eselect/eselect-python-20151117-r2:0
[IP-] [  ] dev-lang/python-2.7.11:2.7
[IP-] [  ] dev-lang/python-3.4.3-r5:3.4/3.4m
[IP-] [  ] dev-lang/python-3.5.1:3.5/3.5m
[IP-] [  ] dev-lang/python-exec-2.1:2
...
$equery b  ~/Gentoo/usr/bin/python
app-eselect/eselect-python-20151117-r2 (/Users/dom/Gentoo/usr/bin/python)
$file ~/Gentoo/usr/bin/python
/Users/dom/Gentoo/usr/bin/python: a /Users/dom/Gentoo/usr/lib/python-exec/python-exec2-c script, UTF-8 Unicode text executable
$equery d eselect-python
 * These packages depend on eselect-python:
dev-lang/python-2.7.11 (>=app-eselect/eselect-python-20151117-r1)
dev-lang/python-3.4.3-r5 (>=app-eselect/eselect-python-20151117-r1)
dev-lang/python-3.5.1 (>=app-eselect/eselect-python-20151117-r1)

May I shouldn't install eselect-python?
But it was pulled automatically.
Comment 5 Fabian Groffen gentoo-dev 2016-01-05 18:18:46 UTC
What tree are you on?  I see versions that I believe aren't in the Prefix tree.
Comment 6 Qiming Wang 2016-01-06 08:49:46 UTC
That's weird. I do `emerge --sync` quite frequently.
$ emerge --info
Portage 2.2.20-prefix (python 2.7.11-final-0, prefix/darwin/macos/10.11/x64, gcc-4.2.1, unavailable, 15.2.0 x86_64)
=================================================================
System uname: Darwin-15.2.0-x86_64-i386-64bit
Timestamp of repository gentoo_prefix: Tue, 05 Jan 2016 02:39:21 +0000
sh bash 4.3_p39
app-shells/bash:      4.3_p39::gentoo_prefix
dev-lang/perl:        5.22.1::gentoo_prefix
dev-lang/python:      2.7.11::gentoo_prefix, 3.4.3-r5::gentoo_prefix, 3.5.1::gentoo_prefix
dev-util/cmake:       3.4.1::gentoo_prefix
dev-util/pkgconfig:   0.29::gentoo_prefix
sys-devel/autoconf:   2.69::gentoo_prefix
sys-devel/automake:   1.14.1::gentoo_prefix, 1.15::gentoo_prefix
sys-devel/binutils:   2.21.1-r1::gentoo_prefix
sys-devel/gcc-config: 1.8-r1::gentoo_prefix
sys-devel/libtool:    2.4.6-r1::gentoo_prefix
sys-devel/make:       4.1-r1::gentoo_prefix
Repositories:

gentoo_prefix
    location: /Users/dom/Gentoo/usr/portage
    sync-type: rsync
    sync-uri: rsync://rsync.prefix.bitzolder.nl/gentoo-portage-prefix
    priority: -1000
    aliases: gentoo

gentoo-zh
    location: /Users/dom/Gentoo/var/lib/layman/gentoo-zh
    masters: gentoo_prefix
    priority: 0

ACCEPT_KEYWORDS="~x64-macos"
ACCEPT_LICENSE="* -@EULA"
CBUILD="x86_64-apple-darwin15"
CC="clang"
CFLAGS="-march=nocona -O2 -pipe"
CHOST="x86_64-apple-darwin15"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/terminfo"
CXX="clang++"
CXXFLAGS="-march=nocona -O2 -pipe"
DISTDIR="/Users/dom/Gentoo/usr/portage/distfiles"
FCFLAGS=""
FEATURES="assume-digests binpkg-logs case-insensitive-fs collision-protect config-protect-if-modified distlocks ebuild-locks fixlafiles force-prefix merge-sync news nostrip parallel-fetch preserve-libs protect-owned sfperms strict unknown-features-warn unmerge-logs unmerge-orphans unprivileged userfetch userpriv usersandbox usersync"
FFLAGS=""
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LDFLAGS="-Wl,-dead_strip_dylibs"
MAKEOPTS="-j3"
PKGDIR="/Users/dom/Gentoo/usr/portage/packages"
PORTAGE_CONFIGROOT="/Users/dom/Gentoo/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/Users/dom/Gentoo/var/tmp"
USE="coreaudio cracklib cxx ipv6 mmx mmxext modules ncurses objc objc++ prefix prefix-guest readline sse sse2 ssl unicode x64-macos zlib" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="mmx mmxext sse sse2" ELIBC="Darwin" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="keyboard mouse" KERNEL="Darwin" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-5" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python3_4 python2_7" RUBY_TARGETS="ruby20 ruby21" USERLAND="GNU" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON
Comment 7 Fabian Groffen gentoo-dev 2016-01-06 19:03:29 UTC
ok, I can confirm this now, it sucks indeed
Comment 8 Fabian Groffen gentoo-dev 2016-01-06 19:24:20 UTC
This is an eselect-python problem as I understand it, for they no longer use the executable wrapper.
Comment 9 Fabian Groffen gentoo-dev 2016-01-06 19:38:28 UTC
this is fun, because python hard depends on this eselect-python version (I don't know if it really needs it) so we'll lose python due to this as well.
Comment 10 Fabian Groffen gentoo-dev 2016-01-06 19:49:04 UTC
Masked the versions in Prefix
Comment 11 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2016-01-06 21:57:40 UTC
Well, it's using the python wrapper since we just happened to have it around. If that's causing problems, I see no problems changing that.

I see two simple solutions:

1. either we modify python-exec-c to support being symlinked directly,

2. or we create non-python wrapper that execs python-exec-c (like python python-exec does via shebang now).

I don't mind either way. Unless I'm mistaken, option 1. would imply comparing argv[0] to *python-exec, and either using argv[0] or argv[1] as the script name appropriately. The script should be able to handle the change gracefully -- it should be only necessary to remove a single ++argv shift.
Comment 12 Fabian Groffen gentoo-dev 2016-01-07 08:21:39 UTC
I got the impression that the new eselect-python tries to switch versions of python like java-config does, e.g. by setting config values such that invocation doesn't use symlinks but listens to the config instead (and probably can be overridden by envvars).  Is that correct?

I can help with the c-wrapper in any case.
Comment 13 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2016-01-07 08:30:56 UTC
It always worked like this. The only difference is that I've removed the second python-wrapper, and used the same wrapper as we use for packages.
Comment 14 Fabian Groffen gentoo-dev 2016-01-08 17:39:17 UTC
Is there a reason why the latest Python ebuilds depend on this version of eselect-python?  I'd like to unmask those python versions on Prefix by adjusting the version requirement on eselect-python in the ebuilds (prefix tree only).
Comment 15 Mike Gilbert gentoo-dev 2016-01-08 18:03:30 UTC
Yes, I changed the dep for a reason. I just can't recall what it was at this moment.
Comment 16 Mike Gilbert gentoo-dev 2016-01-08 18:16:35 UTC
See bug 567866. Calling /usr/bin/python-config from older versions of eselect-python will fail since we dropped /usr/bin/python-config-2.7 from newer dev-lang/python ebuilds.
Comment 17 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2016-01-08 21:06:28 UTC
Just to be clear, I can fix it in 15-30 minutes, I think. I just want to know which solution you prefer. Both pretty much have the same downsides, except that one makes python-exec-c a little more complex and the other adds yet another wrapper (and exec*() call) to avoid the extra complexity in main wrapper.
Comment 18 Fabian Groffen gentoo-dev 2016-01-09 16:12:14 UTC
(In reply to Michał Górny from comment #17)
> Just to be clear, I can fix it in 15-30 minutes, I think. I just want to
> know which solution you prefer. Both pretty much have the same downsides,
> except that one makes python-exec-c a little more complex and the other adds
> yet another wrapper (and exec*() call) to avoid the extra complexity in main
> wrapper.

I would prefer the python-exec-c way of doing things.  exec() is extremely expensive on some platforms hence would add considerable latency.

Thanks for looking into this!
Comment 19 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2016-01-09 23:16:02 UTC
Please test the 'python-exec-prefix' branch, it's got update for eselect-python and python-exec. Please also make sure to run python-exec's test suite.
Comment 20 Fabian Groffen gentoo-dev 2016-01-10 15:55:51 UTC
I can't find python-exec-prefix branch on https://bitbucket.org/mgorny/python-exec/.  Is there a github/infra repo or somewhere else with the repo?
Comment 21 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2016-01-10 16:01:37 UTC
I mean repo/gentoo.git. It has bumped python-exec and eselect-python ebuilds.
Comment 22 Fabian Groffen gentoo-dev 2016-01-10 17:03:43 UTC
(In reply to Michał Górny from comment #21)
> I mean repo/gentoo.git. It has bumped python-exec and eselect-python ebuilds.

This seems to work.
Comment 23 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2016-01-11 16:00:31 UTC
Committed p.masked.
Comment 24 Fabian Groffen gentoo-dev 2016-01-18 18:48:37 UTC
this seems to work very well for me
Comment 25 Fabian Groffen gentoo-dev 2016-02-21 17:01:03 UTC
works good, unmasked in prefix, so resolving.
Comment 26 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2016-02-21 17:22:53 UTC
Thanks. If you could also confirm there's nothing wrong with 2.4.1, I'd love to unmask that one for the whole Gentoo. It pretty much exhausted my TODO.
Comment 27 Fabian Groffen gentoo-dev 2016-02-22 08:28:00 UTC
reopening for test request
Comment 28 Fabian Groffen gentoo-dev 2016-02-23 11:59:27 UTC
testing was good