Skip to content

armgit / ente

Public Imported from GitHub
0

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

Outline

Manav Rathicf27dd5889bc
diff --git a/desktop/docs/dependencies.md b/desktop/docs/dependencies.md
index 22606d50ae..46fd1dacaa 100644
--- a/desktop/docs/dependencies.md
+++ b/desktop/docs/dependencies.md
@@ -111,8 +111,9 @@ The main tool we use is for arbitrary conversions is ffmpeg. To bundle a
> ffmpeg binary and using the wasm one (that our renderer process already has).
> Which is why we bundle it to speed up operations on the desktop app.
-In addition, we also bundle a static Linux binary of imagemagick in our extra
-resources (`build`) folder. This is used for thumbnail generation on Linux.
+On Linux and Windows, we use ImageMagick for thumbnail generation. A static
+OS/architecture specific binary of this is bundled in our extra resources
+(`build`) folder by `scripts/magick.sh`.
On macOS, we use the `sips` CLI tool for conversion, but that is already
available on the host machine, and is not bundled with our app.
diff --git a/desktop/scripts/magick.sh b/desktop/scripts/magick.sh
new file mode 100755
index 0000000000..848fd5940e
--- /dev/null
+++ b/desktop/scripts/magick.sh
@@ -0,0 +1,29 @@
+#!/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`.
diff --git a/desktop/scripts/magick.yml b/desktop/scripts/magick.yml
new file mode 100644
index 0000000000..47d008763b
--- /dev/null
+++ b/desktop/scripts/magick.yml
@@ -0,0 +1,125 @@
+on:
+ workflow_dispatch:
+ push: # Push a tag to build and create a draft release
+ tags:
+ - "*"
+
+name: binaries-for-ente
+jobs:
+ create_magick_binary:
+ name: Create magick binary (Linux)
+ runs-on: ${{ matrix.os }}
+
+ strategy:
+ matrix:
+ os: [ubuntu-24.04, ubuntu-24.04-arm]
+ compiler: [gcc]
+ include:
+ - os: ubuntu-24.04
+ arch: x86_64
+ - os: ubuntu-24.04-arm
+ arch: aarch64
+ - compiler: gcc
+ cxx_compiler: g++
+ packages: gcc g++
+
+ steps:
+ - name: Install dependencies
+ run: |
+ set -e
+ export DEBIAN_FRONTEND=noninteractive
+ sudo apt update -y
+ sudo apt install -y autoconf curl fuse git kmod libbz2-dev libdjvulibre-dev libfontconfig-dev libfreetype6-dev libfribidi-dev libharfbuzz-dev liblcms-dev libopenexr-dev libopenjp2-7-dev libturbojpeg0-dev liblqr-dev libraqm-dev libtiff-dev libwebp-dev libx11-dev libxml2-dev liblzma-dev make software-properties-common wget ${{ matrix.packages }}
+ sudo add-apt-repository ppa:git-core/ppa -y
+ sudo apt install -y git
+ sudo add-apt-repository ppa:strukturag/libheif -y
+ sudo add-apt-repository ppa:strukturag/libde265 -y
+ sudo apt install libheif-dev -y
+
+ - name: Checkout
+ uses: actions/checkout@v4
+
+ # Avoid fatal: detected dubious ownership in repository at '/__w/ImageMagick/ImageMagick'
+ # Possible workaround: https://github.com/actions/runner/issues/2033#issuecomment-1598547465
+ - name: Flag current workspace as safe for git
+ run: git config --global --add safe.directory ${GITHUB_WORKSPACE}
+
+ - name: Download AppImage
+ run: |
+ set -e
+ sudo apt install -y file
+ mkdir -p out/app-image
+ cd out/app-image
+ wget -c https://github.com/$(wget -q https://github.com/probonopd/go-appimage/releases/expanded_assets/continuous -O - | grep "appimagetool-.*-${{ matrix.arch }}.AppImage" | head -n 1 | cut -d '"' -f 2)
+ chmod +x appimagetool-*.AppImage
+
+ - name: Build ImageMagick
+ env:
+ CFLAGS: -Wno-deprecated-declarations -Wdeclaration-after-statement -Wno-error=unused-variable
+ CC: ${{ matrix.compiler }}
+ CXX: ${{ matrix.cxx_compiler }}
+ run: |
+ set -e
+ ./configure --with-quantum-depth=16 --without-magick-plus-plus --without-perl --without-x --disable-docs --prefix=/usr
+ make
+ make install DESTDIR=$(readlink -f out/appdir)
+
+ - name: Create ImageMagick AppImage
+ run: |
+ set -e
+ mkdir -p out/appdir/usr/share/applications/
+ cp app-image/imagemagick.desktop out/appdir/usr/share/applications/
+ mkdir -p out/appdir/usr/share/icons/hicolor/256x256/apps/
+ cp app-image/icon.png out/appdir/usr/share/icons/hicolor/256x256/apps/imagemagick.png
+ unset QTDIR
+ unset QT_PLUGIN_PATH
+ unset LD_LIBRARY_PATH
+ export VERSION=7
+ cd out
+ ./app-image/appimagetool-*.AppImage --appimage-extract-and-run -s deploy appdir/usr/share/applications/*.desktop
+ chmod +x appdir/usr/lib/ld-linux-aarch64.so.1 || true
+ ./app-image/appimagetool-*.AppImage --appimage-extract-and-run appdir
+ mkdir artifacts
+ cp ImageMagick*.AppImage artifacts/magick-${{ matrix.arch }}
+
+ - name: Upload ImageMagick AppImage
+ uses: actions/upload-artifact@v4
+ with:
+ name: magick-${{ matrix.arch }}
+ path: out/artifacts
+
+ - name: Create a draft GitHub release
+ uses: ncipollo/release-action@v1
+ with:
+ artifacts: "out/artifacts/*"
+ draft: true
+ allowUpdates: true
+ updateOnlyUnreleased: true
+
+ download_and_keep_windows_binaries:
+ name: Download magick binary (Windows)
+ runs-on: ubuntu-24.04
+ steps:
+ - name: Download
+ run: |
+ mkdir -p out/artifacts
+ curl -LO https://imagemagick.org/archive/binaries/ImageMagick-7.1.1-43-portable-Q16-x64.zip
+ unzip ImageMagick-7.1.1-43-portable-Q16-x64.zip
+ cp ImageMagick-7.1.1-43-portable-Q16-x64/magick.exe out/artifacts/magick-x64.exe
+ curl -LO https://imagemagick.org/archive/binaries/ImageMagick-7.1.1-43-portable-Q16-arm64.zip
+ unzip ImageMagick-7.1.1-43-portable-Q16-arm64.zip
+ cp ImageMagick-7.1.1-43-portable-Q16-arm64/magick.exe out/artifacts/magick-arm64.exe
+
+ - name: Upload ImageMagick exes
+ uses: actions/upload-artifact@v4
+ with:
+ name: magick-${{ matrix.arch }}
+ path: out/artifacts
+
+ - name: Create a draft GitHub release
+ uses: ncipollo/release-action@v1
+ with:
+ artifacts: "out/artifacts/*"
+ draft: true
+ allowUpdates: true
+ updateOnlyUnreleased: true