[v2] package/bash-completion: new package

Message ID 1515675000-13355-1-git-send-email-romain.naour@smile.fr
State Superseded
Headers show
Series
  • [v2] package/bash-completion: new package
Related show

Commit Message

Romain Naour Jan. 11, 2018, 12:50 p.m.
From: Jeremy Rosen <jeremy.rosen@smile.fr>

Signed-off-by: Jeremy Rosen <jeremy.rosen@smile.fr>
Signed-off-by: Romain Naour <romain.naour@smile.fr>
---
v2: use a install target hook (Baruch)
    install to staging
---
 package/Config.in                            |  1 +
 package/bash-completion/Config.in            |  7 +++++++
 package/bash-completion/bash-completion.hash |  3 +++
 package/bash-completion/bash-completion.mk   | 22 ++++++++++++++++++++++
 4 files changed, 33 insertions(+)
 create mode 100644 package/bash-completion/Config.in
 create mode 100644 package/bash-completion/bash-completion.hash
 create mode 100644 package/bash-completion/bash-completion.mk

Comments

Thomas Petazzoni Jan. 18, 2018, 9:41 p.m. | #1
Hello,

On Thu, 11 Jan 2018 13:50:00 +0100, Romain Naour wrote:

> +define BASH_COMPLETION_INSTALL_FILE
> +	echo ". /usr/share/bash-completion/bash_completion" > $(TARGET_DIR)/etc/bash_completion
> +endef

Who/what is reading this /etc/bash_completion file? Is bash itself
automatically loading this file? I'm asking because on my distro, I
have /etc/bash_completion.d/ and no /etc/bash_completion.

It seems like my bashrc here is automatically
including /usr/share/bash-completion/bash_completion, and otherwise
falls back to /etc/bash_completion:

  if [ -f /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion
  elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
  fi

Basically, my concerns are:

 - You are using ">" for the redirection. Are we going to be the only
   package writing to this file?

 - Do we support having other packages contribute additional bash
   completion logic?

Thanks!

Thomas
Romain Naour Jan. 19, 2018, 3 p.m. | #2
Hi Thomas,

Le 18/01/2018 à 22:41, Thomas Petazzoni a écrit :
> Hello,
> 
> On Thu, 11 Jan 2018 13:50:00 +0100, Romain Naour wrote:
> 
>> +define BASH_COMPLETION_INSTALL_FILE
>> +	echo ". /usr/share/bash-completion/bash_completion" > $(TARGET_DIR)/etc/bash_completion
>> +endef
> 
> Who/what is reading this /etc/bash_completion file? Is bash itself
> automatically loading this file? I'm asking because on my distro, I
> have /etc/bash_completion.d/ and no /etc/bash_completion.

I'm using different Linux distribution and the bash_completion install is not
the same everywhere.

The bash-completion package install bash_completion script in
/usr/share/bash-completion/bash_completion and all completion script to
/usr/share/bash-completion/completion.

So, I guess that files located un /etc/bash_completion.h is distribution specific.

On my Fedora 27 I noticed that /etc/bash_completion is a symlink to
/usr/share/bash-completion/bash_completion.

On my Ubuntu 16.04 I have /etc/bash_completion.d/ and /etc/bash_completion script.

> 
> It seems like my bashrc here is automatically
> including /usr/share/bash-completion/bash_completion, and otherwise
> falls back to /etc/bash_completion:
> 
>   if [ -f /usr/share/bash-completion/bash_completion ]; then
>     . /usr/share/bash-completion/bash_completion
>   elif [ -f /etc/bash_completion ]; then
>     . /etc/bash_completion
>   fi

Same here with my Ubuntu 16.04.

> 
> Basically, my concerns are:
> 
>  - You are using ">" for the redirection. Are we going to be the only
>    package writing to this file?

I'll check this indeed.
The Buildroot Makefile take care to remove /etc/bash_completion when bash is not
selected. This means that some packages install some stuff here.

> 
>  - Do we support having other packages contribute additional bash
>    completion logic?

I'm wondering if we should let the user decide how to their
bash_completion/bashrc settings.

Best regards,
Romain

> 
> Thanks!
> 
> Thomas
>

Patch

diff --git a/package/Config.in b/package/Config.in
index 01f4095..d41d855 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -1892,6 +1892,7 @@  comment "Shells"
 	source "package/zsh/Config.in"
 comment "Utilities"
 	source "package/at/Config.in"
+	source "package/bash-completion/Config.in"
 	source "package/ccrypt/Config.in"
 	source "package/crudini/Config.in"
 	source "package/dialog/Config.in"
diff --git a/package/bash-completion/Config.in b/package/bash-completion/Config.in
new file mode 100644
index 0000000..597c928
--- /dev/null
+++ b/package/bash-completion/Config.in
@@ -0,0 +1,7 @@ 
+config BR2_PACKAGE_BASH_COMPLETION
+	bool "bash completion"
+	depends on BR2_PACKAGE_BASH
+	help
+	  Add bash completion infrastructure.
+
+	  https://github.com/scop/bash-completion
diff --git a/package/bash-completion/bash-completion.hash b/package/bash-completion/bash-completion.hash
new file mode 100644
index 0000000..facbeb0
--- /dev/null
+++ b/package/bash-completion/bash-completion.hash
@@ -0,0 +1,3 @@ 
+# Locally calculated
+sha256 41ba892d3f427d4a686de32673f35401bc947a7801f684127120cdb13641441e  bash-completion-2.7.tar.xz
+sha256 ab15fd526bd8dd18a9e77ebc139656bf4d33e97fc7238cd11bf60e2b9b8666c6  COPYING
diff --git a/package/bash-completion/bash-completion.mk b/package/bash-completion/bash-completion.mk
new file mode 100644
index 0000000..b6606ad
--- /dev/null
+++ b/package/bash-completion/bash-completion.mk
@@ -0,0 +1,22 @@ 
+################################################################################
+#
+# bash-completion
+#
+################################################################################
+
+BASH_COMPLETION_VERSION = 2.7
+BASH_COMPLETION_SITE = https://github.com/scop/bash-completion/releases/download/$(BASH_COMPLETION_VERSION)
+BASH_COMPLETION_SOURCE = bash-completion-$(BASH_COMPLETION_VERSION).tar.xz
+BASH_COMPLETION_LICENSE = GPL-2.0+
+BASH_COMPLETION_LICENSE_FILES = COPYING
+
+# Install bash-completion.pc file
+BASH_COMPLETION_INSTALL_STAGING = YES
+
+define BASH_COMPLETION_INSTALL_FILE
+	echo ". /usr/share/bash-completion/bash_completion" > $(TARGET_DIR)/etc/bash_completion
+endef
+
+BASH_COMPLETION_POST_INSTALL_TARGET_HOOKS += BASH_COMPLETION_INSTALL_FILE
+
+$(eval $(autotools-package))