leycec / raiagent

Third-party Gentoo overlay. Ride the Lagrangian point between awesomeness and volatile compounds.
31 stars 14 forks source link

EAPI 7 changes behavior of "EROOT" ebuild variable #79

Closed nethershaw closed 4 years ago

nethershaw commented 4 years ago

I believe a recent change may have caused very, very subtle and unintended consequences.

If installed by an ebuild following the linked commit, when launching Tmux using a standard configuration that was previously working with a prior version of the ebuild, Powerline may appear simply not to initialize. In that case, manual initialization will yield the following output (assuming a python3.6 interpreter):

powerline-config tmux setup
Traceback (most recent call last):
  File "/usr/lib/python-exec/python3.6/powerline-config", line 22, in <module>
    args.function(pl, args)
  File "/usr/lib64/python3.6/site-packages/powerline/commands/config.py", line 15, in __call__
    self.function(*args, **kwargs)
  File "/usr/lib64/python3.6/site-packages/powerline/bindings/config.py", line 215, in tmux_setup
    source_tmux_files(pl, args, tmux_version=tmux_version, source_tmux_file=stf)
  File "/usr/lib64/python3.6/site-packages/powerline/bindings/config.py", line 74, in source_tmux_files
    source_tmux_file(os.path.join(TMUX_CONFIG_DIRECTORY, 'powerline-base.conf'))
  File "/usr/lib64/python3.6/site-packages/powerline/bindings/config.py", line 196, in source_tmux_file_nosource
    with open(fname) as fd:
FileNotFoundError: [Errno 2] No such file or directory: 'usr/share/powerline/tmux/powerline-base.conf'

This is traceable to /usr/lib64/python3.6/site-packages/powerline/config.py, where it can be observed that the BINDINGS_DIRECTORY variable now takes the value 'usr/share/powerline/' (note the missing leading forward slash). This configuration variable is set by the ebuild here.

This seems strange at first; additional digging reveals an important but easy to miss note from the Gentoo Development Guide. These are the salient bits (emphasis added):

ROOT = / Please note an important recent change regarding the ROOT variable -- in EAPI 7 ebuilds, this variable will default to "" rather than the traditional "/" within ebuilds when pointing to the root filesystem, and when set to a non-root path this variable will never contain a trailing slash. This has the added convenience of eliminating the need to specify "${ROOT%/}" when concatenating paths, making the use of ROOT more elegant. This applies to the variables EROOT, D and ED as well. Please make note that this will mean that ebuilds must use different logic in conditionals to determine if they are installing to the root filesystem -- use [[ "$ROOT" == "" ]] instead of [[ "$ROOT" == "/" ]]. Contains the path that portage should use as the root of the live filesystem. When packages wish to make changes to the live filesystem, they should do so in the tree prefixed by ${ROOT}. Often the offset prefix needs to be taken into account here, for which the variable ${EROOT} is provided (see below). Do not modify this variable.

EROOT = ${ROOT%/}${EPREFIX}/ Beginning with EAPI 3, contains "${ROOT%/}${EPREFIX}/" for convenience purposes. Do not modify this variable. Also see the important note regarding ROOT with EAPI 7, above. As with ROOT, EROOT will be defined as "" when set to the root filesystem and never have a trailing slash within an ebuild.

Thus, changing the ebuild's API version without also changing the way the BINDINGS_DIRECTORY config variable is constructed has the consequence of removing from it the necessary leading forward slash, which in turn breaks the powerline-config tool since it can no longer locate the powerline-base.conf file by its absolute path.

I am not sure how you would prefer to fix this, but it may be sufficient simply to change the definition of POWERLINE_HOME_EROOTED from:

POWERLINE_HOME_EROOTED="${EROOT}"usr/share/powerline/

to:

POWERLINE_HOME_EROOTED="${EROOT}"/usr/share/powerline/

...since ${EROOT} will now reliably never contain a trailing slash.

leycec commented 4 years ago

Wowza! Thanks a metric ton for both your detailed writeup and helpful changeset. As suspected, this is (of course) all my fault. We'll get this merged ASAP to appease my gnawing sense of guilt and shame.

leycec commented 4 years ago

(╯°□°)╯︵ ┻━┻

...in EAPI 7 ebuilds, this variable will default to "" rather than the traditional "/" within ebuilds when pointing to the root filesystem...

┬─┬ ノ( ゜-゜ノ)

leycec commented 4 years ago

Lastly, this is the most scholarly dissemination of a GitHub issue that I've ever seen. It's almost like... you're my open-source doppelgänger. ...umlaut for emphasis

I have now been suitably edumucated. I solemnly vow on an emoji dagger that this EAPI 7 ${EROOT} oversight shall never trouble us again: :dagger:

leycec commented 4 years ago

Oh, boy. Manually inspecting /usr/lib64/python3.6/site-packages/powerline/config.py shows additional badness:

DEFAULT_SYSTEM_CONFIG_DIR = 'etc/xdg'

I'll get this similarly patched up. This is why we test before pushing, people.

leycec commented 4 years ago

The prior comment's mini-issue resolved by 9452696.

@nethershaw: Because of that, you probably also want to update. With luck, this hallmarks the end of Powerline concerns for at least five minutes. crosses skeletal fingers