Skip to content

Commit eff205a

Browse files
Damian Rousonzbeekman
authored andcommitted
Improve minimum prerequisite version verification
The new install_prerequisites/check_version.sh script exits with an error status if the first argument names a package that returns a version number lower than the second version. Now install.sh calls check_version.sh to verify the cmake, flex, bison, and m4 versions, each of which reports version numbers in the format major.minor.patch at the end of the first line of output from invoking them with the sole argument "--version". TODO: handle version numbers in the major.minor format and then use check_version.sh to verify the version number returne dby "mpif90 -v". Currently install.sh instead uses "mpif90 --version" which returns the version number of the Fortran compiler that mpif90 wraps. No check on the version number of the MPI implementation itself is performed. See issue #104
1 parent fb79b83 commit eff205a

File tree

3 files changed

+162
-10
lines changed

3 files changed

+162
-10
lines changed

install.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
# -- This script installs OpenCoarrays and its prerequisites.
66
#
77
# OpenCoarrays is distributed under the OSI-approved BSD 3-clause License:
8-
# Copyright (c) 2015, Sourcery, Inc.
9-
# Copyright (c) 2015, Sourcery Institute
8+
# Copyright (c) 2015-2016, Sourcery, Inc.
9+
# Copyright (c) 2015-2016, Sourcery Institute
1010
# All rights reserved.
1111
#
1212
# Redistribution and use in source and binary forms, with or without modification,
@@ -207,7 +207,7 @@ find_or_install()
207207
elif [[ "$package_in_path" == "true" ]]; then
208208
printf "$this_script: Checking whether $package in PATH is version < $minimum_version... "
209209

210-
if [[ "$package_version_in_path" < "$executable version $minimum_version" ]]; then
210+
if ! ./check_version.sh $package `./build $package --default --query-version`; then
211211
printf "yes.\n"
212212
# Here we place $package on the dependency stack to trigger the build of the above file:
213213
stack_push dependency_pkg $package "none"
@@ -400,7 +400,7 @@ find_or_install()
400400
elif [[ "$package_in_path" == "true" ]]; then
401401

402402
printf "$this_script: Checking whether $package in PATH is version < $minimum_version... "
403-
if [[ "$package_version_in_path" < "$executable $minimum_version" ]]; then
403+
if ! ./check_version.sh $package `./build $package --default --query-version`; then
404404
printf "yes\n"
405405

406406
export FLEX="$package_install_path/bin/$executable"
@@ -460,7 +460,7 @@ find_or_install()
460460

461461
elif [[ "$package_in_path" == "true" ]]; then
462462
printf "$this_script: Checking whether $package executable $executable in PATH is version < $minimum_version... "
463-
if [[ "$package_version_in_path" < "$package (GNU Bison) $minimum_version" ]]; then
463+
if ! ./check_version.sh $package `./build $package --default --query-version`; then
464464
printf "yes.\n"
465465
export YACC="$package_install_path/bin/$executable"
466466
# Trigger 'find_or_install m4' and subsequent build of $package
@@ -519,7 +519,7 @@ find_or_install()
519519

520520
elif [[ "$package_in_path" == "true" ]]; then
521521
printf "$this_script: Checking whether $package executable $executable in PATH is version < $minimum_version... "
522-
if [[ "$package_version_in_path" < "$package (GNU Bison) $minimum_version" ]]; then
522+
if ! ./check_version.sh $package `./build $package --default --query-version`; then
523523
printf "yes.\n"
524524
export M4="$package_install_path/bin/m4"
525525
# Halt the recursion and signal that there are no prerequisites to build
@@ -905,8 +905,8 @@ elif [[ $1 == '-v' || $1 == '-V' || $1 == '--version' ]]; then
905905
echo "opencoarrays $opencoarrays_version"
906906
echo ""
907907
echo "OpenCoarrays installer"
908-
echo "Copyright (C) 2015 Sourcery, Inc."
909-
echo "Copyright (C) 2015 Sourcery Institute"
908+
echo "Copyright (C) 2015-2016 Sourcery, Inc."
909+
echo "Copyright (C) 2015-2016 Sourcery Institute"
910910
echo ""
911911
echo "OpenCoarrays comes with NO WARRANTY, to the extent permitted by law."
912912
echo "You may redistribute copies of $this_script under the terms of the"

install_prerequisites/build

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
# -- This script downloads and installs the OpenCoarrays prerequisites
66
#
77
# OpenCoarrays is distributed under the OSI-approved BSD 3-clause License:
8-
# Copyright (c) 2015, Sourcery, Inc.
9-
# Copyright (c) 2015, Sourcery Institute
8+
# Copyright (c) 2015-2016, Sourcery, Inc.
9+
# Copyright (c) 2015-2016, Sourcery Institute
1010
# All rights reserved.
1111
#
1212
# Redistribution and use in source and binary forms, with or without modification,
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
#!/bin/bash
2+
#
3+
# check_version.sh
4+
#
5+
# -- Verify whether an OpenCoarrays prerequisite meets the required minimum version number.
6+
#
7+
# OpenCoarrays is distributed under the OSI-approved BSD 3-clause License:
8+
# Copyright (c) 2015-2016, Sourcery, Inc.
9+
# Copyright (c) 2015-2016, Sourcery Institute
10+
# All rights reserved.
11+
#
12+
# Redistribution and use in source and binary forms, with or without modification,
13+
# are permitted provided that the following conditions are met:
14+
#
15+
# 1. Redistributions of source code must retain the above copyright notice, this
16+
# list of conditions and the following disclaimer.
17+
# 2. Redistributions in binary form must reproduce the above copyright notice, this
18+
# list of conditions and the following disclaimer in the documentation and/or
19+
# other materials provided with the distribution.
20+
# 3. Neither the names of the copyright holders nor the names of their contributors
21+
# may be used to endorse or promote products derived from this software without
22+
# specific prior written permission.
23+
#
24+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
25+
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26+
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27+
# IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
28+
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29+
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31+
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33+
# POSSIBILITY OF SUCH DAMAGE.
34+
35+
# Interpret the first argument as the package executable name
36+
package=$1
37+
# Interpret the second argument as the minimimum acceptable package version number
38+
minimum_version=$2
39+
# Interpret the third argument as indicating the desired verbosity
40+
verbose=$3
41+
42+
this_script=`basename $0`
43+
44+
usage()
45+
{
46+
echo ""
47+
echo " $this_script - Bash script for verifyin minimum version numbers for OpenCoarrays prerequisites"
48+
echo ""
49+
echo " Usage (optional arguments in square brackets): "
50+
echo " $this_script [<option>]"
51+
echo " $this_script <package-name> <minimum-version-number> [--verbose]"
52+
echo ""
53+
echo " Options:"
54+
echo " --help, -h Show this help message"
55+
echo " --list , -l List the packages whose versions this script can verify"
56+
echo ""
57+
echo " Examples:"
58+
echo ""
59+
echo " $this_script cmake 3.4.0"
60+
echo " $this_script flex 2.6.0 --verbose"
61+
echo " $this_script flex `./build flex --default --query-version`"
62+
echo " $this_script --help"
63+
echo " $this_script --list"
64+
echo ""
65+
echo "[exit 10]"
66+
exit 10
67+
}
68+
69+
# Print usage information and exit if script is invoked without arguments or with --help or -h as the first argument
70+
if [ $# == 0 ]; then
71+
usage | less
72+
exit 20
73+
74+
elif [[ $1 == '--help' || $1 == '-h' ]]; then
75+
usage | less
76+
exit 30
77+
78+
elif [[ $1 == '--list' || $1 == '-l' ]]; then
79+
echo "$this_script currently verifies minimum version numbers for the following OpenCoarrays prerequisites:"
80+
echo " cmake, flex, bison, m4"
81+
exit 40
82+
83+
elif [[ $1 == '-v' || $1 == '-V' || $1 == '--version' ]]; then
84+
# Print script copyright if invoked with -v, -V, or --version argument
85+
cmake_project_line=`grep project ../CMakeLists.txt | grep VERSION`
86+
text_after_version_keyword="${cmake_project_line##*VERSION}"
87+
text_before_language_keyword="${text_after_version_keyword%%LANGUAGES*}"
88+
opencoarrays_version=$text_before_language_keyword
89+
echo "opencoarrays $opencoarrays_version"
90+
echo ""
91+
echo "OpenCoarrays prerequisite version verifier"
92+
echo "Copyright (C) 2015-2016 Sourcery, Inc."
93+
echo "Copyright (C) 2015-2016 Sourcery Institute"
94+
echo ""
95+
echo "OpenCoarrays comes with NO WARRANTY, to the extent permitted by law."
96+
echo "You may redistribute copies of $this_script under the terms of the"
97+
echo "BSD 3-Clause License. For more information about these matters, see"
98+
echo "http://www.sourceryinstitute.org/license.html"
99+
echo ""
100+
fi
101+
102+
package_version_header=`$1 --version | head -1`
103+
if [[ "$verbose" == "--verbose" ]]; then
104+
echo $package_version_header
105+
fi
106+
107+
# Extract the text after the final space:
108+
version=${package_version_header##* }
109+
major=${version%%.*}
110+
minor_patch=${version#*.}
111+
minor=${minor_patch%%.*}
112+
patch=${version##*.}
113+
if [[ "$verbose" == "--verbose" ]]; then
114+
echo "$version = $major . $minor . $patch"
115+
fi
116+
117+
# Extract the text after the final space:
118+
min_major=${minimum_version%%.*}
119+
min_minor_patch=${minimum_version#*.}
120+
min_minor=${min_minor_patch%%.*}
121+
min_patch=${minimum_version##*.}
122+
if [[ "$verbose" == "--verbose" ]]; then
123+
echo "$minimum_version = $min_major . $min_minor . $min_patch"
124+
fi
125+
126+
if [ "$(( major < min_major ))" -ne 0 ]; then
127+
if [[ $verbose == "--verbose" ]]; then
128+
echo "$major < $min_major"
129+
fi
130+
exit 10
131+
elif [[ $verbose == "--verbose" ]]; then
132+
echo "$major >= $min_major"
133+
fi
134+
135+
if [ "$(( minor < min_minor ))" -ne 0 ]; then
136+
if [[ $verbose == "--verbose" ]]; then
137+
echo "$minor < $min_minor"
138+
fi
139+
exit 20
140+
elif [[ $verbose == "--verbose" ]]; then
141+
echo "$minor >= $min_minor"
142+
fi
143+
144+
if [ "$(( patch < min_patch ))" -ne 0 ]; then
145+
if [[ $verbose == "--verbose" ]]; then
146+
echo "$patch < $min_patch"
147+
fi
148+
exit 30
149+
elif [[ $verbose == "--verbose" ]]; then
150+
echo "$patch >= $min_patch"
151+
fi
152+
exit 0

0 commit comments

Comments
 (0)