From b319759360da8bd8448eed1a821b92dce395cb4d Mon Sep 17 00:00:00 2001 From: Michal Rus Date: Thu, 1 Jun 2023 14:51:40 +0200 Subject: [PATCH] [DDW-1213] Try one more hack --- nix/x86_64-windows.nix | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/nix/x86_64-windows.nix b/nix/x86_64-windows.nix index fc53574a41..ee3907be17 100644 --- a/nix/x86_64-windows.nix +++ b/nix/x86_64-windows.nix @@ -225,6 +225,7 @@ in rec { echo ' ' echo '===================== '${pkgs.lib.escapeShellArg title}' =====================' ''; + completeHack = "rebuild-complete-hack-bnlzMmdjbXB5emozNWFndGx1bnd5dnh5"; in '' ${pkgs.xvfb-run}/bin/xvfb-run \ --server-args="-screen 0 1920x1080x24 +extension GLX +extension RENDER -ac -noreset" \ @@ -318,7 +319,31 @@ in rec { ${mkSection "Running @electron/rebuild"} # XXX: we need to run the command with the Node.js env set correcty, `npm.cmd` does that: - export electron_rebuild_bin="$(winepath -w "$(readlink -f node_modules/.bin/electron-rebuild)")" + lx_electron_rebuild_bin="$(readlink -f node_modules/.bin/electron-rebuild)" + export electron_rebuild_bin="$(winepath -w "$lx_electron_rebuild_bin")" + + # XXX: for some reason the build hangs (only on Cicero!) after outputting "Rebuild Complete", so let's hack around that: + sed -r '/Rebuild Complete/a require("fs").writeFileSync("${completeHack}", "");' -i "$lx_electron_rebuild_bin" + + # XXX: re-enable this if you need to simulate Cicero hanging locally: + # sed -r 's/rebuildSpinner.succeed\(\);/setTimeout(function(){rebuildSpinner.succeed();},10000);/g' -i "$lx_electron_rebuild_bin" + + ( + while true ; do + if [ -e ${completeHack} ] ; then + echo "Found ${completeHack}, killing node.exe among:" + + ps aux | cat + + pkill -9 node.exe || true + break + else + sleep 2 + fi + done + ) & + wine_killer_pid=$! + cp ${pkgs.writeText "package.json" (builtins.toJSON ( pkgs.lib.recursiveUpdate originalPackageJson { scripts = { @@ -326,9 +351,18 @@ in rec { }; } ))} package.json - wine npm.cmd run build:electron:windows - - # XXX: We’re running in a separate namespace, so this is fine. Otherwise, builds on Cicero hang. + wine npm.cmd run build:electron:windows || { + real_ec=$? + if [ -e ${completeHack} ] ; then + echo "Wine would return $real_ec, but ${completeHack} exists" + return 0 + else + return $real_ec + fi + } + kill $wine_killer_pid || true + + # XXX: We’re running in a separate namespace, so this is fine. while pgrep wine >/dev/null ; do ${mkSection "Wine is still running in the background, will try to kill it"} echo 'All remaining processes:'