[Bash-completion-commits] [SCM] debian-package branch, master, updated. debian/1.3-2-4-g5f5fdf2

David Paleino dapal at debian.org
Mon Apr 25 12:26:31 UTC 2011


The following commit has been merged in the master branch:
commit 56efbc3974a43d517abae555e2ad55a22cc879b7
Author: David Paleino <dapal at debian.org>
Date:   Mon Apr 25 14:19:50 2011 +0200

    Include install-completions from upstream

diff --git a/debian/changelog b/debian/changelog
index 5f4ac20..b9d698e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,8 +1,9 @@
 bash-completion (1:1.3-3) UNRELEASED; urgency=low
 
   * Also add 'man' to whitelist (Closes: #623880)
+  * Include install-completions from upstream
 
- -- David Paleino <dapal at debian.org>  Sun, 24 Apr 2011 09:02:20 +0200
+ -- David Paleino <dapal at debian.org>  Mon, 25 Apr 2011 14:19:31 +0200
 
 bash-completion (1:1.3-2) experimental; urgency=low
 
diff --git a/debian/extra/scripts/update-bash-completion b/debian/extra/scripts/update-bash-completion
index 34b6ff0..6d5d197 100755
--- a/debian/extra/scripts/update-bash-completion
+++ b/debian/extra/scripts/update-bash-completion
@@ -1,35 +1,75 @@
 #!/bin/bash
+# install relevant completions, by sourcing every scriptlet
+# found in a given directory, and symlinking those matching
+# an installed command to another directory
 
-COMPDICT=/usr/share/bash-completion/compdict
-COMPDIR=/usr/share/bash-completion
-RUNCOMPDIR=/var/lib/bash-completion
-
-if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
-    echo "Usage: update-bash-completion [clean]"
-    echo
-    echo "Updates symlinks to relevant bash completions, i.e. completions for installed"
-    echo "executables."
-    echo
-    echo "The \"clean\" option also removes old completions, i.e. for uninstalled"
-    echo "executables."
-
-    exit 0
-elif [ "$1" == "clean" ]; then
-    rm -rf $RUNCOMPDIR/*
+have()
+{
+    PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin type $1 &>/dev/null
+}
+
+usage()
+{
+    echo "usage: $0 <completion_dir> [installation_dir]"
+}
+
+while getopts ":h" flag; do
+    case $flag in
+	h) usage; exit 0;;
+    esac
+done
+
+shift $((OPTIND - 1))
+
+completion_dir=$1
+if [ -z "$completion_dir" ]; then
+    echo "missing completion directory"
+    usage
+    exit 1
+fi
+if [ ! -d $completion_dir ]; then
+    echo "invalid directory $completion_dir"
+    usage
+    exit 1
 fi
 
-commands=$(compgen -f /usr/bin/ ; compgen -f /usr/sbin/ ; compgen -f /usr/games/ ; compgen -f /bin/ ; compgen -f /sbin/)
-commands=$(echo $commands | sed 's, /[^ ]*/,|\n,g;s,/[^ ]*/,,;s,$,|,')
+installation_dir=$2
+if [ ! -d $installation_dir ]; then
+    echo "invalid directory $installation_dir"
+    usage
+    exit 1
+fi
 
-completions=$(grep -w -F "$commands" $COMPDICT | cut -d: -f1 | sort -u)
+# many scripts require this
+shopt -s extglob
 
-for c in $completions; do
-    [ -L "$RUNCOMPDIR/${c##*/}" ] || ln -s $COMPDIR/$c $RUNCOMPDIR/
-done
+# and some require this also
+UNAME=$(uname -s)
+UNAME=${UNAME/CYGWIN_*/Cygwin}
 
-# This should *always* be enabled.
-for comp in bash-builtins man
-do
-    ln -sf $COMPDIR/completions/$comp $RUNCOMPDIR/
-done
+case $UNAME in
+    Linux|GNU|GNU/*) USERLAND=GNU ;;
+    *) USERLAND=$UNAME ;;
+esac
+
+for script in $completion_dir/*; do
+    # reset completion
+    complete -r
+
+    # source script
+    source $script 2>/dev/null
+
+    # check completion output
+    output=$(complete -p)
 
+    if [ -z "$output" ]; then
+	continue
+    fi
+
+    if [ -n "$installation_dir" ]; then
+	ln -sf $script $installation_dir/$(basename $script)
+    else
+	echo "$script OK"
+    fi
+
+done
diff --git a/debian/extra/scripts/update-bash-completion.1 b/debian/extra/scripts/update-bash-completion.1
index 654ca62..9121242 100644
--- a/debian/extra/scripts/update-bash-completion.1
+++ b/debian/extra/scripts/update-bash-completion.1
@@ -1,9 +1,8 @@
-.TH UPDATE-BASH-COMPLETION 1 "Apr 10, 2011"
+.TH UPDATE-BASH-COMPLETION 1 "Apr 25, 2011"
 .SH NAME
 update-bash-completion \- update completions symlinks
 .SH SYNOPSIS
 .B update-bash-completion
-.RI [ clean ]
 .SH DESCRIPTION
 This manual page documents briefly the \fBupdate-bash-completion\fR command.
 .PP
@@ -13,12 +12,8 @@ bash completions for installed programs.
 It is usually run during after the installation of any package installing
 executables under \fI/usr/bin\fR, \fI/usr/sbin\fR, \fI/usr/games\fR,
 \fI/bin\fR or \fI/sbin\fR, but it may also be run manually.
-.SH COMMANDS
-The only command is \fBclean\fR, which removes all the existing symlinks before
-creating them. This should be used to remove old completions, for uninstalled
-packages.
 .SH AUTHOR
-update-bash-completion was written by David Paleino <dapal at debian.org>.
+update-bash-completion was written by Guillaume Rousse <Guillaume.Rousse at inria.fr>.
 .PP
 This manual page was written by David Paleino <dapal at debian.org>,
 for the Debian project (and may be used by others).

-- 
debian-package



More information about the Bash-completion-commits mailing list