[Rpm-metadata] [PATCH] Add bash completion.

Ville Skyttä ville.skytta at iki.fi
Fri Feb 19 19:45:39 UTC 2010


---
 Makefile        |    6 +++-
 createrepo.bash |   96 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 createrepo.spec |    3 +-
 3 files changed, 103 insertions(+), 2 deletions(-)
 create mode 100644 createrepo.bash

diff --git a/Makefile b/Makefile
index 918614f..6b907d8 100644
--- a/Makefile
+++ b/Makefile
@@ -33,7 +33,8 @@ pkgincludedir = $(includedir)/$(PKGNAME)
 top_builddir = 
 
 # all dirs
-DIRS = $(DESTDIR)$(bindir) $(DESTDIR)$(sysconfdir) $(DESTDIR)$(pkgdatadir) $(DESTDIR)$(mandir)
+DIRS = $(DESTDIR)$(bindir) $(DESTDIR)$(sysconfdir)/bash_completion.d \
+	$(DESTDIR)$(pkgdatadir) $(DESTDIR)$(mandir)
 
 
 # INSTALL scripts 
@@ -63,6 +64,7 @@ check:
 
 install: all installdirs
 	$(INSTALL_MODULES) $(srcdir)/$(MODULES) $(DESTDIR)$(pkgdatadir)
+	$(INSTALL_DATA) $(PKGNAME).bash $(DESTDIR)$(sysconfdir)/bash_completion.d
 	for subdir in $(SUBDIRS) ; do \
 	  $(MAKE) -C $$subdir install VERSION=$(VERSION) PKGNAME=$(PKGNAME); \
 	done
@@ -152,6 +154,7 @@ dailyfiles:
 	$(srcdir)/COPYING.lib \
 	$(srcdir)/README \
 	$(srcdir)/$(PKGNAME).spec \
+	$(srcdir)/$(PKGNAME).bash \
 	$(top_srcdir)/.disttmp/$$distdir
 	for subdir in $(SUBDIRS) ; do \
 	  $(MAKE) -C $$subdir dailyfiles VERSION=$(VERSION) PKGNAME=$(PKGNAME); \
@@ -167,6 +170,7 @@ distfiles:
 	$(srcdir)/COPYING.lib \
 	$(srcdir)/README \
 	$(srcdir)/$(PKGNAME).spec \
+	$(srcdir)/$(PKGNAME).bash \
 	$(top_srcdir)/.disttmp/$$distdir
 	for subdir in $(SUBDIRS) ; do \
 	  $(MAKE) -C $$subdir distfiles VERSION=$(VERSION) PKGNAME=$(PKGNAME); \
diff --git a/createrepo.bash b/createrepo.bash
new file mode 100644
index 0000000..3e2e7fe
--- /dev/null
+++ b/createrepo.bash
@@ -0,0 +1,96 @@
+# bash completion for createrepo and friends
+
+_cr_createrepo()
+{
+    COMPREPLY=()
+
+    case $3 in
+        --version|-h|--help|-u|--baseurl|--distro|--content|--revision|\
+        -x|--excludes|--changelog-limit|--max-delta-rpm-size)
+            return 0
+            ;;
+        --basedir|-c|--cachedir|--update-md-path|-o|--outputdir|\
+        --oldpackagedirs)
+            COMPREPLY=( $( compgen -d -- "$2" ) )
+            return 0
+            ;;
+        -g|--groupfile)
+            COMPREPLY=( $( compgen -f -o plusdirs -X '!*.xml' -- "$2" ) )
+            return 0
+            ;;
+        -s|--sumtype)
+            COMPREPLY=( $( compgen -W 'md5 sha1 sha256 sha512' -- "$2" ) )
+            return 0
+            ;;
+        -i|--pkglist|--read-pkgs-list)
+            COMPREPLY=( $( compgen -f -o plusdirs -- "$2" ) )
+            return 0
+            ;;
+        -n|--includepkg)
+            COMPREPLY=( $( compgen -f -o plusdirs -X '!*.rpm' -- "$2" ) )
+            return 0
+            ;;
+        --num-deltas)
+            COMPREPLY=( $( compgen -W '1 2 3 4 5 6 7 8 9' -- "$2" ) )
+            return 0
+            ;;
+    esac
+
+    if [[ $2 == -* ]] ; then
+        COMPREPLY=( $( compgen -W '--version --help --quiet --verbose --profile
+            --excludes --basedir --baseurl --groupfile --checksum --pretty
+            --cachedir --checkts --database --update --update-md-path
+            --skip-stat --split --pkglist --includepkg --outputdir
+            --skip-symlinks --changelog-limit --unique-md-filenames
+            --simple-md-filenames --distro --content --revision --deltas
+            --oldpackagedirs --num-deltas --read-pkgs-list
+            --max-delta-rpm-size' -- "$2" ) )
+    else
+        COMPREPLY=( $( compgen -d -- "$2" ) )
+    fi
+} &&
+complete -F _cr_createrepo -o filenames createrepo genpkgmetadata.py
+
+_cr_mergerepo()
+{
+    COMPREPLY=()
+
+    case $3 in
+        --version|-h|--help|-a|--archlist)
+            return 0
+            ;;
+        -r|--repo|-o|--outputdir)
+            COMPREPLY=( $( compgen -d -- "$2" ) )
+            return 0
+            ;;
+    esac
+
+    COMPREPLY=( $( compgen -W '--version --help --repo --archlist --database
+        --outputdir --nogroups --noupdateinfo' -- "$2" ) )
+} &&
+complete -F _cr_mergerepo -o filenames mergerepo mergerepo.py
+
+_cr_modifyrepo()
+{
+    COMPREPLY=()
+
+    case $COMP_CWORD in
+        1)
+            COMPREPLY=( $( compgen -f -o plusdirs -- "$2" ) )
+            return 0
+            ;;
+        2)
+            COMPREPLY=( $( compgen -d -- "$2" ) )
+            return 0
+            ;;
+    esac
+} &&
+complete -F _cr_modifyrepo -o filenames modifyrepo modifyrepo.py
+
+# Local variables:
+# mode: shell-script
+# sh-basic-offset: 4
+# sh-indent-comment: t
+# indent-tabs-mode: nil
+# End:
+# ex: ts=4 sw=4 et filetype=sh
diff --git a/createrepo.spec b/createrepo.spec
index 57a0196..19db77b 100644
--- a/createrepo.spec
+++ b/createrepo.spec
@@ -22,7 +22,7 @@ rpm packages
 
 %install
 [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
-make DESTDIR=$RPM_BUILD_ROOT install
+make DESTDIR=$RPM_BUILD_ROOT sysconfdir=%{_sysconfdir} install
 
 %clean
 [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
@@ -32,6 +32,7 @@ make DESTDIR=$RPM_BUILD_ROOT install
 %defattr(-, root, root)
 %dir %{_datadir}/%{name}
 %doc ChangeLog README COPYING COPYING.lib
+%{_sysconfdir}/bash_completion.d/
 %{_datadir}/%{name}/*
 %{_bindir}/%{name}
 %{_bindir}/modifyrepo
-- 
1.6.6



More information about the Rpm-metadata mailing list