[PATCH] install bash completion for oo* wrappers when enabled (bnc#665402)

Petr Mladek pmladek at suse.cz
Wed Jan 19 09:51:37 PST 2011


---
 bin/bash-completion.in          |    8 ++++----
 bin/generate-bash-completion    |   19 +++++++++++++++++++
 bin/package-ooo                 |    7 +++++++
 bin/piece/file-list-postprocess |    8 ++++++--
 4 files changed, 36 insertions(+), 6 deletions(-)

diff --git a/bin/bash-completion.in b/bin/bash-completion.in
index 30f4c9c..77087c5 100644
--- a/bin/bash-completion.in
+++ b/bin/bash-completion.in
@@ -1,4 +1,4 @@
-# Programmable bash_completion file for the main OpenOffice.org applications
+# Programmable bash_completion file for the main office applications
 # It is based on /etc/profile.d/complete.bash from SUSE Linux 10.1
 
 _def=; _dir=; _file=; _nosp=
@@ -16,8 +16,8 @@ if complete -o nospace _nullcommand &> /dev/null ; then
 fi
 complete -r _nullcommand &> /dev/null
 
-# General OOo expanding shell function
-_ooexp_ ()
+# General expanding shell function
+ at OFFICE_SHELL_FUNCTION@ ()
 {
     # bash `complete' is broken because you can not combine
     # -d, -f, and -X pattern without missing directories.
@@ -84,7 +84,7 @@ _ooexp_ ()
 }
 
 
-complete -d -X '.[^./]*' -F _ooexp_ ${_file} \
+complete -d -X '.[^./]*' -F @OFFICE_SHELL_FUNCTION@ ${_file} \
 @BASH_COMPLETION_OOO_APPS@
 
 unset _def _dir _file _nosp _minusdd _minusdf
diff --git a/bin/generate-bash-completion b/bin/generate-bash-completion
index 3eb5aea..dafe413 100755
--- a/bin/generate-bash-completion
+++ b/bin/generate-bash-completion
@@ -55,12 +55,15 @@ my %APPS = (
 	writer		=> "lowriter",
 );
 
+my $office_shell_function = "_loexp_";
+
 sub usage()
 {
     print "Script to Generate bash completion for LO wrappers\n\n";
 
     print "Usage: $0 --help\n";
     print "       $0 [--binsuffix=suffix]\n";
+    print "\t\t[--compat-oowrappers]\n";
     print "\t\t[--office=wrapper_name]\n";
     print "\t\t[--master=wrapper_name]\n";
     print "\t\t[--base=wrapper_name]\n";
@@ -78,6 +81,7 @@ sub usage()
     print "Options:\n";
     print "\t--help\t\tprint this help\n";
     print "\t--binsuffix\tdefines a suffix that is added after each wrapper\n";
+    print "\t--compat-oowrappers\tset wrapper names to the old default oo* wrapper names\n";
 
     print "The other options allows to redefine the wrapper names.\n";
     print "The value \"\" can be used to disable any wrapper.\n\n";
@@ -92,6 +96,19 @@ foreach my $arg (@ARGV) {
 	if ( $arg =~ /--help/ ) {
 		usage();
 		exit 0;
+        } elsif ( $arg =~ /--compat-oowrappers/ ) {
+                $APPS{'office'}   = "ooffice";
+                $APPS{'master'}   = "";
+                $APPS{'base'}     = "oobase";
+                $APPS{'calc'}     = "oocalc";
+                $APPS{'draw'}     = "oodraw";
+                $APPS{'impress'}  = "ooimpress";
+                $APPS{'math'}     = "oomath";
+                $APPS{'template'} = "oofromtemplate";
+                $APPS{'unopkg'}   = "unopkg";
+                $APPS{'web'}      = "ooweb";
+                $APPS{'writer'}   = "oowriter";
+                $office_shell_function = "_ooexp_";
 	} elsif ( $arg =~ /--binsuffix=(.*)/ ) {
 		$binsuffix = "$1";
 	} elsif ( $arg =~ /--office=(.*)/ ) {
@@ -202,6 +219,8 @@ open (BCOUTFILE, "> $outfilename") || die "Error: can't open $outfilename for wr
 while (my $line = <BCINFILE>) {
     chomp $line;
 
+    $line =~ s/\@OFFICE_SHELL_FUNCTION\@/$office_shell_function/;
+
     if ($line =~ m/\@BASH_COMPLETION_SUFFIXES_CHECKS\@/) {
 	print_suffixes_checks();
     } elsif ($line =~ m/\@BASH_COMPLETION_OOO_APPS\@/) {
diff --git a/bin/package-ooo b/bin/package-ooo
index 3d6b1a6..7427e29 100755
--- a/bin/package-ooo
+++ b/bin/package-ooo
@@ -127,6 +127,9 @@ fi
 # create bash completion
 mkdir -p $OODESTDIR/etc/bash_completion.d
 $TOOLSDIR/bin/generate-bash-completion --binsuffix="$BINSUFFIX" $TOOLSDIR/bin/bash-completion.in $OODESTDIR/etc/bash_completion.d/libreoffice${BINSUFFIX}.sh
+if test "$COMPAT_OOWRAPPERS" = "YES" ; then
+    $TOOLSDIR/bin/generate-bash-completion --compat-oowrappers --binsuffix="$BINSUFFIX"  $TOOLSDIR/bin/bash-completion.in $OODESTDIR/etc/bash_completion.d/ooffice${BINSUFFIX}.sh
+fi
 
 if test "z$VENDORNAME" != "zRedHat"; then
 	mkdir -p $MANDIR/man1
@@ -952,6 +955,10 @@ else
 	mv usr/share/man/man1/libreoffice$BINSUFFIX.1 \
 		pkg/libreoffice-common/usr/share/man/man1
 	mkdir -p pkg/libreoffice-common/etc/bash_completion.d
+	if test "$COMPAT_OOWRAPPERS" = "YES" ; then
+		mv etc/bash_completion.d/ooffice$BINSUFFIX.sh \
+			pkg/libreoffice-common/etc/bash_completion.d
+	fi
 	mv etc/bash_completion.d/libreoffice$BINSUFFIX.sh \
 		pkg/libreoffice-common/etc/bash_completion.d
 	mv .$OOINSTBASE/basis$VERSION/program/java-set-classpath \
diff --git a/bin/piece/file-list-postprocess b/bin/piece/file-list-postprocess
index efe0d68..d0252ab 100755
--- a/bin/piece/file-list-postprocess
+++ b/bin/piece/file-list-postprocess
@@ -24,8 +24,12 @@ fi
 
 # create bash completion
 mkdir -p $DESTDIR/etc/bash_completion.d
-$OO_TOOLSDIR/generate-bash-completion --binsuffix="$BINSUFFIX" $OO_TOOLSDIR/bash-completion.in $DESTDIR/etc/bash_completion.d/ooffice${BINSUFFIX}.sh || exit 1;
-echo /etc/bash_completion.d/ooffice${BINSUFFIX}.sh >>files-$piece.txt
+$OO_TOOLSDIR/generate-bash-completion --binsuffix="$BINSUFFIX" $OO_TOOLSDIR/bash-completion.in $DESTDIR/etc/bash_completion.d/libreoffice${BINSUFFIX}.sh || exit 1;
+echo /etc/bash_completion.d/libreoffice${BINSUFFIX}.sh >>files-$piece.txt
+if test "$COMPAT_OOWRAPPERS" == 'YES' ; then
+    $OO_TOOLSDIR/generate-bash-completion --compat-oowrappers --binsuffix="$BINSUFFIX" $OO_TOOLSDIR/bash-completion.in $DESTDIR/etc/bash_completion.d/ooffice${BINSUFFIX}.sh || exit 1;
+    echo /etc/bash_completion.d/ooffice${BINSUFFIX}.sh >>files-$piece.txt
+fi
 
 echo "Installing $OO_INSTDIR/basis$VERSION/program/java-set-classpath"
 sed -e "s|@OOINSTBASE@|$OO_INSTDIR|g" $OO_TOOLSDIR/java-set-classpath.in >$DESTDIR$OO_INSTDIR/basis$VERSION/program/java-set-classpath || exit 1;
-- 
1.7.3.4


--=-IfrYPqVd1pbDcdw65f4h--



More information about the LibreOffice mailing list