From a22772e03e9141dfc651d7bb8cadf30f5bfe2dea Mon Sep 17 00:00:00 2001 From: Mathieu Hofman Date: Sun, 30 Jun 2024 05:50:08 +0000 Subject: [PATCH] fix(agd): check xsnap was rebuilt --- packages/xsnap/package.json | 2 ++ packages/xsnap/scripts/get_xsnap_version.sh | 14 ++++++++++++++ repoconfig.sh | 3 +-- scripts/agd-builder.sh | 15 +++------------ 4 files changed, 20 insertions(+), 14 deletions(-) create mode 100755 packages/xsnap/scripts/get_xsnap_version.sh diff --git a/packages/xsnap/package.json b/packages/xsnap/package.json index 3d67a418912..fd157a7be7d 100644 --- a/packages/xsnap/package.json +++ b/packages/xsnap/package.json @@ -16,6 +16,7 @@ "build:env": "node src/build.js --show-env > build.env", "build:from-env": "{ cat build.env; echo node src/build.js; } | xargs env", "build": "yarn build:bin && yarn build:env", + "check-version": "xsnap_version=$(./scripts/get_xsnap_version.sh); if test \"${npm_package_version}\" != \"${xsnap_version}\"; then echo \"xsnap version mismatch; expected '${npm_package_version}', got '${xsnap_version}'\"; exit 1; fi", "postinstall": "npm run build:from-env", "clean": "rm -rf xsnap-native/xsnap/build", "lint": "run-s --continue-on-error lint:*", @@ -56,6 +57,7 @@ "moddable/xs/makefiles", "moddable/xs/platforms/*.h", "moddable/xs/sources", + "scripts", "src", "xsnap-native/xsnap/makefiles", "xsnap-native/xsnap/sources" diff --git a/packages/xsnap/scripts/get_xsnap_version.sh b/packages/xsnap/scripts/get_xsnap_version.sh new file mode 100755 index 00000000000..065c3724ab2 --- /dev/null +++ b/packages/xsnap/scripts/get_xsnap_version.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +set -ueo pipefail + +# the xsnap binary lives in a platform-specific directory +unameOut="$(uname -s)" +case "${unameOut}" in + Linux*) platform=lin ;; + Darwin*) platform=mac ;; + *) platform=win ;; +esac + +# extract the xsnap package version from the long version printed by xsnap-worker +"./xsnap-native/xsnap/build/bin/${platform}/release/xsnap-worker" -v | sed -e 's/^xsnap \([^ ]*\) (XS [^)]*)$/\1/g' diff --git a/repoconfig.sh b/repoconfig.sh index 14194defb79..231093a2c66 100644 --- a/repoconfig.sh +++ b/repoconfig.sh @@ -4,7 +4,6 @@ NODEJS_VERSION=v16 GOLANG_VERSION=1.20.3 GOLANG_DIR=golang/cosmos GOLANG_DAEMON=$GOLANG_DIR/build/agd -XSNAP_VERSION=agoric-upgrade-10 # Args are major, minor and patch version numbers golang_version_check() { @@ -12,7 +11,7 @@ golang_version_check() { [ "$1" -eq 1 ] && [ "$2" -eq 20 ] && [ "$3" -ge 2 ] && return 0 [ "$1" -eq 1 ] && [ "$2" -ge 21 ] && return 0 [ "$1" -ge 2 ] && return 0 - } 2>/dev/null + } 2> /dev/null echo 1>&2 "need go version 1.20.2+, 1.21+, or 2+" return 1 } diff --git a/scripts/agd-builder.sh b/scripts/agd-builder.sh index e55a4173c3e..39a1648dc44 100755 --- a/scripts/agd-builder.sh +++ b/scripts/agd-builder.sh @@ -219,21 +219,12 @@ $do_not_build || ( echo "At least $src is newer than gyp bindings" (cd "$GOLANG_DIR" && lazy_yarn build:gyp) } + + # check the built xsnap version against the package version it should be using + (cd "${thisdir}/../packages/xsnap" && npm run -s check-version) || exit 1 fi ) -# the xsnap binary lives in a platform-specific directory -unameOut="$(uname -s)" -case "${unameOut}" in - Linux*) platform=lin ;; - Darwin*) platform=mac ;; - *) platform=win ;; -esac - -# check the xsnap version against our baked-in notion of what version we should be using -xsnap_version=$("${thisdir}/../packages/xsnap/xsnap-native/xsnap/build/bin/${platform}/release/xsnap-worker" -n) -[[ "${xsnap_version}" == "${XSNAP_VERSION}" ]] || fatal "xsnap version mismatch; expected ${XSNAP_VERSION}, got ${xsnap_version}" - if $only_build; then echo "Build complete." 1>&2 exit 0