Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 472938

Summary: app-shells/bash-completion-2.1: use upstream build-sys, use upstream path(s) like /usr/share/bash-completion/completions, upstream completions autoloader etc.
Product: Gentoo Linux Reporter: Alexander Tsoy <alexander>
Component: Current packagesAssignee: Gentoo Shell Tools project <shell-tools>
Status: RESOLVED FIXED    
Severity: normal CC: casta, evgen.ibqn, mgorny, pacho, ssuominen
Priority: Normal Keywords: PMASKED
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on: 521146    
Bug Blocks:    
Attachments: bash-completion-2.1-r1.ebuild
bash-completion-r1.eclass.patch
From current 2.1 to 2.1-r1 build patch

Description Alexander Tsoy 2013-06-11 04:04:04 UTC
Created attachment 350726 [details]
bash-completion-2.1-r1.ebuild

Let's drop the wrapper script and change installation paths to upstream defaults. :)


Some facts. From the README [1]:

"There are two alternatives: the recommended one is 'completionsdir' (get it with "pkg-config --variable=completionsdir bash-completion") from which completions are loaded on demand based on invoked commands' names, so be sure to name your completion file accordingly, and to include for example symbolic links in case the file provides completions for more than one command.  The other one which is present for backwards compatibility reasons is 'compatdir' (get it with "pkg-config --variable=compatdir bash-completion") from which files are loaded when bash_completion is loaded."


By default completionsdir="/usr/share/bash-completion/completions" and compatdir="/etc/bash_completion.d". With current bash-completion-2.1 ebuild from the portage tree dynamic loading of completions does not work because they are installed in "/usr/share/bash-completion".

Some completions may not support loading on demand. Currently I'm aware of only one: gentoo-bashcomp. Name of completions provided by gentoo-bashcomp does not match commands' names. They could be enabled globally using bashcomp-eselect, so that symlinks are created in "/etc/bash_completion.d/" (compatdir). The same also applies to completions which support loading on demand, but installed in "/usr/share/bash-completion".

Loading competions from "~/.bash_completion.d" is not supported.


TODO/Qeustions:
 - bash-completion-2.1 ebuild: add postinst messages
 - gentoo-bashcomp: file a bug requesting to support loading completions on demand
 - What is the migration strategy? What to do with ebuilds installing completions in "/usr/share/bash-completion"? What to do with bash-completion-r1.eclass? etc...


[1] http://anonscm.debian.org/gitweb/?p=bash-completion/bash-completion.git;a=blob;f=README
Comment 1 Ryan Hill (RETIRED) gentoo-dev 2013-06-12 04:37:07 UTC
I did some work on gentoo-bashcomp last year before getting sidetracked.  I'll try to get back to it and work on a migration plan.  I think we should eventually get rid of the eselect module and load everything dynamically.  The bulk of the work can be done in the eclass, but I'm thinking it's going to be tricky to handle both versions at the same time.  It might be better to add an -r2 eclass and port ebuilds over.
Comment 2 Samuli Suominen (RETIRED) gentoo-dev 2013-06-12 22:17:29 UTC
Created attachment 350854 [details, diff]
bash-completion-r1.eclass.patch

New functions get_bashcompdir and less used get_bashhelpersdir,

- Use pkg-config (like systemd.eclass, udev.eclass, etc.) but have fallbacks for everything to cause minimal blockers.

- Provide migration path to upstream bash-completion system. No bash-completion-r2.eclass required.

Notes,

As per Comment #1, gentoo-bashcomp is blocked from the new ebuild for now.

Example usage,

--- sys-fs/udisks/udisks-2.1.0.ebuild
+++ sys-fs/udisks/udisks-2.1.0.ebuild
@@ -80,7 +80,8 @@
        keepdir /var/lib/udisks2 #383091

        rm -rf "${ED}"/usr/share/bash-completion
-       dobashcomp data/completions/udisksctl
+       insinto "$(get_bashcompdir)"
+       doins data/completions/udisksctl

        local htmldir=udisks2
        if [[ -d ${ED}/usr/share/doc/${PF}/html/${htmldir} ]]; then



Will attach the ebuild patch too.
Comment 3 Samuli Suominen (RETIRED) gentoo-dev 2013-06-12 22:18:26 UTC
Created attachment 350856 [details, diff]
From current 2.1 to 2.1-r1 build patch
Comment 4 Alexander Tsoy 2013-06-13 12:26:44 UTC
(In reply to Samuli Suominen from comment #2)
> New functions get_bashcompdir and less used get_bashhelpersdir,

See bug 469858

> As per Comment #1, gentoo-bashcomp is blocked from the new ebuild for now.

gentoo-bashcomp works fine if completions enabled globally (eselect bashcomp enable --global {eselect,gentoo,repoman}). Also there is a quick temporary fix for gentoo-bashcomp: install completions in /etc/bash_completion.d/.

-insinto /usr/share/bash-completion
+insinto /etc/bash_completion.d

(In reply to Samuli Suominen from comment #3)
> +RDEPEND="|| ( >=app-shells/bash-3.2 app-shells/zsh )

From the README:

"Use the full power of bash >= 4.1. We no longer support earlier bash
versions, so you may as well use all the features of that version of
bash to optimise your code. However, be careful when using features
added since bash 4.1, since not everyone will be able to use them."

> -		elog "If you use non-login shells you still need to source"
> -		elog "/etc/profile.d/bash-completion.sh in your ~/.bashrc."

Please add something like this into pkg_postinst():

elog "If you use non-login shells you still need to source"
elog "/usr/share/bash-completion/bash_completion"
elog "in your ~/.bashrc. For example:"
elog "[[ \$PS1 && -f /usr/share/bash-completion/bash_completion ]] && \\"
elog "    . /usr/share/bash-completion/bash_completion"
Comment 5 Ryan Hill (RETIRED) gentoo-dev 2013-06-14 04:45:25 UTC
(In reply to Samuli Suominen from comment #2)
> Created attachment 350854 [details, diff] [details, diff]
> bash-completion-r1.eclass.patch
> 
> New functions get_bashcompdir and less used get_bashhelpersdir,
> 
> - Use pkg-config (like systemd.eclass, udev.eclass, etc.) but have fallbacks
> for everything to cause minimal blockers.
> 
> - Provide migration path to upstream bash-completion system. No
> bash-completion-r2.eclass required.

That's not a bad option, but I still like the simplicity of just being able to call dobashcomp.  It's idiot-proof and if we ever need to hook in other features/fixes later we can do it once in the eclass rather than modify a ton of ebuilds.  It also makes migrating ebuilds nothing but a simple tweak of the inherit line.
Comment 6 Samuli Suominen (RETIRED) gentoo-dev 2013-06-14 12:53:22 UTC
(In reply to Ryan Hill from comment #5)
> (In reply to Samuli Suominen from comment #2)
> > Created attachment 350854 [details, diff] [details, diff] [details, diff]
> > bash-completion-r1.eclass.patch
> > 
> > New functions get_bashcompdir and less used get_bashhelpersdir,
> > 
> > - Use pkg-config (like systemd.eclass, udev.eclass, etc.) but have fallbacks
> > for everything to cause minimal blockers.
> > 
> > - Provide migration path to upstream bash-completion system. No
> > bash-completion-r2.eclass required.
> 
> That's not a bad option, but I still like the simplicity of just being able
> to call dobashcomp.  It's idiot-proof and if we ever need to hook in other
> features/fixes later we can do it once in the eclass rather than modify a
> ton of ebuilds.  It also makes migrating ebuilds nothing but a simple tweak
> of the inherit line.

Sure, the patch to the eclass just makes the dobashcomp use pkg-config to determine completionsdir
You can keep on using it
Comment 7 Ryan Hill (RETIRED) gentoo-dev 2013-06-15 07:28:14 UTC
I completely missed that part of the patch.  Looks good to me.
Comment 8 Alexander Tsoy 2013-06-17 14:04:58 UTC
Can we start preparing ebuilds which hardcodes /usr/share/bash-completion path for migration? get_bashcompdir() function is already supported by eclass [1]. If yes, then we need a tracker.

[1] http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/eclass/bash-completion-r1.eclass?r1=1.3&r2=1.4
Comment 9 Samuli Suominen (RETIRED) gentoo-dev 2013-07-16 00:14:57 UTC
2.1-r1 in tree and eclass updated, closing
Comment 10 Jeroen Roovers (RETIRED) gentoo-dev 2013-07-16 12:13:07 UTC
*** Bug 477024 has been marked as a duplicate of this bug. ***
Comment 11 Pacho Ramos gentoo-dev 2014-07-29 12:01:56 UTC
Looks like this was dropped finally
Comment 12 Samuli Suominen (RETIRED) gentoo-dev 2014-07-29 12:08:47 UTC
(In reply to Pacho Ramos from comment #11)
> Looks like this was dropped finally

I removed 2.1-r1 because some loud people complained they couldn't no longer prevent specific bash-completions from being loaded
As in, 2.1-r1 no longer used eselect-bashcomp
I personally used INSTALL_MASK to drop 2 problematic bash-completion files, and was fine with that solution, but this wasn't enough for everyone

So, a new version of eselect-bashcomp "needs" to be created that works in a way that you can disable specific ones, like, move them out of /usr/share/bash-completion/completions/ to some temporary directory like /usr/share/bash-completion/completions.eselect/

I'm no longer working on this, I'm just clarifying why 2.1-r1 was removed, this is why, the lack of newly written eselect-bashcomp module that works reverse from the current one
Comment 13 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2014-08-28 10:01:05 UTC
In case anyone wants to play with this, p.masked >=bash-completion-2.1-r90 is the (second attempt) initial ebuild.
Comment 14 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2014-08-28 10:02:05 UTC
*** Bug 476992 has been marked as a duplicate of this bug. ***
Comment 15 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2014-10-25 13:19:07 UTC
2.1-r91 is now in ~arch. Enjoy the new issues!