Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Use a node script to avoid dealing with Windows nonsense

Manav Rathic73183386322
diff --git a/desktop/.gitignore b/desktop/.gitignore
index f81ee56caf..cf2a1d92f6 100644
--- a/desktop/.gitignore
+++ b/desktop/.gitignore
@@ -20,3 +20,6 @@ out
# electron-builder
dist/
+
+# We download it on demand, if needed for the particular OS/arch.
+build/magick
diff --git a/desktop/eslint.config.mjs b/desktop/eslint.config.mjs
index 889b60c3e5..4175c52a95 100644
--- a/desktop/eslint.config.mjs
+++ b/desktop/eslint.config.mjs
@@ -19,7 +19,13 @@ export default ts.config(
{
// The list of (minimatch) globs to ignore. This needs to be the only
// key in this configuration object.
- ignores: ["eslint.config.mjs", "app/", "out/", "dist/"],
+ ignores: [
+ "eslint.config.mjs",
+ "scripts/magick.js",
+ "app/",
+ "out/",
+ "dist/",
+ ],
},
{
// Rule customizations.
diff --git a/desktop/package.json b/desktop/package.json
index 8714ce4f84..5ad8fdd7d9 100644
--- a/desktop/package.json
+++ b/desktop/package.json
@@ -18,7 +18,8 @@
"dev-renderer": "cross-env-shell _ENTE_IS_DESKTOP=1 \"cd ../web && yarn install && yarn workspace photos next dev -p 3008\"",
"postinstall": "electron-builder install-app-deps",
"lint": "yarn prettier --check --log-level warn . && yarn eslint && yarn tsc",
- "lint-fix": "yarn prettier --write --log-level warn . && yarn eslint && yarn tsc"
+ "lint-fix": "yarn prettier --write --log-level warn . && yarn eslint && yarn tsc",
+ "prepare": "node scripts/magick.js"
},
"resolutions": {
"jackspeak": "2.1.1"
diff --git a/desktop/scripts/magick.js b/desktop/scripts/magick.js
new file mode 100755
index 0000000000..fdcc03a9ae
--- /dev/null
+++ b/desktop/scripts/magick.js
@@ -0,0 +1,62 @@
+/**
+ * ## ImageMagick
+ *
+ * We need static builds for Linux and Windows for both x64 and ARM. For this,
+ * we need a custom workflow because (as of writing):
+ *
+ * 1. Upstream doesn't publish ARM64 binaries for Linux
+ *
+ * 2. The Windows portable releases are not part of the artifacts attached to
+ * the upstream GitHub release.
+ *
+ * Our custom workflow is an adaption of the upstream release.yml - its goal is
+ * to have 4 standalone binaries - Linux x64, Linux ARM, Win x64, Win ARM -
+ * attached to a GitHub release from which we can pull them when building the
+ * desktop app.
+ *
+ * This is our custom workflow, which runs on a fork of upstream:
+ * https://github.com/ente-io/ImageMagick/commit/df895cce13d6a3f874a716c05ff2babeb33351b9
+ * (For reference, we also include a copy of it in this repo - `magick.yml`).
+ *
+ * The binaries it creates are available at
+ * https://github.com/ente-io/ImageMagick/releases/tag/2025-01-21.
+ *
+ * This script downloads the relevant binary for the current OS/arch combination
+ * and places it in the `build` folder. This script runs whenever "yarn install"
+ * is called as it is set as the "prepare" step in our `package.json`.
+ *
+ * On macOS, we don't need ImageMagick since Apple ships `sips`.
+ */
+
+const fs = require("fs");
+const fsp = require("fs/promises");
+
+const main = () => {
+ const out = "build/magick";
+ if (fs.existsSync(out)) return;
+
+ let downloadName = (() => {
+ switch (`${process.platform}-${process.arch}`) {
+ case "linux-x64":
+ return "magick-x86_64";
+ case "linux-arm64":
+ return "magick-aarch64";
+ case "win32-x64":
+ return "magick-x64.exe";
+ case "linux-arm64":
+ return "magick-arm64.exe";
+ default:
+ return undefined;
+ }
+ })();
+
+ if (!downloadName) return;
+
+ console.log(`Downloading ${downloadName}`);
+ const downloadPath = `https://github.com/ente-io/ImageMagick/releases/download/2025-01-21/${downloadName}`;
+ void fetch(downloadPath)
+ .then((res) => res.blob())
+ .then((blob) => fsp.writeFile(out, blob.stream()));
+};
+
+main();
diff --git a/desktop/scripts/magick.sh b/desktop/scripts/magick.sh
deleted file mode 100755
index 848fd5940e..0000000000
--- a/desktop/scripts/magick.sh
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/bin/sh
-
-## ImageMagick
-#
-# We need static builds for Linux and Windows for both x64 and ARM. For this, we
-# need a custom workflow because (as of writing):
-#
-# 1. Upstream doesn't publish ARM64 binaries for Linux
-#
-# 2. The Windows portable releases are not part of the artifacts attached to the
-# upstream GitHub release.
-#
-# Our custom workflow is an adaption of the upstream release.yml - its goal is
-# to have 4 standalone binaries - Linux x64, Linux ARM, Win x64, Win ARM -
-# attached to a GitHub release from which we can pull them when building the
-# desktop app.
-#
-# This is our custom workflow, which runs on a fork of upstream:
-# https://github.com/ente-io/ImageMagick/commit/df895cce13d6a3f874a716c05ff2babeb33351b9
-# (For reference, we also include a copy of it in this repo - `magick.yml`).
-#
-# The binaries it creates are available at
-# https://github.com/ente-io/ImageMagick/releases/tag/2025-01-21.
-#
-# This script downloads the relevant binary for the current OS/arch combination
-# and places it in the `build` folder. This script runs whenever "yarn install"
-# is called as it is set as the "prepare" step in our `package.json`.
-#
-# On macOS, we don't need ImageMagick since Apple ships `sips`.