commit:     70a667146a5de8b7f0d6dbf69e55e006d97e0c0b
Author:     Eli Schwartz <eschwartz93 <AT> gmail <DOT> com>
AuthorDate: Thu Jan 18 03:37:13 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Jan 25 09:19:35 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=70a66714

app-text/lesspipe: fix completion installation

Neither completion is properly installed upstream, and the local fix for
bash was incorrect:

- bash completions have to be loaded without the autoload handler, as
  they extend the builtin completion installed immediately upon loading
  the `bash_completion` initialization

- zsh completions did a configure check to see if zsh is installed.
  Patch submitted upstream at https://github.com/wofr06/lesspipe/pull/142
  and backported

Signed-off-by: Eli Schwartz <eschwartz93 <AT> gmail.com>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 app-text/lesspipe/files/all-completions.patch | 51 ++++++++++++++++++++
 app-text/lesspipe/lesspipe-2.11-r1.ebuild     | 68 +++++++++++++++++++++++++++
 2 files changed, 119 insertions(+)

diff --git a/app-text/lesspipe/files/all-completions.patch 
b/app-text/lesspipe/files/all-completions.patch
new file mode 100644
index 000000000000..dfd8ed90dd34
--- /dev/null
+++ b/app-text/lesspipe/files/all-completions.patch
@@ -0,0 +1,51 @@
+From 621e2897c19155df8d0a5931a0c862bfdac22a0a Mon Sep 17 00:00:00 2001
+From: Eli Schwartz <eschwart...@gmail.com>
+Date: Wed, 17 Jan 2024 22:08:29 -0500
+Subject: [PATCH] add configure option to always install all completions
+
+This is useful for distro packaging. Many distros have a policy that
+shell completions shall always be installed, even if the shell they are
+for is not installed at the time.
+
+This is useful because buildbot chroots often don't have additional
+shells installed, so users will *never* get zsh completions.
+---
+ configure | 9 +++++----
+ 1 file changed, 5 insertions(+), 4 deletions(-)
+
+diff --git a/configure b/configure
+index 68d03a1..d521962 100755
+--- a/configure
++++ b/configure
+@@ -10,10 +10,10 @@ use Getopt::Long;
+ # find sxw2txt and other scripts in current dir, if scripts not installed yet
+ $ENV{PATH} .= ':.';
+ 
+-use vars qw($opt_help $opt_prefix $opt_nomake $opt_shell);
++use vars qw($opt_help $opt_prefix $opt_nomake $opt_shell 
$opt_all_completions);
+ 
+ Getopt::Long::Configure("prefix_pattern=--");
+-my $result = GetOptions('help+', 'prefix=s', 'shell=s', 'nomake+');
++my $result = GetOptions('help+', 'prefix=s', 'shell=s', 'nomake+', 
'all-completions+');
+ if ( $ARGV[0] or ! $result or $opt_help) {
+       print << 'EOF';
+ Usage: configure [options]
+@@ -21,6 +21,7 @@ Options:
+  --help                       print this message
+  --shell=<filename>   specify an alternative shell path (zsh/bash) to use
+  --nomake             do not generate a Makefile
++ --all-completions    always install all completions
+ Directory and file names:
+  --prefix=PREFIX      install lesspipe.sh in PREFIX/bin (/usr/local)
+ 
+@@ -47,8 +48,8 @@ if ( $opt_shell and -f $opt_shell and $opt_shell =~ /^\// ) {
+ my @bad = ();
+ my $shell = check_shell_vers();
+ if ( ! $opt_nomake ) {
+-      my $no_bash = grep {/bash/} @bad;
+-      my $no_zsh = grep {/zsh/} @bad;
++      my $no_bash = (grep {/bash/} @bad and ! $opt_all_completions);
++      my $no_zsh = (grep {/zsh/} @bad and ! $opt_all_completions);
+       open OUT, ">Makefile";
+       while (<DATA>) {
+               next if /bash_complete_dir/ and $no_bash;

diff --git a/app-text/lesspipe/lesspipe-2.11-r1.ebuild 
b/app-text/lesspipe/lesspipe-2.11-r1.ebuild
new file mode 100644
index 000000000000..8ad29bdcd156
--- /dev/null
+++ b/app-text/lesspipe/lesspipe-2.11-r1.ebuild
@@ -0,0 +1,68 @@
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit edo
+
+DESCRIPTION="Preprocessor for less"
+HOMEPAGE="https://github.com/wofr06/lesspipe";
+SRC_URI="https://github.com/wofr06/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv 
~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x64-solaris"
+IUSE="test"
+
+# Please check again on bumps! (bug #734896)
+RESTRICT="!test? ( test ) test"
+
+RDEPEND="dev-lang/perl"
+BDEPEND="
+       ${RDEPEND}
+       virtual/pkgconfig
+       test? ( app-editors/vim )
+"
+
+PATCHES=(
+       # Backport patch to allow installing completions for shells that aren't
+       # yet installed.
+       #
+       # https://github.com/wofr06/lesspipe/pull/142
+       "${FILESDIR}"/all-completions.patch
+)
+
+src_configure() {
+       # Not an autoconf script.
+       #
+       # PG0301
+       # By default, only completions for installed shells are installed.
+       # Unconditionally install zsh too.
+       edo ./configure --prefix="${EPREFIX}"/usr --all-completions
+}
+
+src_compile() {
+       # Nothing to build (avoids the "all" target)
+       :
+}
+
+src_install() {
+       emake PREFIX="${EPREFIX}/usr" DESTDIR="${D}" install
+       einstalldocs
+
+       # The upstream Makefile intentionally installs to the wrong directory, 
then prints:
+       #   In bash, please preload the completion, dynamic invocation does not 
work
+       #   . /usr/share/bash-completion/less_completion
+       #   Or consider installing the file less_completion in 
/etc/bashcompletion.d
+       rm "${ED}"/usr/share/bash-completion/less_completion || die
+       insinto /etc/bash_completion.d
+       doins less_completion
+}
+
+pkg_preinst() {
+       if [[ -z ${REPLACING_VERSIONS} ]] ; then
+               elog "This package installs 'lesspipe.sh' which is distinct 
from 'lesspipe'."
+               elog "The latter is the Gentoo-specific version.  Make sure to 
update your"
+               elog "LESSOPEN environment variable if you wish to use this 
copy."
+       fi
+}

Reply via email to