deps_check.sh 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/bash
  2. # deps_check.sh <vm> <app dir | installed> [source tarball] - we_manager's "install build dependencies" for a source build
  3. # on the VM's package manager (pkexec with a polkit rule for the lab user standing in for the dialog), then the engine's
  4. # CMake configure on the source tarball: it only passes when everything the build needs got installed. SKIPs the
  5. # install on image based systems (we_manager refuses there). Needs the session running (sessenv).
  6. HERE=$(cd "$(dirname "$0")" && pwd)
  7. vm=$1 app=$2 src=${3:-${TMPDIR:-/tmp}/lwe-src.tgz}
  8. sshv() { "$HERE/linuxvm.sh" ssh "$vm" "$@" </dev/null; }
  9. status=0
  10. pass() { echo "PASS $1"; }
  11. fail() { echo "FAIL $1"; status=1; }
  12. cdp() { sshv ". ~/sessenv; cd ~/wem; timeout ${2:-900} timeout ${CDP_TIMEOUT:-90} python3 cdp.py \"$1\" 2>&1 | cut -c1-600"; }
  13. sshv 'mkdir -p ~/wem; pkill -f "[w]e-manager" 2>/dev/null
  14. sudo mkdir -p /etc/polkit-1/rules.d
  15. printf "polkit.addRule(function(action, subject) { if (subject.user == \"lab\") return polkit.Result.YES; });\n" | sudo tee /etc/polkit-1/rules.d/49-lab-test.rules >/dev/null; true'
  16. "$HERE/linuxvm.sh" scp "$vm" "$HERE/cdp.py" wem/cdp.py
  17. if [ -d "$app" ]; then
  18. rm_old=$(basename "$app"); sshv "rm -rf ~/wem/$rm_old"
  19. tar -C "$(dirname "$app")" -cf - "$rm_old" | ssh -i "$HOME/.local/share/linuxvm/id_ed25519" -p "$(cat "$HOME/.local/share/linuxvm/vms/$vm/port")" \
  20. -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR lab@127.0.0.1 'mkdir -p ~/wem && tar -C ~/wem -xf -'
  21. fi
  22. if [[ $app == installed ]]; then start="${WEM_LAUNCH:-} we-manager ${WEM_FLAGS:-}"; else start="${WEM_LAUNCH:-} ~/wem/$(basename "$app")/we-manager --no-sandbox ${WEM_FLAGS:-}"; fi
  23. sshv ". ~/sessenv; (setsid nohup $start --remote-debugging-port=9222 > ~/wem/app-deps.log 2>&1 </dev/null &); sleep 25"
  24. distro=$(cdp 'window.electronAPI.lwe.detectDistro()'); echo " detected distro: $distro"
  25. if sshv 'test -e /run/ostree-booted'; then
  26. echo "SKIP dependency install: image based system, we_manager refuses it (no source build there, nothing to configure)"
  27. sshv 'pkill -f "[w]e-manager" 2>/dev/null; sudo rm -f /etc/polkit-1/rules.d/49-lab-test.rules; true'
  28. exit 0
  29. else
  30. out=$(cdp 'window.electronAPI.lwe.installDeps()' 1200)
  31. if echo "$out" | grep -q '"ok": true'; then pass "we_manager installed the build dependencies ($distro)"; else fail "dependency install: $out"; fi
  32. fi
  33. if [ -n "$LIBNODE_PKG" ]; then
  34. # Arch only has libnode in the AUR, we_manager leaves it to the user: a package built from the AUR recipe stands in
  35. "$HERE/linuxvm.sh" scp "$vm" "$LIBNODE_PKG" libnode.pkg.tar.zst
  36. sshv 'sudo pacman -U --noconfirm ~/libnode.pkg.tar.zst >/tmp/libnode.log 2>&1; tail -1 /tmp/libnode.log'
  37. fi
  38. "$HERE/linuxvm.sh" scp "$vm" "$src" lwe-src.tgz
  39. out=$(sshv 'rm -rf ~/src && mkdir ~/src && tar -C ~/src -xzf ~/lwe-src.tgz && cd ~/src && cmake -S . -B build -DCMAKE_BUILD_TYPE=Release > /tmp/cmake-deps.log 2>&1; echo rc=$?; grep -E "Found V8|CMake Error|Could NOT|not found" /tmp/cmake-deps.log | head -5')
  40. if echo "$out" | grep -q 'Could NOT find V8' && ! sshv 'ls /usr/lib64/libnode.so* /usr/lib/libnode.so* /usr/lib/*/libnode.so* >/dev/null 2>&1'; then
  41. echo "SKIP engine configure: this release has no Node.js shared library (libnode), a source build is not possible, the prebuilt engine is the way (we_manager says so after the install)"
  42. elif echo "$out" | grep -q '^rc=0'; then pass "the engine configures with those packages: $(echo "$out" | grep "Found V8")"; else fail "cmake configure failed: $out"; fi
  43. sshv 'pkill -f "[w]e-manager" 2>/dev/null; sudo rm -f /etc/polkit-1/rules.d/49-lab-test.rules; true'
  44. exit $status