<workingDirectory>${project.basedir}/scripts</workingDirectory>
<arguments>
<argument>deb_package_check</argument>
+ <argument>-olibpng-dev|libpng12-dev</argument>
+ <argument>-olibopenjp2-7-dev|libjasper-dev</argument>
+ <argument>-opython-dev</argument>
+ <argument>-opython-numpy</argument>
<argument>build-essential</argument>
<argument>cmake</argument>
<argument>git</argument>
<argument>libavcodec-dev</argument>
<argument>libavformat-dev</argument>
<argument>libswscale-dev</argument>
- <argument>python-dev</argument>
- <argument>python-numpy</argument>
<argument>libtbb2</argument>
<argument>libtbb-dev</argument>
<argument>libjpeg-dev</argument>
- <argument>libpng12-dev</argument>
<argument>libtiff5-dev</argument>
- <argument>libjasper-dev</argument>
<argument>libdc1394-22-dev</argument>
<argument>execstack</argument>
<argument>ant</argument>
<requireEnvironmentVariable>
<level>WARN</level>
<variableName>JAVA_HOME</variableName>
- <message>$JAVA_HOME is not set. Build WILL fail.</message>
+ <message>$JAVA_HOME is not set. Build may fail.</message>
</requireEnvironmentVariable>
<requireEnvironmentVariable>
<level>WARN</level>
<variableName>MAKEFLAGS</variableName>
<message>No MAKEFLAGS environment variable. Build may be slow.
- To speed up the build you can try exporting MAKEFLAGS=-jX where X equals the number of parallel builds.</message>
+To speed up the build you can try exporting MAKEFLAGS=-jX where X equals the number of parallel builds.</message>
</requireEnvironmentVariable>
</rules>
</configuration>
#!/bin/bash
-###########################################################################################
+##################################################################################################
#
# This script checks for the required Debian packages are installed
# to build OpenCV.
# Commandline parameters:
-# $@ - These are the names of the packages to check with 'dpkg'
+# $@ These are the names of the packages to check with 'dpkg'. Multiple values may
+# be specified per package by using pipe as a delimiter, e.g. libpng-dev|libpng12-dev.
+# Multiple values are evaluated left-to-right and the first found prevents checking of
+# the remaining package options.
+#
+# -o <package_name> Specifying this switch with a package name marks it as optional
+# i.e. it is not required to be installed.
#
# Returns:
# 0 - All packages installed (success)
# Kerry Billingham <contact (at) avionicengineers (d0t) com>
# 20 April 2016
#
-###########################################################################################
+##################################################################################################
red=$'\e[1;31m'
green=$'\e[1;32m'
+yellow=$'\e[1;33m'
end=$'\e[0m'
-check_message="Checking for 'dpkg'"
+check_message="Checking for "
+declare -i packageMissing=0
+declare -i installed=1
+
+#########################
+# Function declarations.
+#########################
+function check_package() {
+ check_message="Checking for package "
+ dpkg -s $1 &>/dev/null
+ is_installed=$?
+ if [ ${is_installed} -ne 0 ]; then
+ printf "%-80s%s\n" "$2${check_message}${red}$1" " MISSING.${end}"
+ packageMissing=1
+ else
+ printf "%-80s%s\n" "$2${check_message}${green}$1" " INSTALLED.${end}"
+ packageMissing=0
+ fi
+ return $is_installed
+}
+
+# Main part of script.
+ORIGINAL_IFS=$IFS
+
dpkg -? &>/dev/null
if [ $? -ne 0 ]; then
- printf "%-80s%s\n" "${check_message}" "${red} MISSING.${end}"
+ printf "%-80s%s\n" "${check_message} ${red}'dpkg'" " MISSING.${end}"
exit 1
else
- printf "%-80s%s\n" "${check_message}" "${green} INSTALLED.${end}"
+ printf "%-80s%s\n" "${check_message} ${green}'dpkg'" " INSTALLED.${end}"
fi
-declare -i packageMissing=0
-packageArray=( "$@" )
+while getopts o: option; do
+ case $option in
+ o)
+ IFS="|"
+ packageChoices=( ${OPTARG} )
+ if [ ${#packageChoices[@]} -gt 1 ]; then
+ echo "Optional package. One of ${yellow}${packageChoices[@]}${end} can be installed."
+ for choice in ${packageChoices[@]}; do
+ check_package ${choice} " "
+ if [ $? -eq 0 ]; then
+ break
+ fi
+ done
+ else
+ echo "Optional package ${yellow}${packageChoices}${end}"
+ check_package ${OPTARG} " "
+ fi
+ IFS=$ORIGINAL_IFS
+ ;;
+ \?)
+ echo "No option found"
+ ;;
+ esac
+done
+
+shift $((OPTIND-1))
+packageArray=( $@ )
for package in ${packageArray[@]}; do
- check_message="Checking for package ${package}"
- dpkg -s ${package} &>/dev/null
- if [ $? -ne 0 ]; then
- printf "%-80s%s\n" "${check_message}" "${red} MISSING.${end}"
- packageMissing=1
+ IFS="|"
+ packageChoices=( ${package} )
+ if [ ${#packageChoices[@]} -gt 1 ]; then
+ echo "Multiple options. One of ${yellow}${packageChoices[@]}${end} must be installed."
+ for choice in ${packageChoices[@]}; do
+ check_package ${choice} " "
+ if [ $? -eq 0 ]; then
+ break
+ fi
+ done
else
- printf "%-80s%s\n" "${check_message}" "${green} INSTALLED.${end}"
+ check_package ${package} ""
fi
done