From 0d68aacd5ec0769a671577186fd1de559e82ec45 Mon Sep 17 00:00:00 2001 From: "Ignacio R. Morelle" Date: Mon, 24 Mar 2008 13:36:44 +0000 Subject: [PATCH] Added probes for required runtime environment --- utils/wesnoth-optipng | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/utils/wesnoth-optipng b/utils/wesnoth-optipng index 26721ea6228..c2dff871320 100755 --- a/utils/wesnoth-optipng +++ b/utils/wesnoth-optipng @@ -28,6 +28,13 @@ total_savings_size=0 total_savings_filecount=0 ####### PROCEDURES ####### + +report_absent_tool() +{ + echo "$1 is not present in PATH. $(basename ${0}) requires it in order to work properly." + exit -1 +} + user_int() { if [ -n "${current_file}" ]; then @@ -92,7 +99,7 @@ Wesnoth automatic PNG optimization helper script Part of the Battle for Wesnoth project Usage: - ${0} [{--nice|n} ] [{--help|-h}] + $(basename ${0}) [{--nice|n} ] [{--help|-h}] Switches: --nice / -n Sets the process nice under which the optimization @@ -109,6 +116,11 @@ EOSTREAM shift done +# Probe optipng +nice -n $opti_nice optipng -v 2> /dev/null 1> /dev/null || report_absent_tool optipng +# Probe IM's convert +nice -n $opti_nice convert --help 2> /dev/null 1> /dev/null || report_absent_tool convert + # Set-up a trap to avoid leaving orphan tempfiles behind. trap user_int SIGINT SIGKILL SIGTERM @@ -119,3 +131,4 @@ done # Print overall statistics echo "*** Total saved: $((${total_savings_size}/1024)) KB on ${total_savings_filecount} files" +exit 0