-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
58a9b6c
commit 222a908
Showing
3 changed files
with
152 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
#!/bin/bash | ||
# | ||
# | ||
|
||
prefix=$HOME/local | ||
cachedir=$HOME/local/.cache | ||
|
||
# | ||
# Ordered list of software to download and install into $prefix. | ||
# NOTE: Code currently assumes .tar.gz suffix... | ||
# | ||
downloads="\ | ||
https://www.open-mpi.org/software/ompi/v2.0/downloads/openmpi-2.0.2.tar.gz" | ||
|
||
declare -A extra_configure_opts=(\ | ||
) | ||
|
||
declare -r prog=${0##*/} | ||
declare -r long_opts="prefix:,cachedir:,verbose,printenv" | ||
declare -r short_opts="vp:c:P" | ||
declare -r usage="\ | ||
\n | ||
Usage: $prog [OPTIONS]\n\ | ||
Download and install to a local prefix (default=$prefix) dependencies\n\ | ||
for building flux-framework/flux-core\n\ | ||
\n\ | ||
Options:\n\ | ||
-v, --verbose Be verbose.\n\ | ||
-P, --printenv Print environment variables to stdout\n\ | ||
-c, --cachedir=DIR Check for precompiled dependency cache in DIR\n\ | ||
-e, --max-cache-age=N Expire cache in N days from creation\n\ | ||
-p, --prefix=DIR Install software into prefix\n | ||
" | ||
|
||
die() { echo -e "$prog: $@"; exit 1; } | ||
say() { echo -e "$prog: $@"; } | ||
debug() { test "$verbose" = "t" && say "$@"; } | ||
|
||
GETOPTS=`/usr/bin/getopt -u -o $short_opts -l $long_opts -n $prog -- $@` | ||
if test $? != 0; then | ||
die "$usage" | ||
fi | ||
|
||
eval set -- "$GETOPTS" | ||
while true; do | ||
case "$1" in | ||
-v|--verbose) verbose=t; shift ;; | ||
-c|--cachedir) cachedir="$2"; shift 2 ;; | ||
-e|--max-cache-age) cacheage="$2"; shift 2 ;; | ||
-p|--prefix) prefix="$2"; shift 2 ;; | ||
-P|--printenv) print_env=1; shift ;; | ||
--) shift ; break; ;; | ||
*) die "Invalid option '$1'\n$usage" ;; | ||
esac | ||
done | ||
|
||
print_env () { | ||
echo "export LD_LIBRARY_PATH=${prefix}/lib:$LD_LIBRARY_PATH" | ||
echo "export CPPFLAGS=-I${prefix}/include" | ||
echo "export LDFLAGS=-L${prefix}/lib" | ||
echo "export PKG_CONFIG_PATH=${prefix}/lib/pkgconfig:${prefix}/share/pkgconfig" | ||
echo "export PATH=${PATH}:${HOME}/.local/bin:${HOME}/local/usr/bin:${HOME}/local/bin" | ||
} | ||
|
||
if test -n "$print_env"; then | ||
print_env | ||
exit 0 | ||
fi | ||
|
||
eval $(print_env) | ||
|
||
sanitize () | ||
{ | ||
# Sanitize cache name | ||
echo $1 | sed 's/[\t /\]/_/g' | ||
} | ||
|
||
check_cache () | ||
{ | ||
test -n "$cachedir" || return 1 | ||
local url=$(sanitize $1) | ||
local cachefile="${cachedir}/${url}" | ||
test -f "${cachefile}" || return 1 | ||
test -n "$cacheage" || return 0 | ||
|
||
local ctime=$(stat -c%Y ${cachefile}) | ||
local maxage=$((${cacheage}*86400)) | ||
test $ctime -gt $maxage && return 1 | ||
} | ||
|
||
add_cache () | ||
{ | ||
test -n "$cachedir" || return 0 | ||
mkdir -p "${cachedir}" && | ||
touch "${cachedir}/$(sanitize ${1})" | ||
} | ||
|
||
|
||
for pkg in $downloads; do | ||
name=$(basename ${pkg} .tar.gz) | ||
if check_cache "$name"; then | ||
say "Using cached version of ${name}" | ||
continue | ||
fi | ||
mkdir -p ${name} || die "Failed to mkdir ${name}" | ||
( | ||
cd ${name} && | ||
curl -L -O --insecure ${pkg} || die "Failed to download ${pkg}" | ||
tar --strip-components=1 -xf *.tar.gz || die "Failed to un-tar ${name}" | ||
test -x configure || ./autogen.sh | ||
test -x configure && CC=gcc ./configure --prefix=${prefix} \ | ||
${extra_configure_opts[$name]} || : && | ||
make PREFIX=${prefix} && | ||
make PREFIX=${prefix} install | ||
) || die "Failed to build and install $name" | ||
add_cache "$name" | ||
done | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/sh | ||
|
||
set -ex | ||
|
||
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope | ||
cd test/src | ||
export PATH=./:$PATH | ||
cat test.launch_1 | ||
./test.launch_1 | ||
sleep 60 | ||
cat test.attach_1 | ||
./test.attach_1 | ||
sleep 60 | ||
echo 'done' |