diff options
| author | David Paleino <d.paleino@gmail.com> | 2009-01-29 14:51:48 +0100 |
|---|---|---|
| committer | David Paleino <d.paleino@gmail.com> | 2009-01-29 14:51:48 +0100 |
| commit | 34ff7bfe8c017762a47eaf439b44fadc46577565 (patch) | |
| tree | aa50cc5b07f1b346f86af8f282878462bd83e8fc /extra | |
| parent | 6a2ff139a00ab0d3cff8fbccc3766c8b6f02ba4e (diff) | |
| download | bash-completion-34ff7bfe8c017762a47eaf439b44fadc46577565.tar.gz | |
* extra/dh_bash-completion:
- updated to support a list of files in debian/<package>.bash-completion
(Closes: #512917)
Diffstat (limited to 'extra')
| -rwxr-xr-x | extra/dh_bash-completion | 71 | ||||
| -rw-r--r-- | extra/dh_bash-completion.1 | 31 |
2 files changed, 80 insertions, 22 deletions
diff --git a/extra/dh_bash-completion b/extra/dh_bash-completion index ccbcaf98..804c5752 100755 --- a/extra/dh_bash-completion +++ b/extra/dh_bash-completion @@ -7,6 +7,7 @@ dh_bash-completion - install bash completions for package =cut use strict; +use File::Find; use Debian::Debhelper::Dh_Lib; =head1 SYNOPSIS @@ -18,15 +19,25 @@ B<dh_bash-completion> [S<I<debhelper options>>] dh_bash-completion is a debhelper program that is responsible for installing completions for bash, usable installing the "bash-completion" package. -If a file named debian/package.bash-completion exists, then it is -installed into etc/bash_completion.d in the package build directory. -This file is used to provide the user with proper completion for available -commands. +If a file named debian/package.bash-completion exists, then different actions +are performed, depending on its format. + +It can be a proper completion snippet, and in that case it would be installed +in the completion directory, and no other actions would be performed. + +It can also be a list of files, with an optionally specified name to call the +completion snippet after. The file format is as follows: + + my/path/to/foo-completion # this would be installed as "foo-completion" + my/path/to/bar-completion baz # this would be installed as "baz" =cut init(); +my $srcdir = '.'; +$srcdir = $dh{SOURCEDIR}."/" if defined $dh{SOURCEDIR}; + foreach my $package (@{$dh{DOPACKAGES}}) { next if is_udeb($package); @@ -34,11 +45,57 @@ foreach my $package (@{$dh{DOPACKAGES}}) { my $bc_dir = "$tmp/etc/bash_completion.d"; my $completions = pkgfile($package,"bash-completion"); - if ($completions ne '') { + my @install; + my $name; + + if ($completions) { if (! -d "$bc_dir") { - doit("install", "-d", "$bc_dir"); + doit("install", "-d", "$bc_dir"); + } + + # try parsing a list of files + @install = filedoublearray($completions); + foreach my $set (@install) { + my @filelist; + my @tmp = @$set; + if (@$set > 1) { + $name = pop @$set; + } + else { + $name = basename($tmp[0]); + } + verbose_print "installing $tmp[0] as $name"; + + my @found; + foreach my $glob (@$set) { + @found = glob "$srcdir/$glob"; + if (!compat(6)) { + # Fall back to looking into debian/tmp + if (!@found || !-e $found[0]) { + @found = glob "debian/tmp/$glob"; + } + } + + if (!@found || !-e $found[0]) { + warning "file-list parsing failed, installing as proper snippet"; + + doit("install", "-p", "-m644", $completions, "$bc_dir/$package"); + exit 0 + } + push @filelist, @found; + } + + if (! compat(4)) { # check added in v5 + # glob now, relative to srcdir + if (!@filelist) { + error("$package missing files (@$set), aborting"); + } + } + + foreach my $src (@filelist) { + doit("install", "-p", $src, "$bc_dir/$name"); + } } - doit("install", "-p", "-m644", $completions, "$bc_dir/$package"); } } diff --git a/extra/dh_bash-completion.1 b/extra/dh_bash-completion.1 index f8ec0bdb..a637b1d5 100644 --- a/extra/dh_bash-completion.1 +++ b/extra/dh_bash-completion.1 @@ -1,15 +1,7 @@ -.\" Automatically generated by Pod::Man 2.16 (Pod::Simple 3.05) +.\" Automatically generated by Pod::Man 2.1801 (Pod::Simple 3.05) .\" .\" Standard preamble: .\" ======================================================================== -.de Sh \" Subsection heading -.br -.if t .Sp -.ne 5 -.PP -\fB\\$1\fR -.PP -.. .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp @@ -53,7 +45,7 @@ .el .ds Aq ' .\" .\" If the F register is turned on, we'll generate index entries on stderr for -.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index +.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .ie \nF \{\ @@ -132,7 +124,7 @@ .\" ======================================================================== .\" .IX Title "DH_BASH-COMPLETION 1" -.TH DH_BASH-COMPLETION 1 "2008-06-22" "20080617.1" "Bash-Completion Debhelper" +.TH DH_BASH-COMPLETION 1 "2009-01-29" "200811xx" "Bash-Completion Debhelper" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -147,10 +139,19 @@ dh_bash\-completion \- install bash completions for package dh_bash\-completion is a debhelper program that is responsible for installing completions for bash, usable installing the \*(L"bash-completion\*(R" package. .PP -If a file named debian/package.bash\-completion exists, then it is -installed into etc/bash_completion.d in the package build directory. -This file is used to provide the user with proper completion for available -commands. +If a file named debian/package.bash\-completion exists, then different actions +are performed, depending on its format. +.PP +It can be a proper completion snippet, and in that case it would be installed +in the completion directory, and no other actions would be performed. +.PP +It can also be a list of files, with an optionally specified name to call the +completion snippet after. The file format is as follows: +.PP +.Vb 2 +\& my/path/to/foo\-completion # this would be installed as "foo\-completion" +\& my/path/to/bar\-completion baz # this would be installed as "baz" +.Ve .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIdebhelper\fR\|(1) |
