Skip to content

Commit a82eabd

Browse files
author
Damian Rouson
committed
Merge pull request #170 from sourceryinstitute/add-install-script-boilerplate
Boilerplate installation scripts & mv install_prerequisites
2 parents 868dd35 + 78b30bf commit a82eabd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1674
-14
lines changed

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*.md text
1111
*.txt text
1212
*.sh text
13-
install_prerequisites/build text
13+
prerequisites/build text
1414
*.cu text
1515
*.x64 text
1616

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ install:
116116
elif [[ "X$BUILD_TYPE" != "XInstallScript" ]]; then # Ubuntu on Travis-CI, NOT testing install.sh
117117
if ! ( [[ -x "$HOME/.local/bin/mpif90" ]] && [[ -x "$HOME/.local/bin/mpicc" ]] ); then
118118
# mpich install not cached
119-
# could use install_prerequisites/build instead...
119+
# could use prerequisites/build instead...
120120
wget "${MPICH_URL_HEAD}/${MPICH_URL_TAIL}"
121121
mv "$MPICH_URL_TAIL" "$MPICH_DIR/.."
122122
pushd "$MPICH_DIR/.."

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ endif()
105105
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
106106

107107
add_subdirectory(src)
108-
add_subdirectory(install_prerequisites)
108+
add_subdirectory(prerequisites)
109109

110110
#-----------------------------------------------------
111111
# Publicize installed location to other CMake projects

INSTALL.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ the [Installation Script] section. Or try building each prerequisite from sourc
203203
follows:
204204

205205
```
206-
cd install_prerequisites
206+
cd prerequisites
207207
CC=gcc FC=gfortran CXX=g++ ./build flex
208208
./build gcc
209209
CC=gcc FC=gfortran CXX=g++ ./build mpich
@@ -235,7 +235,7 @@ where the second line builds the flex package that is required for building gcc
235235
[Issues]: https://github.com/sourceryinstitute/opencoarrays/issues
236236
[make.inc]: ./src/make.inc
237237
[opencoarrays]: ./src/extensions/opencoarrays.F90
238-
[install_prerequisites]: ./install_prerequisites
238+
[prerequisites]: ./prerequisites
239239
[MPICH]: http://www.mpich.org
240240
[MVAPICH]:http://mvapich.cse.ohio-state.edu
241241
[MacPorts]: http://www.macports.org

install.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ if [[ "$directory_exists" == "false" ]]; then
9191
fi
9292

9393
build_path=$opencoarrays_src_dir/opencoarrays-build
94-
build_script=$opencoarrays_src_dir/install_prerequisites/build
94+
build_script=$opencoarrays_src_dir/prerequisites/build
9595
if [[ ! -x "$build_script" ]]; then
9696
echo "$this_script: $build_script script does not exist or the user lacks executable permission for it."
9797
echo "$this_script: Please run this_script in the top-level OpenCoarrays source directory or set the"
@@ -124,7 +124,7 @@ usage()
124124
}
125125

126126
# Include stack management functions
127-
. ./install_prerequisites/stack.sh
127+
. ./prerequisites/stack.sh
128128
stack_new dependency_pkg
129129
stack_new dependency_exe
130130
stack_new dependency_path
@@ -741,7 +741,7 @@ print_header()
741741
popd > /dev/null
742742
echo ""
743743
echo "*** All prerequisites will be downloaded to, built in, and installed in ***"
744-
echo "$opencoarrays_src_dir/install_prerequisites"
744+
echo "$opencoarrays_src_dir/prerequisites"
745745
printf "*** OpenCoarrays will be installed "
746746
if [[ "$install_path" == "$opencoarrays_src_dir/opencoarrays-installation" ]]; then
747747
printf "in the above location also. ***\n"
@@ -922,7 +922,7 @@ elif [[ $1 == '-v' || $1 == '-V' || $1 == '--version' ]]; then
922922
echo ""
923923
else # Find or install prerequisites and install OpenCoarrays
924924

925-
cd install_prerequisites &&
925+
cd prerequisites &&
926926
installation_record=install-opencoarrays.log &&
927927
. set_SUDO.sh &&
928928
set_SUDO_if_necessary &&
File renamed without changes.
File renamed without changes.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Make the build directory, configure, and build
2+
build_and_install()
3+
{
4+
num_threads=${arg_j}
5+
build_path="${OPENCOARRAYS_SRC_DIR}/prerequisites/builds/${package_to_build}-${version_to_build}"
6+
7+
info "Building ${package_to_build} ${version_to_build}"
8+
info "Build path: ${build_path}"
9+
10+
set_SUDO_if_needed_to_write_to_directory "${build_path}"
11+
set_SUDO_if_needed_to_write_to_directory "${install_path}"
12+
mkdir -p "${build_path}"
13+
info "pushd ${build_path}"
14+
pushd "${build_path}"
15+
if [[ "${package_to_build}" == "gcc" ]]; then
16+
info 'pushd ${download_path}/${package_source_directory} '
17+
pushd "${download_path}/${package_source_directory}"
18+
"${PWD}"/contrib/download_prerequisites
19+
info "popd"
20+
popd
21+
info "Configuring with the following command:"
22+
info "${download_path}/${package_source_directory}/configure --prefix=${install_path} --enable-languages=c,c++,fortran,lto --disable-multilib --disable-werror"
23+
"${download_path}/${package_source_directory}/configure" --prefix="${install_path}" --enable-languages=c,c++,fortran,lto --disable-multilib --disable-werror
24+
info "Building with the following command: 'make -j${num_threads} bootstrap'"
25+
make "-j${num_threads}" bootstrap
26+
if [[ ! -z "${SUDO:-}" ]]; then
27+
info "You do not have write permissions to the installation path ${install_path}"
28+
info "If you have administrative privileges, enter your password to install ${package_to_build}"
29+
fi
30+
info "Installing with the following command: ${SUDO:-} make install"
31+
${SUDO:-} make install
32+
else
33+
info "Configuring ${package_to_build} ${version_to_build} with the following command:"
34+
info "CC=\"${CC:-'gcc'}\" CXX=\"${CXX:-'g++'}\" \"${download_path}/${package_source_directory}\"/configure --prefix=\"${install_path}\""
35+
CC="${CC:-'gcc'}" CXX="${CXX:-'g++'}" "${download_path}/${package_source_directory}"/configure --prefix="${install_path}"
36+
info "Building with the following command:"
37+
info "CC=\"${CC:-'gcc'}\" CXX=\"${CXX:-'g++'}\" make -j\"${num_threads}\""
38+
CC="${CC:-'gcc'}" CXX="${CXX:-'g++'}" make "-j${num_threads}"
39+
info "Installing ${package_to_build} in ${install_path}"
40+
if [[ ! -z "${SUDO:-}" ]]; then
41+
info "You do not have write permissions to the installation path ${install_path}"
42+
info "If you have administrative privileges, enter your password to install ${package_to_build}"
43+
fi
44+
info "Installing with the following command: ${SUDO:-} make install"
45+
${SUDO:-} make install
46+
fi
47+
info "popd"
48+
popd
49+
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/ftp-url.sh"
2+
source "${OPENCOARRAYS_SRC_DIR:-}/prerequisites/build-functions/set_SUDO_if_needed_to_write_to_directory.sh"
3+
4+
# Download pkg-config if the tar ball is not already in the present working directory
5+
download_if_necessary()
6+
{
7+
download_path="${PWD}/downloads"
8+
set_SUDO_if_needed_to_write_to_directory "${download_path}"
9+
if [ -f $url_tail ] || [ -d $url_tail ]; then
10+
info "Found '${url_tail}' in ${PWD}."
11+
info "If it resulted from an incomplete download, building ${package_name} could fail."
12+
info "Would you like to proceed anyway? (y/n)"
13+
read proceed
14+
if [[ "${proceed}" == "y" ]]; then
15+
info "y"
16+
else
17+
info "n"
18+
info "Please remove $url_tail and restart the installation to to ensure a fresh download." 1>&2
19+
emergency "Aborting. [exit 80]"
20+
fi
21+
elif ! type "${fetch}" &> /dev/null; then
22+
# The download mechanism is missing
23+
info "The default download mechanism for ${package_name} is ${fetch}."
24+
info "Please either ensure that ${fetch} is installed and in your PATH"
25+
info "or download the ${package_name} source from "
26+
info "${package_url}"
27+
#called_by_install_sh=`echo "$(ps -p $PPID -o args=)" | grep install.sh`
28+
info "Place the downloaded file in ${download_path} and restart this script."
29+
#if [[ ! -z $called_by_install_sh ]]; then
30+
# caller="install.sh"
31+
#else
32+
# caller="build"
33+
#fi
34+
emergency "Aborting [exit 90]"
35+
else
36+
# The download mechanism is in the path.
37+
if [[ "${fetch}" == "svn" ]]; then
38+
if [[ ${version_to_build} == '--avail' || ${version_to_build} == '-a' ]]; then
39+
args="ls"
40+
else
41+
args="checkout"
42+
fi
43+
elif [[ "${fetch}" == "wget" ]]; then
44+
args="--no-check-certificate"
45+
elif [[ "${fetch}" == "ftp-url" ]]; then
46+
args="-n"
47+
elif [[ "${fetch}" == "git" ]]; then
48+
args="clone"
49+
fi
50+
if [[ "${fetch}" == "svn" || "${fetch}" == "git" ]]; then
51+
package_source_directory="${url_tail}"
52+
else
53+
package_source_directory="${package_name}-${version_to_build}"
54+
fi
55+
info "Downloading ${package_name} ${version_to_build} to the following location:"
56+
info "${download_path}/${package_source_directory}"
57+
info "Download command: ${fetch} ${args} ${package_url}"
58+
info "Depending on the file size and network bandwidth, this could take several minutes or longer."
59+
pushd "${download_path}"
60+
"${fetch}" "${args}" "${package_url}"
61+
popd
62+
if [[ "${version_to_build}" == '--avail' || "${version_to_build}" == '-a' ]]; then
63+
# In this case, args="ls" and the list of available versions has been printed so we can move on.
64+
exit 1
65+
fi
66+
if [[ "${fetch}" == "svn" ]]; then
67+
search_path="${download_path}/${version_to_build}"
68+
else
69+
search_path="${download_path}/${url_tail}"
70+
fi
71+
if [ -f "${search_path}" ] || [ -d "${search_path}" ]; then
72+
info "Download succeeded. The "${package_name}" source is in the following location:"
73+
info "${search_path}"
74+
else
75+
info "Download failed. The "${package_name}" source is not in the following, expected location:"
76+
info "${search_path}"
77+
emergency "Aborting. [exit 110]"
78+
fi
79+
fi
80+
}

0 commit comments

Comments
 (0)