]> TLD Linux GIT Repositories - packages/bash-completion.git/commitdiff
- from PLD
authorMarcin Krol <hawk@tld-linux.org>
Mon, 3 Aug 2015 08:21:03 +0000 (08:21 +0000)
committerMarcin Krol <hawk@tld-linux.org>
Mon, 3 Aug 2015 08:21:03 +0000 (08:21 +0000)
bash-completion-poldek.sh [new file with mode: 0644]
bash-completion-rpm-cache.patch [new file with mode: 0644]
bash-completion.spec [new file with mode: 0644]
builder.bash-completion [new file with mode: 0644]
pear.patch [new file with mode: 0644]

diff --git a/bash-completion-poldek.sh b/bash-completion-poldek.sh
new file mode 100644 (file)
index 0000000..3682c47
--- /dev/null
@@ -0,0 +1,66 @@
+# poldek(1) completion
+#
+_poldek()
+{
+       local cur prev
+       cur=${COMP_WORDS[COMP_CWORD]}
+
+       COMPREPLY=()
+
+       case "${COMP_WORDS[1]}" in
+       -@(e|-erase))
+               if [[ "$cur" == -* ]]; then
+                       COMPREPLY=( $( compgen -W '--nodeps --nofollow --test' -- $cur ) )
+               else
+                       _xfunc rpm _rpm_installed_packages
+               fi
+               return 0
+               ;;
+       esac
+
+       prev=${COMP_WORDS[COMP_CWORD-1]}
+
+       case "$prev" in
+       -@(n|-sn))
+               COMPREPLY=( $( poldek -l | awk "/^$cur/{print \$1}" ) )
+               return 0
+               ;;
+       esac
+
+       case "$cur" in
+       --verify*=*,*)
+               local p=${cur#--verify=*,}
+               p=${p//\\} # those backslashes propagate!!! -- kill them
+               # somewhy bash escapes equal sign, so we must match the backslash too
+               COMPREPLY=( $( compgen -P "${p%,*}," -W 'deps conflicts file-conflicts file-orphans file-missing-deps' -- "${cur##*,}" ) )
+               return 0
+               ;;
+       --verify*)
+               # somewhy bash escapes equal sign, so we must match the backslash too
+               COMPREPLY=( $( compgen -P --verify= -W 'deps conflicts file-conflicts file-orphans file-missing-deps' -- "${cur#--verify*=}" ) )
+               return 0
+               ;;
+       --*)
+               COMPREPLY=( $( compgen -W '
+               --mkidx --makeidx --mt --nocompress --nodesc --nodiff --notimestamp
+               --dn --dt --sn --prefix --source --st --clean --clean-pkg
+               --clean-whole --cleana --sl --stl --update --up --update-whole
+               --upa --caplookup --pset --downgrade --install --reinstall
+               --upgrade --install-dist --reinstall-dist --root --upgrade-dist
+               --dump --dumpn --fetch --follow --force --fresh --greedy --hold
+               --ignore --justdb --mercy --nodeps --nohold --noignore --nofollow
+               --parsable-tr-summary --pm-force --pm-nodeps --pmopt --promoteepoch
+               --uniq --test --erase --greedy --nodeps --nofollow --test --verify=
+               --priconf --split --split-out --ask --cachedir --cmd --conf --log
+               --noask --noconf --pmcmd --runas --shell --skip-installed --sudocmd
+               --upconf --help --usage --version
+               ' -- $cur ) )
+               ;;
+       *)
+               COMPREPLY=( $( compgen -W '-F -N -O -P -Q -V -e -i -l -m -n -q -r -s -t -u -v' -- $cur ) )
+               ;;
+       esac
+
+       return 0
+} &&
+complete -F _poldek $nospace $filenames poldek
diff --git a/bash-completion-rpm-cache.patch b/bash-completion-rpm-cache.patch
new file mode 100644 (file)
index 0000000..9c9d401
--- /dev/null
@@ -0,0 +1,22 @@
+Support rpm (jbj rpm 4.4.7+) hrmib exports for rpm -qa filter (via %_hrmib_path /var/cache/hrmib)
+
+Not accepted upstream.
+
+--
+Signed-off-by: Elan Ruusamäe <glen@delfi.ee>
+
+--- bash-completion-2.0/completions/rpm.orig   2012-01-07 23:44:41.000000000 +0100
++++ bash-completion-2.0/completions/rpm        2012-07-28 07:21:12.033708931 +0200
+@@ -4,6 +4,12 @@
+ _rpm_installed_packages()
+ {
++    # if rpm (4.4.7+) is configured to export it's rpmdb to /var/cache/hrmib (%_hrmib_path)
++    if [ -d /var/cache/hrmib -a -r /var/cache/hrmib ]; then
++        COMPREPLY=( $( LC_ALL=C command ls -1 /var/cache/hrmib | sed -ne '/^'$cur'/p') )
++        return
++    fi
++
+     if [[ -r /var/log/rpmpkgs && \
+         /var/log/rpmpkgs -nt /var/lib/rpm/Packages ]]; then
+         # using RHL 7.2 or later - this is quicker than querying the DB
diff --git a/bash-completion.spec b/bash-completion.spec
new file mode 100644 (file)
index 0000000..13ff511
--- /dev/null
@@ -0,0 +1,106 @@
+# vim:ft=spec
+# TODO
+# - use mkinitrd and update for geninitrd
+# - fix vim not to mark this file as bash
+Summary:       bash-completion offers programmable completion for bash
+Summary(pl.UTF-8):     Programowalne uzupełnianie nazw dla basha
+Name:          bash-completion
+Version:       2.1
+Release:       4
+Epoch:         1
+License:       GPL v2+
+Group:         Applications/Shells
+Source0:       http://bash-completion.alioth.debian.org/files/%{name}-%{version}.tar.bz2
+# Source0-md5: 4e2a9f11a4042a38ee79ddcd048e8b9e
+Source1:       %{name}-poldek.sh
+# https://bugs.launchpad.net/ubuntu/+source/mysql-dfsg-5.0/+bug/106975
+Source3:       http://launchpadlibrarian.net/19164189/mysqldump
+# Source3-md5: 09e4885be92e032400ed702f39925d85
+Source4:       http://svn.php.net/viewvc/pear2/sandbox/PEAR_BashCompletion/trunk/pear?revision=285425&view=co?/pear
+# Source4-md5: 8ce77e4459e2c45e2096da8d03c8f43d
+Patch0:                %{name}-rpm-cache.patch
+Patch1:                pear.patch
+URL:           http://bash-completion.alioth.debian.org/
+BuildRequires: sed >= 4.0
+Requires(triggerpostun):       sed >= 4.0
+Requires:      bash >= 4.1
+Requires:      pld-release
+Obsoletes:     bash-completion-rpm-cache
+Conflicts:     rpm < 4.4.9-44
+BuildArch:     noarch
+BuildRoot:     %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
+
+%description
+bash-completion is a collection of shell functions that take advantage
+of the programmable completion feature of bash 4.1 and later.
+
+%description -l pl.UTF-8
+bash-completion jest kolekcją funkcji shella, które opierają się na
+wbudowanych rozszerzeniach basha 4.1 lub późniejszego umożliwiającego
+dopełnianie parametrów linii poleceń.
+
+%prep
+%setup -q
+cp -p '%{SOURCE4}' completions/pear
+%patch0 -p1
+%patch1 -p1
+
+# cleanup backups after patching
+find '(' -name '*~' -o -name '*.orig' ')' -print0 | xargs -0 -r -l512 rm -f
+
+# update path
+%{__sed} -i -e 's#${BASH_SOURCE\[0\]%/\*}#%{_datadir}/%{name}#' completions/perl
+
+%build
+%configure
+%{__make}
+
+%install
+rm -rf $RPM_BUILD_ROOT
+install -d $RPM_BUILD_ROOT%{_sysconfdir}/bash_completion.d
+
+%{__make} install -j1 \
+       INSTALL="install -p" \
+       profiledir=/etc/shrc.d \
+       DESTDIR=$RPM_BUILD_ROOT
+
+cp -p %{SOURCE1} $RPM_BUILD_ROOT%{_datadir}/%{name}/completions/poldek
+cp -p %{SOURCE3} $RPM_BUILD_ROOT%{_datadir}/%{name}/completions/mysqldump
+cp -p completions/pear $RPM_BUILD_ROOT%{_datadir}/%{name}/completions
+
+# util-linux
+%{__rm} $RPM_BUILD_ROOT%{_datadir}/%{name}/completions/{cal,chsh,dmesg,eject,hexdump,hwclock,ionice,look,newgrp,renice,rtcwake,su}
+# No package matches '*/apache2ctl'
+%{__rm} $RPM_BUILD_ROOT%{_datadir}/%{name}/completions/apache2ctl
+# No PLD package or no such binary to complete on
+%{__rm} $RPM_BUILD_ROOT%{_datadir}/%{name}/completions/{larch,lisp,monodevelop,[pg]4,cowsay,cowthink,cpan2dist}
+%{__rm} $RPM_BUILD_ROOT%{_datadir}/%{name}/completions/{mkinitrd,rpmcheck}
+# FreeBSD stuff
+%{__rm} $RPM_BUILD_ROOT%{_datadir}/%{name}/completions/{kldload,portupgrade}
+# Debian stuff
+%{__rm} $RPM_BUILD_ROOT%{_datadir}/%{name}/completions/{apt-build,dselect,reportbug,alternatives,update-alternatives,lintian,lintian-info}
+# NetworkManager stuff
+%{__rm} $RPM_BUILD_ROOT%{_datadir}/%{name}/completions/nmcli
+
+
+# do not generate autodeps
+chmod a-x $RPM_BUILD_ROOT%{_datadir}/%{name}/helpers/perl
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%triggerpostun -- %{name} < 20050721-3.9
+sed -i -e '/^# START bash completion/,/^# END bash completion/d' /etc/bashrc
+
+%files
+%defattr(644,root,root,755)
+%doc AUTHORS CHANGES README
+/etc/shrc.d/bash_completion.sh
+%dir %{_sysconfdir}/bash_completion.d
+%dir %{_datadir}/%{name}
+%{_datadir}/%{name}/bash_completion
+%dir %{_datadir}/%{name}/completions
+%{_datadir}/%{name}/completions/*
+%dir %{_datadir}/%{name}/helpers
+%attr(755,root,root) %{_datadir}/%{name}/helpers/perl
+%{_npkgconfigdir}/bash-completion.pc
diff --git a/builder.bash-completion b/builder.bash-completion
new file mode 100644 (file)
index 0000000..0b081c8
--- /dev/null
@@ -0,0 +1,50 @@
+# PLD Linux builder(1) script completion
+
+# get active spec file from commandline
+# caller should make $spec local variable
+# TODO: it gets it wrong if some option arg is found before spec itself
+_builder_get_spec()
+{
+       local i
+       spec=
+       for (( i=1; i < ${#words[@]}-1; i++ )); do
+               if [[ ${words[i]} != -* ]]; then
+                       spec=${words[i]}
+                       break
+               fi
+       done
+       [[ ! -f $spec ]] && return 0
+}
+
+_builder()
+{
+       local cur prev words cword
+       _init_completion || return
+
+       case $prev in
+       -r)
+               COMPREPLY=( $( compgen -W '$( git tag )' -- "$cur" ) )
+               return 0
+               ;;
+       --with|--without)
+               local spec bconds
+               _builder_get_spec
+               bconds=$(
+                       awk '
+                       /^%changelog/ { exit }
+                       /^%bcond_with/{
+                               print $2
+                       }' $spec
+               )
+               COMPREPLY=( $( compgen -W "$bconds" -- "$cur" ) )
+               return 0
+               ;;
+       esac
+
+       if [[ $cur == -* ]]; then
+               COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
+       else
+               _filedir spec
+       fi
+} &&
+complete -F _builder builder
diff --git a/pear.patch b/pear.patch
new file mode 100644 (file)
index 0000000..d62385e
--- /dev/null
@@ -0,0 +1,16 @@
+--- bash-completion-1.2/completions/pear~      2010-08-23 20:41:58.000000000 +0300
++++ bash-completion-1.2/completions/pear       2010-10-19 22:52:26.008412279 +0300
+@@ -106,6 +106,13 @@
+             _filedir '@(tgz)'
+             return 0
+             ;;
++        make-rpm-spec)
++            if [[ "${cur}" == -* ]] ; then
++                COMPREPLY=( $(compgen -W "-t -o -r -p -d --spec-template --output --rpm-release --rpm-pkgname --rpm-depname" -- ${cur}) )
++            fi
++            _filedir '@(tgz)'
++            return 0
++            ;;
+         package|pickle)
+             if [[ "${cur}" == -* ]] ; then
+                 COMPREPLY=( $(compgen -W "-Z -n --nocompress --showname" -- ${cur}) )