fixed bash completion

resolves: rhbz#1207668
This commit is contained in:
Jaroslav Škarvada 2015-04-02 10:28:12 +02:00
parent 940f6ede64
commit 92e761999b
2 changed files with 108 additions and 2 deletions

View File

@ -0,0 +1,100 @@
From 15dc0865f0b47b7f430c8c2c9fcc39b2169d0a07 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jaroslav=20=C5=A0karvada?= <jskarvad@redhat.com>
Date: Wed, 1 Apr 2015 18:11:19 +0200
Subject: [PATCH] Fixed bash completion
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Resolves: rhbz#1207668
Signed-off-by: Jaroslav Škarvada <jskarvad@redhat.com>
---
diff --git a/Makefile b/Makefile
index abda771..792ec05 100644
--- a/Makefile
+++ b/Makefile
@@ -9,7 +9,7 @@ DESTDIR = /
DOCDIR = /usr/share/doc/$(NAME)
PYTHON_SITELIB = /usr/lib/python2.7/site-packages
TUNED_PROFILESDIR = /usr/lib/tuned
-BASH_COMPLETIONS = /usr/share/bash-completion/completions/
+BASH_COMPLETIONS = /usr/share/bash-completion/completions
archive: clean
mkdir -p $(VERSIONED_NAME)
@@ -17,8 +17,9 @@ archive: clean
cp AUTHORS COPYING INSTALL README $(VERSIONED_NAME)
cp tuned.py tuned.spec tuned.service tuned.tmpfiles Makefile tuned-adm.py \
- tuned.bash dbus.conf recommend.conf tuned-main.conf 00_tuned bootcmdline \
- org.tuned.gui.policy tuned-gui.py tuned-gui.glade $(VERSIONED_NAME)
+ tuned-adm.bash dbus.conf recommend.conf tuned-main.conf 00_tuned \
+ bootcmdline org.tuned.gui.policy tuned-gui.py tuned-gui.glade \
+ $(VERSIONED_NAME)
cp -a doc experiments libexec man profiles systemtap tuned $(VERSIONED_NAME)
tar cjf $(VERSIONED_NAME).tar.bz2 $(VERSIONED_NAME)
@@ -62,8 +63,8 @@ install:
cp -a profiles/* $(DESTDIR)$(TUNED_PROFILESDIR)/
install -pm 0644 recommend.conf $(DESTDIR)$(TUNED_PROFILESDIR)/recommend.conf
- # Install bash completion
- install -Dpm 0644 tuned.bash $(DESTDIR)$(BASH_COMPLETIONS)/tuned/tuned.bash
+ # bash completion
+ install -Dpm 0644 tuned-adm.bash $(DESTDIR)$(BASH_COMPLETIONS)/tuned-adm
# log dir
mkdir -p $(DESTDIR)/var/log/tuned
diff --git a/tuned-adm.bash b/tuned-adm.bash
new file mode 100644
index 0000000..9fc2780
--- /dev/null
+++ b/tuned-adm.bash
@@ -0,0 +1,19 @@
+# bash completion for tuned-adm
+
+_tuned_adm()
+{
+ local commands="active list off profile recommend"
+ local cur prev words cword
+ _init_completion || return
+
+ if [[ "$cword" -eq 1 ]]; then
+ COMPREPLY=( $(compgen -W "$commands" -- "$cur" ) )
+ elif [[ "$cword" -eq 2 && "$prev" == "profile" ]]; then
+ COMPREPLY=( $(compgen -W "$(command find /usr/lib/tuned /etc/tuned -mindepth 1 -maxdepth 1 -type d -printf "%f\n")" -- "$cur" ) )
+ else
+ COMPREPLY=()
+ fi
+
+ return 0
+} &&
+complete -F _tuned_adm tuned-adm
diff --git a/tuned.bash b/tuned.bash
deleted file mode 100644
index 8603b8f..0000000
--- a/tuned.bash
+++ /dev/null
@@ -1,19 +0,0 @@
-# bash completion for tuned-adm
-
-_tuned_adm()
-{
- local commands="active list off profile recommend"
- local current="${COMP_WORDS[$COMP_CWORD]}"
- local previous="${COMP_WORDS[$COMP_CWORD-1]}"
-
- if [[ $COMP_CWORD -eq 1 ]]; then
- COMPREPLY=( $(compgen -W "$commands" -- "$current" ) )
- elif [[ $COMP_CWORD -eq 2 && "$previous" == "profile" ]]; then
- COMPREPLY=( $(compgen -W "$(command find /usr/lib/tuned /etc/tuned -mindepth 1 -maxdepth 1 -type d -printf "%f\n")" -- "$current" ) )
- else
- COMPREPLY=()
- fi
-
- return 0
-} &&
-complete -F _tuned_adm tuned-adm
--
2.1.0

View File

@ -1,7 +1,7 @@
Summary: A dynamic adaptive system tuning daemon Summary: A dynamic adaptive system tuning daemon
Name: tuned Name: tuned
Version: 2.4.1 Version: 2.4.1
Release: 3%{?dist} Release: 4%{?dist}
License: GPLv2+ License: GPLv2+
Source: https://fedorahosted.org/releases/t/u/tuned/tuned-%{version}.tar.bz2 Source: https://fedorahosted.org/releases/t/u/tuned/tuned-%{version}.tar.bz2
URL: https://fedorahosted.org/tuned/ URL: https://fedorahosted.org/tuned/
@ -14,6 +14,7 @@ Requires: python-decorator, dbus-python, pygobject3-base, python-pyudev
Requires: virt-what, python-configobj, ethtool, gawk, kernel-tools, hdparm Requires: virt-what, python-configobj, ethtool, gawk, kernel-tools, hdparm
Requires: util-linux Requires: util-linux
Patch0: tuned-2.4.1-powertop2tuned-keyerror-fix.patch Patch0: tuned-2.4.1-powertop2tuned-keyerror-fix.patch
Patch1: tuned-2.4.1-bashcomp-fix.patch
%description %description
The tuned package contains a daemon that tunes system settings dynamically. The tuned package contains a daemon that tunes system settings dynamically.
@ -83,6 +84,7 @@ It can be also used to fine tune your system for specific scenarios.
%prep %prep
%setup -q %setup -q
%patch0 -p1 %patch0 -p1
%patch1 -p1
%build %build
@ -141,7 +143,7 @@ fi
%doc COPYING %doc COPYING
%doc README %doc README
%doc doc/TIPS.txt %doc doc/TIPS.txt
%{_datadir}/bash-completion/completions/tuned %{_datadir}/bash-completion/completions/tuned-adm
%exclude %{python_sitelib}/tuned/gtk %exclude %{python_sitelib}/tuned/gtk
%{python_sitelib}/tuned %{python_sitelib}/tuned
%{_sbindir}/tuned %{_sbindir}/tuned
@ -229,6 +231,10 @@ fi
%{_mandir}/man7/tuned-profiles-compat.7* %{_mandir}/man7/tuned-profiles-compat.7*
%changelog %changelog
* Thu Apr 2 2015 Jaroslav Škarvada <jskarvad@redhat.com> - 2.4.1-4
- fixed bash completion
resolves: rhbz#1207668
* Fri Jan 9 2015 Jaroslav Škarvada <jskarvad@redhat.com> - 2.4.1-3 * Fri Jan 9 2015 Jaroslav Škarvada <jskarvad@redhat.com> - 2.4.1-3
- fixed KeyError exception in powertop2tuned - fixed KeyError exception in powertop2tuned