[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Quilt-dev] [PATCH] Helper function checking for external tool
From: |
Jean Delvare |
Subject: |
[Quilt-dev] [PATCH] Helper function checking for external tool |
Date: |
Tue, 10 Jun 2014 15:45:15 +0200 |
Introduce a helper function checking for availability of a given
external tool. A standard error message is displayed if the required
tool is not available.
Use this helper function in graph, mail and setup, instead of
duplicating the code.
---
quilt/graph.in | 15 ++-------------
quilt/mail.in | 7 +------
quilt/scripts/patchfns.in | 15 +++++++++++++++
quilt/setup.in | 7 +------
4 files changed, 19 insertions(+), 25 deletions(-)
--- a/quilt/graph.in
+++ b/quilt/graph.in
@@ -109,19 +109,8 @@ then
usage
fi
-if [ "$opt_format" = "ps" ] && ! type dot &> /dev/null
-then
- printf $"You have to install '%s' (from package %s) to use 'quilt
%s'\n" \
- dot graphviz "graph -T" >&2
- exit 1
-fi
-
-if [ -n "$opt_reduce" ] && ! type tred &> /dev/null
-then
- printf $"You have to install '%s' (from package %s) to use 'quilt
%s'\n" \
- tred graphviz "graph --reduce" >&2
- exit 1
-fi
+[ "$opt_format" = "ps" ] && check_external_tool dot graphviz -T
+[ -n "$opt_reduce" ] && check_external_tool tred graphviz --reduce
if [ -z "$opt_all" ]
then
--- a/quilt/mail.in
+++ b/quilt/mail.in
@@ -257,12 +257,7 @@ then
fi
# check if formail is installed before doing anything
-if ! type formail &> /dev/null
-then
- printf $"You have to install '%s' (from package %s) to use 'quilt
%s'\n" \
- formail procmail mail >&2
- exit 1
-fi
+check_external_tool formail procmail
if [ $# -ge 1 ]
then
--- a/quilt/scripts/patchfns.in
+++ b/quilt/scripts/patchfns.in
@@ -979,6 +979,21 @@ quilt_command()
QUILT_COMMAND="" bash $BASH_OPTS -c "${SUBDIR:+cd $SUBDIR;} .
$QUILT_DIR/$command" "quilt $command" "$@"
}
+check_external_tool()
+{
+ local tool=$1 package=$2 options=$3
+ local command=$QUILT_COMMAND
+
+ [ -n "$options" ] && command="$command $options"
+
+ if ! type "$tool" &> /dev/null
+ then
+ printf $"You have to install '%s' (from package %s) to use
'quilt %s'\n" \
+ "$tool" "$package" "$command" >&2
+ exit 1
+ fi
+}
+
declare pager_fifo pager_fifo_dir pager_pid
wait_for_pager()
--- a/quilt/setup.in
+++ b/quilt/setup.in
@@ -174,12 +174,7 @@ case "$1" in
spec_file=$1
# check if rpmbuild is installed before running inspect
- if ! type rpmbuild &> /dev/null
- then
- printf $"You have to install '%s' (from package %s) to use
'quilt %s'\n" \
- rpmbuild rpm-build setup >&2
- exit 1
- fi
+ check_external_tool rpmbuild rpm-build
if ! $QUILT_DIR/scripts/inspect $verbose $opt_sourcedir $opt_fuzz \
"$spec_file" 2>&1 > $tmpfile
--
Jean Delvare
SUSE L3 Support
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Quilt-dev] [PATCH] Helper function checking for external tool,
Jean Delvare <=