From ed4beb91b01e498be778eda66f19218e2339aafa Mon Sep 17 00:00:00 2001 From: Alexander Schwinn <al.schwinn@gsi.de> Date: Tue, 22 Nov 2022 10:39:23 +0100 Subject: [PATCH] Updated and automated snap7 build --- snap7/.gitignore | 3 +-- snap7/build.sh | 54 +++++++++++++++++++++++++++++++++++++++--------- snap7/install.sh | 5 ++++- 3 files changed, 49 insertions(+), 13 deletions(-) diff --git a/snap7/.gitignore b/snap7/.gitignore index 07cc7ee..4d3bafb 100644 --- a/snap7/.gitignore +++ b/snap7/.gitignore @@ -1,2 +1 @@ -snap7-full/ -/snap7-full-1.4.0.tar.gz +/snap7-ful* diff --git a/snap7/build.sh b/snap7/build.sh index 4fb7c06..256d415 100755 --- a/snap7/build.sh +++ b/snap7/build.sh @@ -1,16 +1,50 @@ #!/bin/sh set -e -SNAP7_VERSION=1.4.0 +# First argument has to be the desired snap7 version +SNAP7_VERSION=$1 + +SCRIPT=$(readlink -f "$0") +SCRIPTPATH=$(dirname "$SCRIPT") # path where this script is located in SNAP7_FOLDER=snap7-full-${SNAP7_VERSION} +SNAP7_PATH=${SCRIPTPATH}/${SNAP7_FOLDER} + +echo ${SNAP7_PATH} +# If there is no snap7 folder yet, we download the required version and build it +if [ -d ${SNAP7_PATH} ]; then + echo "Some snap7 version is already available. No need to download/build it" + #TODO Check if the version matches +else + + archiveFile=${SNAP7_FOLDER}.tar.gz + archiveFilePath=${SCRIPTPATH}/${SNAP7_FOLDER}.tar.gz + + echo "Cleanup" + rm -rf snap7-ful* + + if [ ! -f "$archiveFilePath" ] + then + echo "Downloading snap7" + cd ${SCRIPTPATH} + wget http://downloads.sourceforge.net/project/snap7/${SNAP7_VERSION}/${archiveFile} + fi -archiveFile=${SNAP7_FOLDER}.tar.gz -if [ ! -f "$archiveFile" ] -then - rm -rf snap7-full* - wget http://downloads.sourceforge.net/project/snap7/${SNAP7_VERSION}/${archiveFile} - tar -vxzf ${archiveFile} - mv ${SNAP7_FOLDER} snap7-full + if [ ! -d ${SNAP7_PATH} ] + then + echo "Extracting snap7" + tar -vxzf ${archiveFilePath} + rm ${archiveFilePath} + fi + + if [ ! -d ${SCRIPTPATH}/snap7-full ] + then + echo "Creating symlink" + ln -s ${SNAP7_PATH} ${SCRIPTPATH}/snap7-full + fi + + echo "Building snap7" + cd ${SNAP7_FOLDER}/build/unix + make -f x86_64_linux.mk fi -cd snap7-full/build/unix -make -f x86_64_linux.mk + + diff --git a/snap7/install.sh b/snap7/install.sh index c89ea37..553fbf9 100755 --- a/snap7/install.sh +++ b/snap7/install.sh @@ -4,7 +4,7 @@ set -e RELEASE_DIR_BASE=$1 SILECS_VERSION=$2 -SNAP7_VERSION=1.4.2 +SNAP7_VERSION=1.4.0 SCRIPT=$(readlink -f "$0") SCRIPTPATH=$(dirname "$SCRIPT") # path where this script is located in @@ -15,6 +15,9 @@ if [ -d ${RELEASE_DIR} ]; then exit 1 fi +# Download and build snap7 if required +${SCRIPTPATH}/build.sh ${SNAP7_VERSION} + mkdir -p ${RELEASE_DIR} cp -r ${SCRIPTPATH}/snap7-full/build/bin/x86_64-linux ${RELEASE_DIR} -- GitLab