Skip to content
Snippets Groups Projects
Commit 5af19857 authored by al.schwinn's avatar al.schwinn
Browse files

fixed return/exit chaos

parent c2cc2f00
No related branches found
No related tags found
No related merge requests found
#!/bin/sh
set -e
# Usage examples: # Usage examples:
# first you need to source this script, so that you can use it's methods: # first you need to source this script, so that you can use it's methods:
# $ source releaseSilecs.sh # $ source releaseSilecs.sh
...@@ -18,12 +15,24 @@ set -e ...@@ -18,12 +15,24 @@ set -e
# List of silecs packages which is released or patched # List of silecs packages which is released or patched
PACKAGES="silecs-codegen silecs-model silecs-communication-cpp silecs-diagnostic-cpp snap7" PACKAGES="silecs-codegen silecs-model silecs-communication-cpp silecs-diagnostic-cpp snap7"
# Check that folder exists, print proper error if not
checkFolderExists()
{
FOLDER=$1
if [ ! -d ${FOLDER} ]; then
echo "Error: The folder '${FOLDER}' is needed in order to finish the installation."
echo "Installation cancelled."
exit 1
fi
}
# releases all silecs-packages to release-dir # releases all silecs-packages to release-dir
function release release()
{ {
VERSION=$1 VERSION=$1
RELEASE_DIR_BASE=$2 RELEASE_DIR_BASE=$2
WORKSPACE=$3 WORKSPACE=$3
checkFolderExists ${WORKSPACE}
for PACKAGE in $PACKAGES; do for PACKAGE in $PACKAGES; do
INSTALL_DIR=${RELEASE_DIR_BASE}/${PACKAGE}/${VERSION} INSTALL_DIR=${RELEASE_DIR_BASE}/${PACKAGE}/${VERSION}
...@@ -31,6 +40,7 @@ function release ...@@ -31,6 +40,7 @@ function release
echo "Error: Silecs version ${VERSION} is already installed in ${INSTALL_DIR}. Exiting now." echo "Error: Silecs version ${VERSION} is already installed in ${INSTALL_DIR}. Exiting now."
return 1 return 1
else else
checkFolderExists ${WORKSPACE}/${PACKAGE}
echo "installing ${INSTALL_DIR} from ${WORKSPACE}/${PACKAGE}" echo "installing ${INSTALL_DIR} from ${WORKSPACE}/${PACKAGE}"
${WORKSPACE}/${PACKAGE}/install.sh ${INSTALL_DIR} ${WORKSPACE}/${PACKAGE}/install.sh ${INSTALL_DIR}
fi fi
...@@ -38,40 +48,49 @@ function release ...@@ -38,40 +48,49 @@ function release
return 0 return 0
} }
function plugin_release plugin_release()
{ {
RELEASE_DIR_BASE=$1 (
WORKSPACE=$2 set -e
PACKAGE=silecs-eclipse-plugin-update-site RELEASE_DIR_BASE=$1
INSTALL_DIR=${RELEASE_DIR_BASE}/${PACKAGE} WORKSPACE=$2
echo "installing ${INSTALL_DIR} from ${WORKSPACE}/${PACKAGE}" PACKAGE=silecs-eclipse-plugin-update-site
${WORKSPACE}/${PACKAGE}/install.sh ${INSTALL_DIR} INSTALL_DIR=${RELEASE_DIR_BASE}/${PACKAGE}
checkFolderExists ${WORKSPACE}/${PACKAGE}
echo "installing ${INSTALL_DIR} from ${WORKSPACE}/${PACKAGE}"
${WORKSPACE}/${PACKAGE}/install.sh ${INSTALL_DIR}
return 0
)
} }
# releases a specific package to release-dir. For all other packages symlinks to the base-version are generated # releases a specific package to release-dir. For all other packages symlinks to the base-version are generated
function patch patch()
{ {
PACKAGE_TO_PATCH=$1 PACKAGE_TO_PATCH=$1
NEW_VERSION=$2 NEW_VERSION=$2
BASE_VERSION=$3 BASE_VERSION=$3
RELEASE_DIR_BASE=$4 RELEASE_DIR_BASE=$4
WORKSPACE=$5 WORKSPACE=$5
checkFolderExists ${WORKSPACE}
for PACKAGE in $PACKAGES; do for PACKAGE in $PACKAGES; do
INSTALL_DIR=${RELEASE_DIR_BASE}/${PACKAGE}/${NEW_VERSION} INSTALL_DIR=${RELEASE_DIR_BASE}/${PACKAGE}/${NEW_VERSION}
BASE_DIR=${RELEASE_DIR_BASE}/${PACKAGE}/${BASE_VERSION} BASE_DIR=${RELEASE_DIR_BASE}/${PACKAGE}/${BASE_VERSION}
checkFolderExists ${BASE_DIR}
if [ "$PACKAGE" == "$PACKAGE_TO_PATCH" ]; then if [ "$PACKAGE" == "$PACKAGE_TO_PATCH" ]; then
if [ -d ${INSTALL_DIR} ]; then if [ -d ${INSTALL_DIR} ]; then
if [ -L ${INSTALL_DIR} ]; then if [ -L ${INSTALL_DIR} ]; then
checkFolderExists ${WORKSPACE}/${PACKAGE}
# Replace Sym-Link with patch-version ... needed if more than one package is patched for the same version # Replace Sym-Link with patch-version ... needed if more than one package is patched for the same version
unlink ${INSTALL_DIR} unlink ${INSTALL_DIR}
echo "installing ${INSTALL_DIR} from ${WORKSPACE}/${PACKAGE}" checkFolderExists ${WORKSPACE}/${PACKAGE}
${WORKSPACE}/${PACKAGE}/install.sh ${INSTALL_DIR} ${WORKSPACE}/${PACKAGE}/install.sh ${INSTALL_DIR}
else else
echo "Error: Silecs version ${NEW_VERSION} of package ${PACKAGE} is already installed in ${INSTALL_DIR}. Exiting now." echo "Error: Silecs version ${NEW_VERSION} of package ${PACKAGE} is already installed in ${INSTALL_DIR}. Exiting now."
return 1 return 1
fi fi
else else
checkFolderExists ${WORKSPACE}/${PACKAGE}
echo "installing ${INSTALL_DIR} from ${WORKSPACE}/${PACKAGE}" echo "installing ${INSTALL_DIR} from ${WORKSPACE}/${PACKAGE}"
${WORKSPACE}/${PACKAGE}/install.sh ${INSTALL_DIR} ${WORKSPACE}/${PACKAGE}/install.sh ${INSTALL_DIR}
fi fi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment