--- a/codesys-ide/codesys +++ b/codesys-ide/codesys @@ -46,8 +46,38 @@ cp ${libdir}/${libbase}.pdf .drone-artifacts/${libdir}/${libbase}.pdf fi done +elif [ "${1}" == "install" ]; then + # check if file exists, before we call PackageManager with it + url=${2} + filename=${url} + tmpfile=$(mktemp --suffix=.package) + if [ "${url%:*}" == "https" ]; then + filename=${tmpfile} + wget --output-document=${filename} "${url}" + elif [ ! -f ${filename} ]; then + echo "error: package '${filename}' not found." + exit -1 + fi + export DISPLAY=:91 + Xvfb :91 &> /dev/zero & + sleep 1 + export WINEPREFIX=~/.wine.cds + ${WINE} ~/.wine.cds/drive_c/CODESYS/CODESYS/Common/PackageManagerCLI.exe --culture=en --profile="'"${profile}"'" --components="typical" --verbose --install="${filename}" + + result=$? + + rm ${tmpfile} + + sleep 1 + killall Xvfb + rm -rf /tmp/.X91* + + if [ "${result}" == "0" ]; then + true + else + false + fi else - # check if file exists, before we call CODESYS with it if [ ! -f ${BASEPATH}/${1}.py ]; then echo "error: script '${BASEPATH}/${1}.py' not found."