Fix quotation of variables
This commit is contained in:
parent
897f0354c7
commit
e66425895b
1 changed files with 34 additions and 33 deletions
67
Dockerfile
67
Dockerfile
|
@ -55,7 +55,7 @@ RUN \
|
|||
pattern="fixme:win:NtUserLockWindowUpdate ((nil))"; \
|
||||
# The amount of times the pattern should occur for the process to be considered stuck
|
||||
patternCount=2; \
|
||||
output=$( \
|
||||
output="$( \
|
||||
sed \
|
||||
# Handle exit hints
|
||||
-e "s/^exit \([[:digit:]]\+\)$/\1/; t end;" \
|
||||
|
@ -66,45 +66,46 @@ RUN \
|
|||
# Branch "stuck": delete output and exit with code 42
|
||||
-e ":stuck s/.*//; q42;" \
|
||||
# Branch "end": exit with code 0
|
||||
-e ":end q;"); \
|
||||
-e ":end q;")"; \
|
||||
exitCode="$?"; \
|
||||
exitCode=$?; \
|
||||
# Kill installer if it got stuck (according to console output)
|
||||
[ $exitCode -eq 42 ] && pkill -9 MDK537.exe; \
|
||||
[ "$exitCode" -eq 42 ] && pkill -9 MDK537.exe; \
|
||||
# Use `sed`s exit code if non-zero
|
||||
[ $exitCode -ne 0 ] && exit $exitCode; \
|
||||
[ "$exitCode" -ne 0 ] && exit $exitCode; \
|
||||
# Use `sed`s output otherwise
|
||||
[ $exitCode -eq 0 ] && exit $output; \
|
||||
[ "$exitCode" -eq 0 ] && exit $output; \
|
||||
}; \
|
||||
# Run actual MDK537 installer
|
||||
install_keil() { \
|
||||
echo "Starting ARM Keil installation"; \
|
||||
try=$1; \
|
||||
try="$1"; \
|
||||
# Run installer asynchronously
|
||||
{ \
|
||||
{ 2>&1 WINEDEBUG=+all,trace-all,warn-all /usr/bin/entrypoint wine MDK537.exe --batch-install || echo "exit $?"; } \
|
||||
# Write output to `log.txt`
|
||||
| { [ $DEBUG -eq 1 ] && tee log.txt || cat; } \
|
||||
| { [ "$DEBUG" -eq 1 ] && tee log.txt || cat; } \
|
||||
# Pipe stdout and stderr to `handle_output` function
|
||||
| handle_output & \
|
||||
}; \
|
||||
pid=$!; \
|
||||
pid="$!"; \
|
||||
# Continuously display screenshots and iteration number
|
||||
[ $DEBUG -eq 1 ] \
|
||||
[ "$DEBUG" -eq 1 ] \
|
||||
&& { \
|
||||
{ \
|
||||
x=0; \
|
||||
maxCount=120; \
|
||||
while ps -p $pid > /dev/null && [ $x -ne $maxCount ]; do \
|
||||
while ps -p "$pid" > /dev/null && [ "$x" -ne "$maxCount" ]; do \
|
||||
# Create screenshot and print it to the console
|
||||
fileName=screens/install-try$try-$x.png; \
|
||||
import -window root $fileName; \
|
||||
tiv -w 10000 -h 10000 $fileName; \
|
||||
fileName="screens/install-try$try-$x.png"; \
|
||||
import -window root "$fileName"; \
|
||||
tiv -w 10000 -h 10000 "$fileName"; \
|
||||
x=$(bash -c "declare -i x=$x+1; echo "'$x'); \
|
||||
echo $x; \
|
||||
sleep 1; \
|
||||
done; \
|
||||
# Kill installer after timeout indicated by `maxCount`
|
||||
[ $x -eq $maxCount ] && { pkill -9 MDK537.exe; mv log.txt logs/timeout-try$try.log; }; \
|
||||
[ "$x" -eq "$maxCount" ] && { pkill -9 MDK537.exe; mv log.txt "logs/timeout-try$try.log"; }; \
|
||||
} & \
|
||||
}; \
|
||||
wait $pid; \
|
||||
|
@ -114,12 +115,12 @@ RUN \
|
|||
&& [ -f log.txt ] \
|
||||
&& { \
|
||||
# Move logs to location based on exit code
|
||||
[ $exitCode -eq 0 ] && mv log.txt logs/success-try$try.log; \
|
||||
[ $exitCode -eq 42 ] && mv log.txt logs/timeout-handled-try$try.log; \
|
||||
[ $exitCode -ne 0 ] && mv log.txt logs/fail-try$try.log; \
|
||||
[ "$exitCode" -eq 0 ] && mv log.txt "logs/success-try$try.log"; \
|
||||
[ "$exitCode" -eq 42 ] && mv log.txt "logs/timeout-handled-try$try.log"; \
|
||||
[ "$exitCode" -ne 0 ] && mv log.txt "logs/fail-try$try.log"; \
|
||||
}; \
|
||||
[ $exitCode -ne 0 ] && { \
|
||||
[ $exitCode -eq 42 ] && echo "The installation got stuck" || \
|
||||
[ "$exitCode" -ne 0 ] && { \
|
||||
[ "$exitCode" -eq 42 ] && echo "The installation got stuck" || \
|
||||
echo "The installation failed"; \
|
||||
} || \
|
||||
echo "The installation was successful"; \
|
||||
|
@ -132,16 +133,16 @@ RUN \
|
|||
# Create job for waiting for Xvfb to start
|
||||
watchStarting="$(mktemp)"; \
|
||||
{ 2>&1 inotifywait -e create /tmp/.X11-unix/; } | { sed -u -e "/^Watches established.\$/e rm \"$watchStarting\""; } & \
|
||||
resolver=$!; \
|
||||
resolver="$!"; \
|
||||
while [ -f "$watchStarting" ]; do true; done; \
|
||||
{ \
|
||||
# Improve arguments for screenshots
|
||||
ARGS=$([ $DEBUG -eq 1 ] && echo "-screen 0 640x480x24 -dpi 192" || echo ""); \
|
||||
ARGS="$([ $DEBUG -eq 1 ] && echo "-screen 0 640x480x24 -dpi 192" || echo "")"; \
|
||||
Xvfb ${DISPLAY} ${ARGS} & \
|
||||
}; \
|
||||
displayPID=$!; \
|
||||
displayPID="$!"; \
|
||||
# Wait for Xvfb to start
|
||||
wait $resolver; \
|
||||
wait "$resolver"; \
|
||||
y=0; \
|
||||
while ! \
|
||||
install_keil \
|
||||
|
@ -152,27 +153,27 @@ RUN \
|
|||
# Increase counter
|
||||
y=$(bash -c "declare -i y=$y+1; echo "'$y'); \
|
||||
done && \
|
||||
kill -9 $displayPID > /dev/null 2>&1; \
|
||||
kill -9 "$displayPID" > /dev/null 2>&1; \
|
||||
# Delete unfinished installations
|
||||
rm -rf "$(/usr/bin/entrypoint winepath 'C:\Keil_v5')/Backup."*; \
|
||||
rm MDK537.exe; \
|
||||
rm -f /tmp/.X*-lock;
|
||||
|
||||
RUN \
|
||||
keilConfig=$(/usr/bin/entrypoint winepath 'C:\Keil_v5\TOOLS.INI') && \
|
||||
keilConfig="$(/usr/bin/entrypoint winepath 'C:\Keil_v5\TOOLS.INI')" && \
|
||||
winAppData="$(/usr/bin/entrypoint wine cmd.exe /c 'echo %LOCALAPPDATA%' | tr -d '\r' | sed 's/\\/\\\\/g')" && \
|
||||
packDir="$winAppData"'\Arm\Packs' && \
|
||||
sed -i '/^RTEPATH=/d' $keilConfig && \
|
||||
echo 'RTEPATH="'"$packDir"'"' | sed -i '/\[UV2\]/ r /dev/stdin' $keilConfig
|
||||
sed -i '/^RTEPATH=/d' "$keilConfig" && \
|
||||
echo 'RTEPATH="'"$packDir"'"' | sed -i '/\[UV2\]/ r /dev/stdin' "$keilConfig"
|
||||
|
||||
RUN \
|
||||
wget ${PACK_URL} --progress=bar:force:noscroll --no-check-certificate -O InES.pack; \
|
||||
wget "${PACK_URL}" --progress=bar:force:noscroll --no-check-certificate -O InES.pack; \
|
||||
/usr/bin/entrypoint xvfb-run wine 'C:\Keil_v5\UV4\PackUnzip.exe' --embedded --agree-license InES.pack & \
|
||||
pid=$!; \
|
||||
wait $pid; \
|
||||
pkill -P -9 $pid > /dev/null 2>&1; \
|
||||
kill -9 $pid > /dev/null 2>&1; \
|
||||
kill -9 $displayPID > /dev/null 2>&1; \
|
||||
pid="$!"; \
|
||||
wait "$pid"; \
|
||||
pkill -P -9 "$pid" > /dev/null 2>&1; \
|
||||
kill -9 "$pid" > /dev/null 2>&1; \
|
||||
kill -9 "$displayPID" > /dev/null 2>&1; \
|
||||
rm InES.pack; \
|
||||
rm -f /tmp/.X*-lock;
|
||||
|
||||
|
|
Loading…
Reference in a new issue