threads / rfc / 23095

RFC v2RPM spec: optionally include bash completion support

Subject: [PATCH/RFC v2] RPM spec: optionally include bash completion support

## tl;dr

8 messages between Mar 20, 2010 and Mar 21, 2010. Diffs are folded; open one to read it.

replies: 7people: 4as markdown or json

Ian Ward Comfort· Mar 20, 2010, 00:32 UTC · lore

Include the bash completion routines from contrib/ in our core RPM, in the standard system-wide location, when our spec is built "--with completion". The completion routines are not packaged by default. ---

 git.spec.in |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
Show changes to git.spec.in +7 −0
diff --git a/git.spec.in b/git.spec.in
index ee74a5e..65a0db8 100644
--- a/git.spec.in
+++ b/git.spec.in
@@ -1,4 +1,5 @@
 # Pass --without docs to rpmbuild if you don't want the documentation
+# Pass --with completion to rpmbuild if you want shell completion support
 
 Name: 		git
 Version: 	@@VERSION@@
@@ -127,6 +128,11 @@ find $RPM_BUILD_ROOT -type f -name perllocal.pod -exec rm -f {} ';'
 rm -rf $RPM_BUILD_ROOT%{_mandir}
 %endif
 
+%if %{?_with_completion:1}0
+mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/bash_completion.d
+install -m 644 -T contrib/completion/git-completion.bash $RPM_BUILD_ROOT%{_sysconfdir}/bash_completion.d/git
+%endif
+
 %clean
 rm -rf $RPM_BUILD_ROOT
 
@@ -136,6 +142,7 @@ rm -rf $RPM_BUILD_ROOT
 %doc README COPYING Documentation/*.txt
 %{!?_without_docs: %doc Documentation/*.html Documentation/howto}
 %{!?_without_docs: %doc Documentation/technical}
+%{?_with_completion: %{_sysconfdir}/bash_completion.d}
 
 %files svn
 %defattr(-,root,root)
-- 
1.7.0.2
Ben Walton· Mar 20, 2010, 18:18 UTC · re: Ian Ward Comfort · lore

[PATCH] Add a git-completion rpm subpackage to the spec

Make the rpm spec file create a git-completion subpackage that contains the bash completion support from the contrib/ directory.

Signed-off-by: Ben Walton <bwalton@artsci.utoronto.ca>
---

This is the alternate method for shipping the bash completion support. I think I personally prefer this method, but I'd be happy to see either solution ship as part of the .spec file so that I don't need to continue handling it separately.

 git.spec.in |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
Show changes to git.spec.in +17 −0
diff --git a/git.spec.in b/git.spec.in
index ee74a5e..d59747a 100644
--- a/git.spec.in
+++ b/git.spec.in
@@ -80,6 +80,13 @@ Requires:       git = %{version}-%{release}, tk >= 8.4
 %description gui
 Git GUI tool
 
+%package completion
+Summary:	Bash completion support for Git
+Group:		Development/Tools
+Requires:	git = %{version}-${release}, bash
+%description completion
+Bash completion support for Git
+
 %package -n gitk
 Summary:        Git revision tree visualiser ('gitk')
 Group:          Development/Tools
@@ -113,6 +120,8 @@ rm -rf $RPM_BUILD_ROOT
 make %{_smp_mflags} CFLAGS="$RPM_OPT_FLAGS" DESTDIR=$RPM_BUILD_ROOT \
      %{path_settings} \
      INSTALLDIRS=vendor install %{!?_without_docs: install-doc}
+mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/bash_completion.d
+install -m 644 -T contrib/completion/git-completion.bash $RPM_BUILD_ROOT/%{_sysconfdir}/bash_completion.d/git
 test ! -d $RPM_BUILD_ROOT%{python_sitelib} || rm -fr $RPM_BUILD_ROOT%{python_sitelib}
 find $RPM_BUILD_ROOT -type f -name .packlist -exec rm -f {} ';'
 find $RPM_BUILD_ROOT -type f -name '*.bs' -empty -exec rm -f {} ';'
@@ -177,6 +186,10 @@ rm -rf $RPM_BUILD_ROOT
 %{!?_without_docs: %{_mandir}/man1/git-citool.1*}
 %{!?_without_docs: %doc Documentation/git-citool.html}
 
+%files completion
+%defattr(-,root,root)
+%{_sysconfdir}/bash_completion.d/git
+
 %files -n gitk
 %defattr(-,root,root)
 %doc Documentation/*gitk*.txt
@@ -192,6 +205,10 @@ rm -rf $RPM_BUILD_ROOT
 # No files for you!
 
 %changelog
+* Sat Mar 20 2010 Ben Walton <bwalton@artsci.utoronto.ca>
+- Add git-completion subpackage to distribute bash completion from
+  contrib.
+
 * Sun Jan 31 2010 Junio C Hamano <gitster@pobox.com>
 - Do not use %define inside %{!?...} construct.
 
-- 
1.7.0
Junio C Hamano· Mar 20, 2010, 20:12 UTC · re: Ben Walton · lore

Re: [PATCH] Add a git-completion rpm subpackage to the spec

Ben Walton <bwalton@artsci.utoronto.ca> writes:
Show 10 quoted lines
> Make the rpm spec file create a git-completion subpackage that
> contains the bash completion support from the contrib/ directory.
>
> Signed-off-by: Ben Walton <bwalton@artsci.utoronto.ca>
> ---
>
> This is the alternate method for shipping the bash completion support.
> I think I personally prefer this method, but I'd be happy to see
> either solution ship as part of the .spec file so that I don't need to
> continue handling it separately.

As long as %{_sysconfdir}/bash_completion.d/ is the appropriate place for *all* RPM based distros, which I don't knonw, the patch looks sensible. May I ask for what distribution you are "handling it"? The last thing I want to do is to get in the way of distro packagers.

I looked for "gitcompletion" or "git-completion" in rpmfind.net, but didn't find anything, which may actually be a good sign that whatever we do here won't stomp on whatever distro package maintainers would do.

Ian Ward Comfort· Mar 20, 2010, 21:01 UTC · re: Junio C Hamano · lore

Re: [PATCH] Add a git-completion rpm subpackage to the spec

On 20 Mar 2010, at 1:12 PM, Junio C Hamano wrote:
Show 19 quoted lines
> Ben Walton <bwalton@artsci.utoronto.ca> writes:
>
>> Make the rpm spec file create a git-completion subpackage that
>> contains the bash completion support from the contrib/ directory.
>>
>> Signed-off-by: Ben Walton <bwalton@artsci.utoronto.ca>
>> ---
>>
>> This is the alternate method for shipping the bash completion  
>> support.
>> I think I personally prefer this method, but I'd be happy to see
>> either solution ship as part of the .spec file so that I don't need  
>> to
>> continue handling it separately.
>
> As long as %{_sysconfdir}/bash_completion.d/ is the appropriate  
> place for
> *all* RPM based distros, which I don't knonw, the patch looks  
> sensible.

The spec file provided by the author of bash-completion, Ian Macdonald, uses this path:

	http://www.caliban.org/files/redhat/SPECS/bash-completion.spec
As does the Fedora Project (including EPEL):
	http://cvs.fedoraproject.org/viewvc/rpms/bash-completion/F-13/bash-completion.spec?view=markup
	http://cvs.fedoraproject.org/viewvc/rpms/bash-completion/EL-5/bash-completion.spec?view=markup
OpenSUSE 11 does not appear to ship bash-completion:
	http://en.opensuse.org/Package_List/11.2/DVD9
But OpenSUSE 10.3 used the same path:
	http://www.novell.com/products/linuxpackages/opensuse/bash-completion.html
Mandriva uses the same path:
	http://svn.mandriva.com/cgi-bin/viewvc.cgi/packages/cooker/bash-completion/current/SPECS/bash-completion.spec?view=markup
That's all the definitive information I can find at the moment.
-- 
Ian Ward Comfort <icomfort@stanford.edu>
Systems Team Lead, Academic Computing Services, Stanford University
Ben Walton· Mar 20, 2010, 21:14 UTC · re: Junio C Hamano · lore

Re: [PATCH] Add a git-completion rpm subpackage to the spec

Excerpts from Junio C Hamano's message of Sat Mar 20 16:12:34 -0400 2010:
> looks sensible.  May I ask for what distribution you are "handling
> it"?  The last thing I want to do is to get in the way of distro
> packagers.

I can't say it's _the_ global definition for RPM based distros, but I suspect the redhat derived ones would use this location. I'm working against RHEL5.

The info that Ian provides seems to corroborate this hypothesis.

HTH. -Ben

-- 
Ben Walton
Systems Programmer - CHASS
University of Toronto
C:416.407.5610 | W:416.978.4302
Junio C Hamano· Mar 21, 2010, 01:20 UTC · re: Ben Walton · lore

Re: [PATCH] Add a git-completion rpm subpackage to the spec

Ben Walton <bwalton@artsci.utoronto.ca> writes:
Show 13 quoted lines
> Excerpts from Junio C Hamano's message of Sat Mar 20 16:12:34 -0400 2010:
>
>> looks sensible.  May I ask for what distribution you are "handling
>> it"?  The last thing I want to do is to get in the way of distro
>> packagers.
>
> I can't say it's _the_ global definition for RPM based distros, but I
> suspect the redhat derived ones would use this location.  I'm working
> against RHEL5.
>
> The info that Ian provides seems to corroborate this hypothesis.
>
> HTH.
Yes, it helps a lot---thank you, both!
Will queue.
Todd Zullinger· Mar 21, 2010, 15:51 UTC · re: Ben Walton · lore

Re: [PATCH] Add a git-completion rpm subpackage to the spec

Ben Walton wrote:
Show 12 quoted lines
> Excerpts from Junio C Hamano's message of Sat Mar 20 16:12:34 -0400
> 2010:
>
>> looks sensible.  May I ask for what distribution you are "handling
>> it"?  The last thing I want to do is to get in the way of distro
>> packagers.
>
> I can't say it's _the_ global definition for RPM based distros, but
> I suspect the redhat derived ones would use this location.  I'm
> working against RHEL5.
>
> The info that Ian provides seems to corroborate this hypothesis.

FWIW, upstream bash-completion is no longer handled by Ian. The current upstream is at http://bash-completion.alioth.debian.org/

The paths haven't changed currently, though I thought I read that eventually they'd like to move the default location for completion scripts to /usr/share/bash-completion/ (many are already installed there, but are symlinked to /etc/bash_completion.d by bash-completion packages (in the Fedora/EPEL packages via %triggers when the applications they complete are installed).

Also worth noting for RHEL/CentOS 5 folks is that the current Fedora packages should rebuild cleanly on those systems. Typically, I do this via mock, which sets some of the needed rpm macros, but they are also available in the buildsys-macros package¹. I'm hoping to move git in EPEL to a newer version at some point but I haven't made time to do so yet.

I also haven't made time to see what, if any, of the changes we've made in the Fedora packages might be worthwhile to integrate into the git.git rpm spec file. :/

The Fedora packages install the completion scripts by default. The completion is only sourced when someone has installed bash-completion, so the thought is that if you installed that you would want git to provide completion by default. For those that only want git completion without the more general bash-completion package, it's simple to source /etc/bash_completion.d/git. In that light, is there a compelling reason not to install the completion by default?

¹ http://buildsys.fedoraproject.org/buildgroups/rhel5/i386/
  The may eventually be added to the epel-release package to make it
  simpler to rebuild EPEL packages (and Fedora packages on EPEL).
-- 
Todd        OpenPGP -> KeyID: 0xBEAF0CE3 | URL: www.pobox.com/~tmz/pgp
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
People are crazy and times are strange
I'm locked in tight, I'm out of range
I used to care, but things have changed
Ben Walton· Mar 21, 2010, 20:06 UTC · re: Todd Zullinger · lore

Re: [PATCH] Add a git-completion rpm subpackage to the spec

Excerpts from Todd Zullinger's message of Sun Mar 21 11:51:56 -0400 2010:
Hi Todd,
Show 6 quoted lines
> The paths haven't changed currently, though I thought I read that
> eventually they'd like to move the default location for completion
> scripts to /usr/share/bash-completion/ (many are already installed
> there, but are symlinked to /etc/bash_completion.d by
> bash-completion packages (in the Fedora/EPEL packages via %triggers
> when the applications they complete are installed).
Should this be taken as:
* Eventually, /etc/bash_completion will source files directly from
  /usr/share/...
OR
* To play nice with the distros, triggers and symlinks are the way to
  go after installing to /usr/share/...?
> I also haven't made time to see what, if any, of the changes we've
> made in the Fedora packages might be worthwhile to integrate into
> the git.git rpm spec file. :/

I just took a look at the spec from 1.7.0.1-1 in rawhide. Some of the stuff it includes is Fedora/RHEL specific, but a few items that I wouldn't mind seeing merged into the stock .spec file are the splitting of the daemon package with the addition of an xinetd.d/git file and the emacs support subpackage.

I also like the gitweb sub-package, but it doesn't meet the (site specific) needs I have for deployment...In general, I think support in the standard .spec for it is a good thing though.

> simple to source /etc/bash_completion.d/git.  In that light, is
> there a compelling reason not to install the completion by default?

Well, that's a good point. I think my personal inclination for a separate package comes from having it separated in OpenCSW. Most of the reasons for a separate package there likely don't apply here though, so maybe it should be part of git-core? As I said when I sent the alternate (separate rpm) version, I'm happy with either solution as long as the completion support is more easily available when I build rpms in the future.

Thanks -Ben

-- 
Ben Walton
Systems Programmer - CHASS
University of Toronto
C:416.407.5610 | W:416.978.4302

← back to recent threads