Skip to content

Commit 3c70ef0

Browse files
committed
improve native modules compatibility with old systems
* Run "prepare-native-deps" script on "ubuntu:20.04" docker image (old system). This fixes Snap package (also should benefit some old Linux systems). Tested on Ubuntu 24.04. Originally, the Snap build from https://github.com/vladimiry/ElectronMail/releases/tag/v5.3.1 was failing on Ubuntu 24.04 with error (sodium-native.node binary): /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found. * Tweak "prepare-native-deps" compiling args on Windows.
1 parent 8db0eb7 commit 3c70ef0

File tree

7 files changed

+107
-49
lines changed

7 files changed

+107
-49
lines changed

.github/workflows/main.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ jobs:
1515
- { uses: actions/checkout@v4 }
1616
- { uses: pnpm/action-setup@v4, with: { version: 'latest' } }
1717
- { uses: actions/setup-node@v4, with: { node-version: '${{ env.ELECTRON_MAIL_NODE_VERSION }}', cache: 'pnpm' } }
18-
- { name: system setup, if: runner.os == 'Linux', run: ./scripts/ci/github/system-setup-linux.sh }
1918
- { uses: actions/setup-python@v5, with: { python-version: '3.9' } }
2019
- { name: envinfo, run: npx envinfo }
2120
- { name: install node modules, run: 'pnpm install --frozen-lockfile --reporter=append-only' }
@@ -44,7 +43,6 @@ jobs:
4443
- { uses: actions/checkout@v4 }
4544
- { uses: pnpm/action-setup@v4, with: { version: 'latest' } }
4645
- { uses: actions/setup-node@v4, with: { node-version: '${{ env.ELECTRON_MAIL_NODE_VERSION }}', cache: 'pnpm' } }
47-
- { name: system setup, if: runner.os == 'Linux', run: ./scripts/ci/github/system-setup-linux.sh }
4846
- { uses: actions/setup-python@v5, with: { python-version: '3.9' } }
4947
- { name: envinfo, run: npx envinfo }
5048
- { name: install node modules, run: 'pnpm install --frozen-lockfile --reporter=append-only' }
@@ -66,7 +64,6 @@ jobs:
6664
- { uses: actions/checkout@v4 }
6765
- { uses: pnpm/action-setup@v4, with: { version: 'latest' } }
6866
- { uses: actions/setup-node@v4, with: { node-version: '${{ env.ELECTRON_MAIL_NODE_VERSION }}', cache: 'pnpm' } }
69-
- { name: system setup, if: runner.os == 'Linux', run: ./scripts/ci/github/system-setup-linux.sh }
7067
- { uses: actions/setup-python@v5, with: { python-version: '3.9' } }
7168
- { name: envinfo, run: npx envinfo }
7269
- { name: install node modules, run: 'pnpm install --frozen-lockfile --reporter=append-only' }
@@ -77,6 +74,18 @@ jobs:
7774
- { name: assets, run: 'yarn assets', env: { ELECTRON_MAIL_SHOULD_FAIL_ON_BUILD: 'true' } }
7875
- { name: print ./app files, shell: bash, run: ./scripts/ci/list-fs-content.sh ./app }
7976
- { name: build, if: runner.os == 'Windows', run: ./scripts/ci/github/package-app.ps1 }
77+
- name: build native deps in ubuntu:20.04
78+
if: runner.os == 'Linux'
79+
run: |
80+
set -e
81+
pnpm run clean:prebuilds
82+
docker run --rm \
83+
-v ${{ github.workspace }}:/host \
84+
-w /tmp \
85+
-e ELECTRON_MAIL_NODE_VERSION=${{ env.ELECTRON_MAIL_NODE_VERSION }} \
86+
-e GITHUB_REPOSITORY=${{ github.repository }} \
87+
-e GITHUB_SHA=${{ github.sha }} \
88+
ubuntu:20.04 bash -c "/host/scripts/ci/github/prepare-native-deps-docker.sh"
8089
- { name: build, if: runner.os == 'Linux', run: ./scripts/ci/github/package-app-linux.sh }
8190
- {
8291
name: build,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"clean:app": "rimraf ./app",
5757
"clean:app-dev": "rimraf ./app-dev",
5858
"clean:output": "rimraf ./output",
59-
"clean:prebuilds": "rimraf --glob \"./node_modules/{keytar,sodium-native,msgpackr-extract}/{bin,build,prebuilds}\" \"./node_modules/@msgpackr-extract/\" \"./node_modules/sodium-native/deps/**/!(bin.js)\"",
59+
"clean:prebuilds": "rimraf --glob \"./node_modules/{keytar,sodium-native,msgpackr-extract,@msgpackr-extract}/**/*.{node,bare}\" \"./node_modules/@msgpackr-extract/\"",
6060
"assets": "npm-run-all assets:copy assets:webclient",
6161
"assets:dev": "npm-run-all assets:copy:dev assets:webclient:dev",
6262
"assets:copy": "cpx \"./src/assets/dist/**/*\" ./app/assets",

scripts/ci/github/package-app-linux.sh

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,20 @@ set -ev
44

55
echo "::group::tweak the system"
66
sudo apt-get update
7-
# <purpose: native modules compiling>
8-
sudo apt-get install --yes --no-install-recommends libtool automake gcc-10 g++-10
9-
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10 --slave /usr/bin/gcov gcov /usr/bin/gcov-10
10-
# purpose: compiling "desktop-idle" native module (issue: No package 'xscrnsaver' found)
11-
sudo apt-get install --yes --no-install-recommends libxss-dev
12-
# purpose: tweaking snap package ("unsquashfs" binary)
13-
sudo apt-get install --yes --no-install-recommends snapcraft squashfs-tools
14-
# purpose: compiling "node-keytar" native module and keychain initialization
15-
sudo apt-get install --yes --no-install-recommends libsecret-1-dev
16-
# purpose: pacman build fails also due missing "bsdtar", see https://github.com/jordansissel/fpm/issues/1453#issuecomment-356138549
17-
sudo apt-get install --yes --no-install-recommends libarchive-tools
18-
# purpose: AppImage re-packaging
19-
sudo apt-get install --yes --no-install-recommends desktop-file-utils
20-
# </purpose: native modules compiling>
21-
export CC=gcc-10
22-
export CXX=g++-10
7+
# - snapcraft: for snap tweaking
8+
# - squashfs-tools: for snap tweaking
9+
# - libarchive-tools: includes bsdtar for pacman builds
10+
# - desktop-file-utils: needed for AppImage packaging
11+
sudo apt-get install --yes --no-install-recommends \
12+
snapcraft \
13+
squashfs-tools \
14+
libarchive-tools \
15+
desktop-file-utils
2316
echo "::endgroup::"
2417

25-
# assuming that "ubuntu-22.04" image comes with glibc v2.31, see https://github.com/vladimiry/ElectronMail/issues/389#issuecomment-812071591
26-
GLIBC_INFO_EXPECTED_SUB="release version 2.35"
27-
GLIBC_INFO=$(lsof -p $$ | grep libc | awk ' { print $NF" --version"; } ' | sh)
28-
echo $GLIBC_INFO
29-
if [[ "$GLIBC_INFO" != *"$GLIBC_INFO_EXPECTED_SUB"* ]]; then
30-
echo >&2 "unexpected glibc version detected"
31-
exit 1
32-
fi
33-
34-
echo "::group::compile native modules"
35-
pnpm run prepare-native-deps
36-
echo "::endgroup::"
18+
# echo "::group::compile native modules"
19+
# pnpm run prepare-native-deps # moved to "./scripts/ci/github/prepare-native-deps-docker.sh"
20+
# echo "::endgroup::"
3721

3822
echo "::group::test e2e setup"
3923
echo "initializing xvfb stuff..."
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/usr/bin/env bash
2+
3+
set -ev
4+
5+
: "${ELECTRON_MAIL_NODE_VERSION:?Missing ELECTRON_MAIL_NODE_VERSION}"
6+
: "${GITHUB_REPOSITORY:?Missing GITHUB_REPOSITORY}"
7+
: "${GITHUB_SHA:?Missing GITHUB_SHA}"
8+
9+
export DEBIAN_FRONTEND=noninteractive
10+
11+
apt-get update
12+
13+
echo "::group::isntall nodejs & pnpm"
14+
apt-get install --yes --no-install-recommends ca-certificates curl gnupg
15+
mkdir -p /etc/apt/keyrings
16+
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key \
17+
| gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
18+
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_${ELECTRON_MAIL_NODE_VERSION}.x nodistro main" \
19+
| tee /etc/apt/sources.list.d/nodesource.list
20+
apt update
21+
apt-get install --yes nodejs
22+
node -v
23+
npm -v
24+
corepack enable
25+
corepack prepare pnpm@latest --activate
26+
pnpm -v
27+
echo "::endgroup::"
28+
29+
echo "::group::install system packages"
30+
apt-get install --yes --no-install-recommends wget lsb-release software-properties-common build-essential python3 git
31+
echo "::endgroup::"
32+
33+
echo "::group::install clang/ldd setup"
34+
wget https://apt.llvm.org/llvm.sh
35+
chmod +x llvm.sh
36+
./llvm.sh 20
37+
rm llvm.sh
38+
echo "::endgroup::"
39+
40+
# picket form "./scripts/ci/github/package-app-linux.sh" of v5.3.0 release (when it still used "ubuntu-20.04" GH CI image)
41+
echo "::group::install and configure compiling tools"
42+
apt-get install --yes --no-install-recommends libtool automake gcc-10 g++-10 libsecret-1-dev
43+
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10 --slave /usr/bin/gcov gcov /usr/bin/gcov-10
44+
echo "::endgroup::"
45+
46+
echo "::group::clone project & install node modules"
47+
git clone "https://github.com/${GITHUB_REPOSITORY}" /build
48+
cd /build
49+
git checkout "${GITHUB_SHA}"
50+
pnpm install --frozen-lockfile
51+
echo "::endgroup::"
52+
53+
echo "::group::compile native modules"
54+
pnpm run prepare-native-deps
55+
echo "::endgroup::"
56+
57+
echo "::group::copy compiled .node files back to host and print GLIBC version strings"
58+
find node_modules -name '*.node' -exec sh -c '
59+
echo "GLIBC symbols in $1:"
60+
strings "$1" | grep GLIBC_ | sort | uniq
61+
echo "Copying: $1"
62+
cp --parents "$1" /host/
63+
echo "-----------------------------"
64+
' _ {} \;
65+
echo "::endgroup::"

scripts/ci/github/system-setup-linux.sh

Lines changed: 0 additions & 7 deletions
This file was deleted.

scripts/prepare-native-deps.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ const IS_CROSS_PLATFORM_COMPILATION = DEST_ARCH !== os.arch();
1818

1919
const resolvePlatformEnvVars = ((): () => NodeJS.ProcessEnv => {
2020
const resolvers: Readonly<Partial<Record<NodeJS.Platform, () => NodeJS.ProcessEnv>>> = {
21-
// win32: () => ({GYP_MSVS_VERSION: "2022", CL: "/FS /Zc:__cplusplus /std:c++20"}),
21+
win32: () => ({
22+
GYP_DEFINES: "win_target=0x0A00 msvs_runtime_static=true",
23+
CL: "/MT /D_WIN32_WINNT=0x0A00",
24+
}),
2225
darwin: () => {
2326
// https://developer.apple.com/documentation/apple-silicon/building-a-universal-macos-binary
2427
const versionMin = DEST_ARCH === "x64" ? "10.12" : "11";
@@ -52,11 +55,17 @@ const compileRegularNativeDeps = async (): Promise<void> => {
5255

5356
for (const moduleDir of nativeModuleDirs) {
5457
const moduleName = path.basename(moduleDir);
58+
const baseEnvVars = resolvePlatformEnvVars();
5559
const extraEnvVars = {
56-
...resolvePlatformEnvVars(),
60+
...baseEnvVars,
5761
...(os.platform() === "win32" && moduleName === "msgpackr-extract"
58-
? {GYP_MSVS_VERSION: "2022", CL: "/FS /Zc:__cplusplus /std:c++20"}
62+
? {
63+
GYP_MSVS_VERSION: "2022",
64+
GYP_DEFINES: `${baseEnvVars.GYP_DEFINES ?? ""} msvs_version=2022`,
65+
CL: `${baseEnvVars.CL ?? ""} /FS /Zc:__cplusplus /std:c++20`,
66+
}
5967
: undefined),
68+
...(os.platform() === "linux" ? {CC: "gcc-10", CXX: "g++-10"} : undefined),
6069
};
6170

6271
await execShell(["npm", [
@@ -90,7 +99,10 @@ const compileRegularNativeDeps = async (): Promise<void> => {
9099
};
91100

92101
const bareMakeExec = async (cwd: string, ...args: string[]): Promise<void> => {
93-
const extraEnvVars = resolvePlatformEnvVars();
102+
const extraEnvVars = {
103+
...resolvePlatformEnvVars(),
104+
...(os.platform() === "linux" ? {CC: "clang-20", CXX: "clang++-20"} : undefined),
105+
};
94106
await execShell(
95107
["pnpm", ["exec", "bare-make", ...args, "--verbose"], {cwd, env: {...process.env, ...extraEnvVars}}],
96108
{printEnvWhitelist: [...Object.values(ENV_VAR_NAMES), ...Object.keys(extraEnvVars)]},

src/e2e/lib/init-app.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,7 @@ export const initAppWithTestContext = async (
4444
// - folder prepared by running "electron-builder --dir"
4545
const app = testContext.app = await playwright._electron.launch({
4646
args: [MAIN_SCRIPT_FILE, `--user-data-dir=${testContext.userDataDirPath}`],
47-
env: {
48-
...process.env,
49-
[RUNTIME_ENV_USER_DATA_DIR]: testContext.userDataDirPath,
50-
ELECTRON_ENABLE_LOGGING: "1",
51-
// ...(os.platform() === "darwin" ? {ELECTRON_DISABLE_GPU: "1"} : undefined),
52-
},
47+
env: {...process.env, ELECTRON_ENABLE_LOGGING: "1", [RUNTIME_ENV_USER_DATA_DIR]: testContext.userDataDirPath},
5348
});
5449

5550
testContext.firstWindowPage = await app.firstWindow();

0 commit comments

Comments
 (0)