1#!/bin/bash 2 3set -e 4 5if [ $# -lt 1 ]; then 6 echo "Usage: $0 <spring_VERSION.exe> <outputpath>" 7 exit 8fi 9 10# check req. 11`which wine &> /dev/null` || (echo "Error: You need wine installed!"; exit) 12`which winepath &> /dev/null` || (echo "Error: You need winepath installed!"; exit) 13`which 7z &> /dev/null` || (echo "Error: You need 7z installed!"; exit) 14 15 16# prepare 17INSTALLER=$1 18OUTPUTPATH=$2 19 20if [ -n ${OUTPUTPATH} ]; then 21 if [ ! -d ${OUTPUTPATH} ]; then 22 echo "${OUTPUTPATH} doesn't exist!" 23 exit 1 24 fi 25 OUTPUTPATH="${OUTPUTPATH}/" 26fi 27 28VERSION=`basename ${INSTALLER} .exe` 29VERSION=${VERSION:7} 30echo ${VERSION} detected 31TEMPDIR=`mktemp -d` 32 33echo Temporary directory: ${TEMPDIR} 34 35# create a tempdir 36PATHNAME=spring-${VERSION} 37INSTPATH=${TEMPDIR}/${PATHNAME} 38mkdir -p "${INSTPATH}" 39 40# detect wine `windows` peth of the tempdir 41WINEINSTPATH=`winepath -w "${INSTPATH}"` 42if [ "${WINEINSTPATH:0:4}" = "\\\\?\\" ]; then 43 echo "Error: Couldn't translate tempdir path" 44 exit 45fi 46 47# make the path passable via linux bash \ -> \\ 48WINEINSTPATH="${WINEINSTPATH//\\/\\\\}" 49 50# install in tempdir via wine 51INSTCOMMAND="wine ${INSTALLER} /S /PORTABLE /NOREGISTRY /NODESKTOPLINK /NOSTARTMENU /D=$WINEINSTPATH" 52echo $INSTCOMMAND 53 54if ! sh -c "$INSTCOMMAND" ; then 55 echo "Error: Installation failed" 56 exit 57fi 58 59# compress 607z a -t7z -m0=lzma -mx=9 -mfb=64 -md=64m -ms=on ${OUTPUTPATH}spring_${VERSION}_portable.7z ${INSTPATH} 61 62rm -rf ${TEMPDIR} 63 64