Skip to content

Commit 93999ad

Browse files
author
Damian Rouson
committed
First draft of Windows installation script.
On Windows Subsystem for Linux (WSL) Build 15007, the new windows-install.sh completes the OpenCoarrays build process, but 33 of 34 tests fail. The one test that passes is the test of the installation script. The build uses GCC 5.4.0, which is the version that apt-get installs.
1 parent 4575ca1 commit 93999ad

File tree

2 files changed

+279
-0
lines changed

2 files changed

+279
-0
lines changed

windows-install.sh

Lines changed: 266 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,266 @@
1+
#!/usr/bin/env bash
2+
#
3+
# windows-install.sh
4+
#
5+
# -- This script installs OpenCoarrays and its prerequisites.
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+
# Portions of this script derive from BASH3 Boilerplate and are distributed under
36+
# the following license:
37+
#
38+
# The MIT License (MIT)
39+
#
40+
# Copyright (c) 2014 Kevin van Zonneveld
41+
#
42+
# Permission is hereby granted, free of charge, to any person obtaining a copy
43+
# of this software and associated documentation files (the "Software"), to deal
44+
# in the Software without restriction, including without limitation the rights
45+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
46+
# copies of the Software, and to permit persons to whom the Software is
47+
# furnished to do so, subject to the following conditions:
48+
#
49+
# The above copyright notice and this permission notice shall be included in all
50+
# copies or substantial portions of the Software.
51+
#
52+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
53+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
54+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
55+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
56+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
57+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
58+
# SOFTWARE.
59+
#
60+
#
61+
# - https://github.com/kvz/bash3boilerplate
62+
# - http://kvz.io/blog/2013/02/26/introducing-bash3boilerplate/
63+
#
64+
# Version: 2.0.0
65+
#
66+
# Authors:
67+
#
68+
# - Kevin van Zonneveld (http://kvz.io)
69+
# - Izaak Beekman (https://izaakbeekman.com/)
70+
# - Alexander Rathai ([email protected])
71+
# - Dr. Damian Rouson (http://www.sourceryinstitute.org/) (documentation)
72+
#
73+
# Licensed under MIT
74+
# Copyright (c) 2013 Kevin van Zonneveld (http://kvz.io)
75+
76+
# The invocation of bootstrap.sh below performs the following tasks:
77+
# (1) Import several bash3boilerplate helper functions & default settings.
78+
# (2) Set several variables describing the current file and its usage page.
79+
# (3) Parse the usage information (default usage file name: current file's name with -usage appended).
80+
# (4) Parse the command line using the usage information.
81+
82+
starting_directory=${PWD}
83+
84+
### Start of boilerplate -- do not edit this block #######################
85+
export OPENCOARRAYS_SRC_DIR="${OPENCOARRAYS_SRC_DIR:-${PWD%/}}"
86+
if [[ ! -f "${OPENCOARRAYS_SRC_DIR}/src/libcaf.h" ]]; then
87+
echo "Please run this script inside the top-level OpenCoarrays source directory or "
88+
echo "set OPENCOARRAYS_SRC_DIR to the OpenCoarrays source directory path."
89+
exit 1
90+
fi
91+
export B3B_USE_CASE="${B3B_USE_CASE:-${OPENCOARRAYS_SRC_DIR}/prerequisites/use-case}"
92+
if [[ ! -f "${B3B_USE_CASE:-}/bootstrap.sh" ]]; then
93+
echo "Please set B3B_USE_CASE to the bash3boilerplate use-case directory path."
94+
exit 2
95+
else
96+
# shellcheck source=./prerequisites/use-case/bootstrap.sh
97+
source "${B3B_USE_CASE}/bootstrap.sh" "$@"
98+
fi
99+
### End of boilerplate -- start user edits below #########################
100+
101+
# Set expected value of present flags that take no arguments
102+
export __flag_present=1
103+
104+
# Set up a function to call when receiving an EXIT signal to do some cleanup. Remove if
105+
# not needed. Other signals can be trapped too, like SIGINT and SIGTERM.
106+
function cleanup_before_exit () {
107+
info "Cleaning up. Done"
108+
}
109+
trap cleanup_before_exit EXIT # The signal is specified here. Could be SIGINT, SIGTERM etc.
110+
111+
112+
### Validation (decide what's required for running your script and error out)
113+
#####################################################################
114+
115+
[ -z "${LOG_LEVEL:-}" ] && emergency "Cannot continue without LOG_LEVEL. "
116+
117+
# shellcheck disable=SC2154
118+
if [[ "${arg_d}" == "${__flag_present}" ]]; then
119+
print_debug_only=7
120+
if [ "$(( LOG_LEVEL < print_debug_only ))" -ne 0 ]; then
121+
debug "Supressing info and debug messages: one of {-l, -v, -P, -U, -V, -D} present."
122+
suppress_info_debug_messages
123+
fi
124+
fi
125+
126+
# Get linux_distribution name
127+
{
128+
info "__file: ${__file}"
129+
info "__dir: ${__dir}"
130+
info "__base: ${__base}"
131+
info "__os: ${__os}"
132+
info "__usage: ${__usage}"
133+
info "LOG_LEVEL: ${LOG_LEVEL}"
134+
135+
info "-c (--with-c): [arg] ${arg_c}"
136+
info "-C (--with-cxx): [arg] ${arg_C}"
137+
info "-d (--debug): ${arg_d}"
138+
info "-e (--verbose): ${arg_e}"
139+
info "-f (--with-fortran): ${arg_e}"
140+
info "-i (--install-prefix): ${arg_i}"
141+
info "-j (--num-threads): ${arg_j}"
142+
info "-m (--with-cmake): [arg] ${arg_m}"
143+
info "-n (--no-color): ${arg_n}"
144+
info "-v (--version): ${arg_v}"
145+
info "-V (--version-number): ${arg_V}"
146+
}
147+
148+
149+
# __________ Process command-line arguments and environment variables _____________
150+
151+
export this_script="$(basename "$0")"
152+
debug "this_script=\"${this_script}\""
153+
154+
export install_prefix="${arg_i%/:-${PWD}/prerequisites/installations}"
155+
info "install_prefix=\"${install_prefix}\""
156+
157+
export num_threads="${arg_j}"
158+
info "num_threads=\"${arg_j}\""
159+
160+
set_opencoarrays_version()
161+
{
162+
cmake_project_line="$(grep project "${OPENCOARRAYS_SRC_DIR}/CMakeLists.txt" | grep VERSION)"
163+
text_after_version_keyword="${cmake_project_line##*VERSION}"
164+
text_before_language_keyword="${text_after_version_keyword%%LANGUAGES*}"
165+
opencoarrays_version=$text_before_language_keyword
166+
export opencoarrays_version="${opencoarrays_version//[[:space:]]/}"
167+
}
168+
set_opencoarrays_version
169+
170+
export build_path="${OPENCOARRAYS_SRC_DIR%/}"/prerequisites/builds/opencoarrays/$opencoarrays_version
171+
info "build_path=\"${build_path}\""
172+
173+
export CMAKE="${arg_m:-cmake}"
174+
175+
verify_this_is_ubuntu()
176+
{
177+
linux_standard_base_i=`lsb_release -i`
178+
untrimmed_name=${linux_standard_base_i##*Distributor ID:}
179+
linux_distribution="${untrimmed_name//[[:space:]]/}"
180+
info "Linux distribution: ${linux_distribution}"
181+
if [[ "${linux_distribution:-}" != "Ubuntu" ]]; then
182+
info "Please run this script inside the Windows Subsystem for Linux (WSL) Ubuntu 16.04 or later,"
183+
info "which might require joining the Windows Insider Preview program and selecting 'Fast' updates."
184+
emergency "Error: see above."
185+
fi
186+
}
187+
verify_this_is_ubuntu
188+
189+
# Ubuntu 16.04 apt-get installs gfortran 5.4.0 or later, which is acceptable for many uses of OpenCoarrays
190+
verify_acceptable_release_number()
191+
{
192+
linux_standard_base_r=`lsb_release -r`
193+
untrimmed_name=${linux_standard_base_r##*Release:}
194+
release_number="${untrimmed_name//[[:space:]]/}"
195+
major_release="${release_number%%.*}"
196+
minor_release="${release_number##*.}"
197+
info "Release: ${major_release}.${minor_release}"
198+
if [[ $major_release -lt 16 ]]; then
199+
emergency "Please upgrade to Windows Subsystem for Linux (WSL) Ubuntu 16.04 or later."
200+
elif [[ $major_release -eq 16 ]]; then
201+
if [[ $minor_release -lt "04" ]]; then
202+
emergency "Please upgrade to Windows Subsystem for Linux (WSL) Ubuntu 16.04 or later."
203+
fi
204+
fi
205+
}
206+
verify_acceptable_release_number
207+
208+
export FC=${arg_f:-gfortran}
209+
export CC=${arg_f:-gcc}
210+
export CXX=${arg_f:-g++}
211+
212+
if [[ "${arg_V}" == "${__flag_present}" ]]; then
213+
# Print just the version number
214+
info "$opencoarrays_version"
215+
216+
elif [[ "${arg_v}" == "${__flag_present}" ]]; then
217+
218+
# Print copyright info and version number
219+
info "OpenCoarrays ${opencoarrays_version}"
220+
info ""
221+
info "OpenCoarrays installer"
222+
info "Copyright (C) 2015-2017 Sourcery, Inc."
223+
echo "Copyright (C) 2015-2017 Sourcery Institute"
224+
info ""
225+
info "OpenCoarrays comes with NO WARRANTY, to the extent permitted by law."
226+
info "You may redistribute copies of ${this_script} under the terms of the"
227+
echo "BSD 3-Clause License. For more information about these matters, see"
228+
info "http://www.sourceryinstitute.org/license.html"
229+
info ""
230+
else
231+
232+
# Check for and, if necessary, install OpenCoarrays prerequisites
233+
234+
if ! type "$CMAKE" >& /dev/null; then
235+
sudo apt-get install cmake
236+
fi
237+
if ! type "$CXX" >& /dev/null; then
238+
sudo apt-get install g++
239+
fi
240+
if ! type "$FC" >& /dev/null; then
241+
sudo apt-get install gfortran
242+
fi
243+
244+
if ! type mpif90 >& /dev/null; then
245+
sudo apt-get install mpich
246+
fi
247+
248+
# Install OpenCoarrays
249+
250+
source prerequisites/build-functions/set_SUDO_if_needed_to_write_to_directory.sh "$install_prefix"
251+
252+
if [[ -d build ]]; then
253+
rm -rf "$build_path"
254+
fi
255+
mkdir -p "$build_path"
256+
cd "$build_path"
257+
info "Configuring OpenCoarrays with the following command:"
258+
info "\"$CMAKE\" \"$OPENCOARRAYS_SRC_DIR\" -DCMAKE_INSTALL_PREFIX=\"$install_prefix\""
259+
"$CMAKE" "$OPENCOARRAYS_SRC_DIR" -DCMAKE_INSTALL_PREFIX="$install_prefix"
260+
info "Building OpenCoarrays with the following command:"
261+
info "make -j $arg_j"
262+
make -j $arg_j
263+
info "Installing OpenCoarrays with the following command:"
264+
info "${SUDO:-} make install"
265+
${SUDO:-} make install
266+
fi

windows-install.sh-usage

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
-c --with-c [arg] Use specified C compiler. Default="gcc"
2+
-C --with-cxx [arg] Use specified C++ compiler. Default="g++"
3+
-d --debug Enable debug mode.
4+
-e --verbose Enable verbose mode, print script as it is executed.
5+
-f --with-fortran [arg] Use specified Fortran compiler. Default="gfortran"
6+
-h --help Print this page.
7+
-i --install-prefix [arg] Install package in specified path. Default="${OPENCOARRAYS_SRC_DIR}/prerequisites/installations/opencoarrays/${version_to_build:-}"
8+
-j --num-threads [arg] Number of threads to use when invoking make. Default="1"
9+
-m --with-cmake [arg] Use specified CMake installation. Default="cmake"
10+
-n --no-color Disable color output.
11+
-v --version Print OpenCoarrays version number and copyright.
12+
-V --version-number Print OpenCoarrays version number.
13+
-y --yes-to-all Build non-interactively by assuming affirmative user responses.

0 commit comments

Comments
 (0)