From b9840c5801c4edb72dcde2e9539f7dae915e3bf3 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> Date: Mon, 8 Dec 2025 11:52:24 +0000 Subject: [PATCH] Fixes to docs and scripts for building seshat (#2733) ... because it took me all day to figure out. --- README.md | 4 +++- docs/native-node-modules.md | 28 ++++++++++++++++++++++++++-- scripts/hak/link.ts | 32 ++++---------------------------- scripts/in-docker.sh | 6 ++++++ 4 files changed, 39 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 47156350..a71c85c8 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,9 @@ If you only want to run the app locally and don't need to build packages, you ca provide the `webapp` directory directly: ``` -# Assuming you've checked out and built a copy of element-web in ../element-web +# Assuming you've checked out and built a copy of element-web in ../element-web. +# Note that you will not be able to `yarn build` after this, but `yarn start` +# will work fine. ln -s ../element-web/webapp ./ ``` diff --git a/docs/native-node-modules.md b/docs/native-node-modules.md index 675af42c..ab226184 100644 --- a/docs/native-node-modules.md +++ b/docs/native-node-modules.md @@ -13,12 +13,35 @@ custom build of Element without installing the various build tools required. The process is automated by [vector-im/element-builder](https://github.com/vector-im/element-builder) when releasing. +## Use docker + +If you are building for Linux, you can build the native modules with: + +``` +yarn docker:setup +yarn docker:install +INDOCKER_SQLCIPHER_BUNDLED=1 yarn docker:build:native +``` + +The above will build `matrix-seshat` in +`docker/node_modules/matrix-seshat`. You can then either run `yarn docker:build` +to build the app inside docker, or: + +``` +yarn --cwd docker/node_modules/matrix-seshat link +yarn link matrix-seshat +``` + +... and build the app with `yarn build` or run it with `yarn start`. + +(See also https://github.com/element-hq/element-desktop#docker.) + ## Building Install the pre-requisites for your system: - [Windows pre-requisites](https://github.com/vector-im/element-desktop/blob/develop/docs/windows-requirements.md) -- Linux: TODO +- Linux: TODO. Using the docker environment as above is recommended. - OS X: TODO Then optionally, [add seshat and dependencies to support search in E2E rooms](#adding-seshat-for-search-in-e2e-encrypted-rooms). @@ -56,7 +79,8 @@ This is also needed to when pulling in changes to Seshat using `yarn link`. Recompiling Seshat itself can be done like so: - yarn run electron-build-env -- --electron 6.1.1 -- neon build matrix-seshat --release + ELECTRON_VERSION=$(electron --version) + yarn run electron-build-env -- --electron ${ELECTRON_VERSION#v} -- neon build matrix-seshat --release Please make sure to include all the `--` as well as the `--release` command line switch at the end. Modify your electron version accordingly depending on the diff --git a/scripts/hak/link.ts b/scripts/hak/link.ts index c2c43ceb..f528c154 100644 --- a/scripts/hak/link.ts +++ b/scripts/hak/link.ts @@ -7,41 +7,17 @@ Please see LICENSE files in the repository root for full details. */ import path from "node:path"; -import os from "node:os"; -import fsProm from "node:fs/promises"; import type HakEnv from "./hakEnv.js"; import { type DependencyInfo } from "./dep.js"; export default async function link(hakEnv: HakEnv, moduleInfo: DependencyInfo): Promise { - const yarnrc = path.join(hakEnv.projectRoot, ".yarnrc"); - // this is fairly terrible but it's reasonably clunky to either parse a yarnrc - // properly or get yarn to do it, so this will probably suffice for now. - // We just check to see if there is a local .yarnrc at all, and assume that - // if you've put one there yourself, you probably know what you're doing and - // we won't meddle with it. - // Also we do this for each module which is unnecessary, but meh. - try { - await fsProm.stat(yarnrc); - } catch { - await fsProm.writeFile( - yarnrc, - // XXX: 1. This must be absolute, as yarn will resolve link directories - // relative to the closest project root, which means when we run it - // in the dependency project, it will put the link directory in its - // own project folder rather than the main project. - // 2. The parser gets very confused by strings with colons in them - // (ie. Windows absolute paths) but strings in quotes get parsed as - // JSON so need to be valid JSON encoded strings (ie. have the - // backslashes escaped). JSON.stringify will add quotes and escape. - "--link-folder " + JSON.stringify(path.join(hakEnv.dotHakDir, "links")) + os.EOL, - ); - } - - await hakEnv.spawn("yarn", ["link"], { + const linkFolder = path.join(hakEnv.dotHakDir, "links"); + await hakEnv.spawn("yarn", ["link", "--link-folder", linkFolder], { cwd: moduleInfo.moduleOutDir, }); - await hakEnv.spawn("yarn", ["link", moduleInfo.name], { + + await hakEnv.spawn("yarn", ["link", "--link-folder", linkFolder, moduleInfo.name], { cwd: hakEnv.projectRoot, }); } diff --git a/scripts/in-docker.sh b/scripts/in-docker.sh index 231ddd88..99282075 100755 --- a/scripts/in-docker.sh +++ b/scripts/in-docker.sh @@ -1,5 +1,9 @@ #!/bin/bash +set -e + +cd $(dirname "$0")/.. + IMAGE=${DOCKER_IMAGE_NAME:-"element-desktop-dockerbuild"} docker inspect "$IMAGE" 2> /dev/null > /dev/null @@ -8,6 +12,8 @@ if [ $? != 0 ]; then exit 1 fi +mkdir -p docker/node_modules docker/.hak docker/.gnupg + # Taken from https://www.electron.build/multi-platform-build#docker # Pass through any vars prefixed with INDOCKER_, removing the prefix docker run --rm -ti \