Skip to content
This repository has been archived by the owner on Sep 29, 2022. It is now read-only.

Commit

Permalink
Added recipe for gatling-2.2.0 package
Browse files Browse the repository at this point in the history
  • Loading branch information
mutirri committed Jan 15, 2015
1 parent 1ce03c0 commit 3099c23
Show file tree
Hide file tree
Showing 4 changed files with 342 additions and 0 deletions.
2 changes: 2 additions & 0 deletions gatling/bld.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
python setup.py install
if errorlevel 1 exit 1
112 changes: 112 additions & 0 deletions gatling/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#!/bin/bash

MACHINE="$(uname 2>/dev/null)"

LinuxInstallation() {
# Build dependencies:
# - java-1.6.0-openjdk-devel

local javaVersion=''
local pkgBaseDir="${PKG_NAME}-${PKG_VERSION}"
local aliasPkgBaseDir="${PKG_NAME}"
local fullPkgBaseDir="${PREFIX}/share/${pkgBaseDir}"
local fullAliasPkgBaseDir="${PREFIX}/share/${aliasPkgBaseDir}"
local launchWrapperName="launch-symlink"
local binLaunchWrapper="${fullPkgBaseDir}/bin/${launchWrapperName}"
local pkgRelBinPath="../share/${aliasPkgBaseDir}/bin"

shopt -s extglob;

${RECIPE_DIR}/latest-java-detector.sh;
if [[ ${?} -eq 1 ]]; then
${RECIPE_DIR}/latest-java-detector.sh -d;
if [[ ${?} -eq 1 ]]; then
echo -e "Unable to setup JAVA_HOME and/or JRE_HOME in built environment";
exit 1;
else
export JAVA_HOME="$(${RECIPE_DIR}/latest-java-detector.sh -d| grep 'export JAVA_HOME='| cut -d '=' -f 2)"
export JRE_HOME="$(${RECIPE_DIR}/latest-java-detector.sh -d| grep 'export JRE_HOME='| cut -d '=' -f 2)"
fi
fi

mkdir -vp ${PREFIX}/bin || exit 1;
mkdir -vp ${PREFIX}/share || exit 1;
mkdir -vp ${fullPkgBaseDir} || exit 1;

pushd ${PREFIX}/share || exit 1;
ln -sv ${pkgBaseDir} ${aliasPkgBaseDir} || exit 1;
popd || exit 1;

mv -v ${SRC_DIR}/* ${fullPkgBaseDir}/ || exit 1;

pushd ${fullPkgBaseDir}/bin || exit 1;
chmod -v 755 *;

cp -v ${RECIPE_DIR}/latest-java-detector.sh ${PREFIX}/bin/ || exit 1;

for bin in ${binLaunchWrapper}; do
cat > ${bin} <<EOF
#!/bin/bash
SCRIPT_CUR_DIR="\$(dirname "\${0}" 2>/dev/null)"
SCRIPT_REL_DIR="\$(dirname "\$(readlink "\${0}" 2>/dev/null)" 2>/dev/null)"
SCRIPT_DIR="\$(cd "\${SCRIPT_CUR_DIR}/\${SCRIPT_REL_DIR}" 2>/dev/null && pwd -P 2>/dev/null)"
SCRIPT_FILE_NAME="\$(basename "\${0}" 2>/dev/null)"
SCRIPT_FILE="\${SCRIPT_DIR}/\${SCRIPT_FILE_NAME}"
if [[ ! -d \${SCRIPT_DIR} ]]; then
echo -e "Problem with launch-wrapper, no directory was found: \${SCRIPT_DIR}" && exit 1;
fi
if [[ ! -f \${SCRIPT_FILE} ]]; then
echo -e "Problem with launch-wrapper, no file was found: \${SCRIPT_FILE}" && exit 1;
fi
latest-java-detector.sh;
if [[ \${?} -eq 1 ]]; then
latest-java-detector.sh -d;
if [[ \${?} -eq 1 ]]; then
echo -e "Unable to setup JAVA_HOME and/or JRE_HOME in environment" && exit 1;
else
export JAVA_HOME="\$(latest-java-detector.sh -d| grep 'export JAVA_HOME='| cut -d '=' -f 2)"
export JRE_HOME="\$(latest-java-detector.sh -d| grep 'export JRE_HOME='| cut -d '=' -f 2)"
fi
fi
echo -e "\nlaunch-wrapper:"
echo -e "\tRunning -> \${SCRIPT_FILE}";
echo -e "\tWith args -> \${@}";
echo -e "";
"\${SCRIPT_FILE}" "\${@}"
EOF
chmod -v 755 ${bin} || return 1;
done

### Setup bin

pushd ${PREFIX}/bin || return 1;

for filePath in ${pkgRelBinPath}/*; do
fileName="$(basename "${filePath}" 2>/dev/null)"

if [[ ${fileName} == ${launchWrapperName} ]]; then
continue;
fi

ln -vs ${pkgRelBinPath}/${launchWrapperName} ${fileName} || return 1;
done

popd || return 1;

return 0;
}

case ${MACHINE} in
'Linux'|'Darwin')
LinuxInstallation || exit 1;
;;
*)
echo -e "Unsupported machine type: ${MACHINE}";
exit 1;
;;
esac
208 changes: 208 additions & 0 deletions gatling/latest-java-detector.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
#!/bin/bash

#############
# VARIABLES #
#############

SCRIPT_NAME="${0}"
CMD="${1}"

MACHINE_TYPE="unknown"

DETERMINED_JAVA_HOME=""
DETERMINED_JRE_HOME=""

#############
# FUNCTIONS #
#############

f_CheckJavaHomeVariable() {
if [[ -z ${JAVA_HOME} ]]; then
echo -e "You have NO setup of JAVA_HOME variable!";
return 1;
else
if [[ ! -x ${JAVA_HOME}/bin/java ]]; then
echo -e "Your JAVA_HOME variable is NOT pointing to right directory with java (no executable bin/java was found there)!";
return 1;
fi
fi

return 0;
}

f_CheckJreHomeVariable() {
if [[ -z ${JRE_HOME} ]]; then
echo -e "You have NO setup of JRE_HOME variable!";
return 1;
else
if [[ ! -x ${JRE_HOME}/bin/java ]]; then
echo -e "Your JRE_HOME variable is NOT pointing to right directory with java (no executable bin/java was found there)!";
return 1;
fi
fi

return 0;
}

f_PrintError() {
cmd="${1}"

cat <<NEWEOF
Can't determine appropriate value for JAVA_HOME and JAVA_JRE variables.
Probably You have no java installed at all.
Please run below command and eventually re-run this script:
$ ${cmd}
NEWEOF

return 0;
}

f_DetermineMachineType() {
local machineType=''

uname|grep -q '^Darwin';
[[ ${?} -eq 0 ]] && {
export MACHINE_TYPE="osx"
return 0;
}

which yum &>/dev/null;
if [[ ${?} -eq 0 ]]; then
machineType='centos'
else
which apt-get &>/dev/null;
if [[ ${?} -eq 0 ]]; then
machineType='debian'
else
cat <<NEWEOF
Sorry but your machine type is not supported.
The support is available only for linux distros with:
a) apt-get package manager
b) yum package manager
And OSX machines.
NEWEOF
exit 1;
fi
fi

export MACHINE_TYPE="${machineType}"

return 0;
}

f_DetermineVariables() {
local determined_home=''
local test_home=0
local pattern=''
local javaPath=''

case ${MACHINE_TYPE} in
'centos'|'debian')
javaPath="/usr/lib/jvm/"
;;
'osx')
javaPath="/System/Library/Java/JavaVirtualMachines/"
;;
*)
echo -e "Internal error!";
exit 1;
;;
esac

determined_home="$(find ${javaPath} -wholename '*bin/java' 2>/dev/null| sort -r| head -n1)"

case ${MACHINE_TYPE} in
'centos')
cmd="sudo yum install java-1.6.0-openjdk-devel"
;;
'debian')
cmd="sudo apt-get install openjdk-6-jdk"
;;
'osx')
cmd="Use package manager and install java 6 in your OSX system."
;;
*)
echo -e "Internal error!";
exit 1;
;;
esac

[[ -z ${determined_home} ]] && test_home=1;

pattern="${determined_home:${#determined_home} - 8}"

[[ ${pattern} != "bin/java" ]] && test_home=1
[[ ! -x ${determined_home} ]] && test_home=1;

determined_home="${determined_home%%/bin/java}"

if [[ ${test_home} -eq 1 ]]; then
f_PrintError "${cmd}" && return 1;
fi

DETERMINED_JAVA_HOME="${determined_home}"
DETERMINED_JRE_HOME="${determined_home}"

cat <<NEWEOF
You should setup in your environment (for example in .bashrc file):
export JAVA_HOME=${DETERMINED_JAVA_HOME}
export JRE_HOME=${DETERMINED_JRE_HOME}
Then restart current shell to properly propagate the changes.
NEWEOF

export JAVA_HOME="${DETERMINED_JAVA_HOME}"
export JRE_HOME="${DETERMINED_JRE_HOME}"

return 0;
}

f_TestJava() {
f_CheckJavaHomeVariable || return 1;
f_CheckJreHomeVariable || return 1;

return 0;
}

f_Usage() {

cat <<NEWEOF
${SCRIPT_NAME} [-h|-d]
-h Print this help.
-d Try to determine appropriate JAVA_HOME and JRE_HOME variables on curent system.
Without specifying one of above parameters scripts will check if JAVA_HOME and JRE_HOME are
appropriately setup (if not then appropriately info will be printed and return code equals to 1)
NEWEOF

return 0;
}

f_Main() {
shopt -s extglob;

f_DetermineMachineType;

if [[ ${CMD} == '-h' ]]; then
f_Usage;
return 0;
elif [[ ${CMD} == '-d' ]]; then
f_DetermineVariables || return 1;
return 0;
fi

f_TestJava || return 1;

return 0;
}

########
# MAIN #
########

f_Main ${CMD} || exit 1;
20 changes: 20 additions & 0 deletions gatling/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

package:
name: gatling
version: 2.2.0

source:
fn: gatling-charts-highcharts-bundle-2.2.0-20150114.161537-60-bundle.zip
url: https://oss.sonatype.org/content/repositories/snapshots/io/gatling/highcharts/gatling-charts-highcharts-bundle/2.2.0-SNAPSHOT/gatling-charts-highcharts-bundle-2.2.0-20150114.161537-60-bundle.zip
md5: a650a3cb84a4cb8fb02c5751d50e401d

build:
number: 0

test:
commands:
- gatling.sh --help

about:
home: http://gatling.io
license: Apache license 2.0

0 comments on commit 3099c23

Please sign in to comment.