summaryrefslogtreecommitdiff
path: root/scripts/mkc_check_prog
diff options
context:
space:
mode:
authorAndrew Shadura <andrewsh@debian.org>2014-01-05 22:42:41 +0100
committerAndrew Shadura <andrew@shadura.me>2015-07-25 14:44:33 +0200
commitc8659b636be5e763c5dc028a5db7294b1af2648c (patch)
tree7dacf7580ff8c7d8c64682eaa28350bc47fbd56e /scripts/mkc_check_prog
parent004c4cd3db1d9ad252eccbc1e9e6c54ec61a2927 (diff)
parentaba913436a8521abe405a04ed71388989e1d646f (diff)
Imported Debian patch 0.25.0-1
Diffstat (limited to 'scripts/mkc_check_prog')
-rwxr-xr-xscripts/mkc_check_prog91
1 files changed, 91 insertions, 0 deletions
diff --git a/scripts/mkc_check_prog b/scripts/mkc_check_prog
new file mode 100755
index 0000000..bf4a58e
--- /dev/null
+++ b/scripts/mkc_check_prog
@@ -0,0 +1,91 @@
+#!/bin/sh
+
+############################################################
+# Copyright (c) 2009-2010 by Aleksey Cheusov
+#
+# See LICENSE file in the distribution.
+############################################################
+
+set -e
+
+LC_ALL=C
+export LC_ALL
+
+##################################################
+# options
+usage (){
+ cat <<EOF
+mkc_check_prog detects presense of program file.
+
+Usage: mkc_check_prog [OPTION] progname
+
+OPTIONS:
+ -h display this screen
+ -i <progid> program id, a part of _mkc_* cache file
+ -d delete cache files
+Examples:
+ mkc_check_prog -h
+ mkc_check_prog lua
+ mkc_check_prog gawk
+ mkc_check_prog -i gxx g++
+EOF
+}
+
+while test $# -ne 0; do
+ case "$1" in
+ -h)
+ usage
+ exit 0;;
+ -i)
+ pathpart=prog_$2
+ shift;;
+ -d)
+ delcache=1;;
+ --)
+ shift
+ break;;
+ -*)
+ echo "Unknown option $1" 1>&2
+ exit 1;;
+ *)
+ break;;
+ esac
+ shift
+done
+
+if test $# -ne 1; then
+ usage
+ exit 1
+fi
+
+##################################################
+# initializing
+
+pathpart=${pathpart-prog_`echo $1 | tr /. __`}
+
+. mkc_check_common.sh
+
+##################################################
+# test
+
+check_itself (){
+ mkc_which -x "$1" 2>"${tmperr}"
+}
+
+check_and_cache "checking for program $1" "$cache" "$1"
+
+##################################################
+# clean-ups
+
+cleanup
+
+##################################################
+# finishing
+
+if test -n "$ret"; then
+ printme "$ret\n" 1>&2
+else
+ printme 'NOT FOUND\n' 1>&2
+fi
+
+echo $ret