Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

refactor: pin linuxdeploy in make/yarn build process instead of github workflow

D. Rect.a668204cdcc0
diff --git a/.devcontainer/buildAppImage.sh b/.devcontainer/buildAppImage.sh
deleted file mode 100644
index efb963d5a..000000000
--- a/.devcontainer/buildAppImage.sh
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/usr/bin/env bash
-
-make clean
-
-# To reproduce https://github.com/menloresearch/jan/pull/5463
-TAURI_TOOLKIT_PATH="${XDG_CACHE_HOME:-$HOME/.cache}/tauri"
-mkdir -p "$TAURI_TOOLKIT_PATH"
-wget https://github.com/linuxdeploy/linuxdeploy/releases/download/1-alpha-20250213-2/linuxdeploy-x86_64.AppImage -O "$TAURI_TOOLKIT_PATH/linuxdeploy-x86_64.AppImage"
-chmod +x "$TAURI_TOOLKIT_PATH/linuxdeploy-x86_64.AppImage"
-
-jq '.bundle.resources = ["resources/pre-install/**/*"] | .bundle.externalBin = ["binaries/cortex-server", "resources/bin/uv"]' ./src-tauri/tauri.conf.json > /tmp/tauri.conf.json
-mv /tmp/tauri.conf.json ./src-tauri/tauri.conf.json
-
-make build-tauri
-
-cp ./src-tauri/resources/bin/bun ./src-tauri/target/release/bundle/appimage/Jan.AppDir/usr/bin/bun
-mkdir -p ./src-tauri/target/release/bundle/appimage/Jan.AppDir/usr/lib/Jan/binaries/engines
-cp -f ./src-tauri/binaries/deps/*.so* ./src-tauri/target/release/bundle/appimage/Jan.AppDir/usr/lib/Jan/binaries/
-cp -f ./src-tauri/binaries/*.so* ./src-tauri/target/release/bundle/appimage/Jan.AppDir/usr/lib/Jan/binaries/
-cp -rf ./src-tauri/binaries/engines ./src-tauri/target/release/bundle/appimage/Jan.AppDir/usr/lib/Jan/binaries/
-APP_IMAGE=./src-tauri/target/release/bundle/appimage/$(ls ./src-tauri/target/release/bundle/appimage/ | grep AppImage | head -1)
-echo $APP_IMAGE
-rm -f $APP_IMAGE
-/opt/bin/appimagetool ./src-tauri/target/release/bundle/appimage/Jan.AppDir $APP_IMAGE
\ No newline at end of file
diff --git a/.devcontainer/postCreateCommand.sh b/.devcontainer/postCreateCommand.sh
index 79fb4de1c..a9a1277b8 100755
--- a/.devcontainer/postCreateCommand.sh
+++ b/.devcontainer/postCreateCommand.sh
@@ -14,7 +14,3 @@ sudo apt install -yqq libwebkit2gtk-4.1-dev \
librsvg2-dev \
xdg-utils \
libfuse2
-
-sudo mkdir -p /opt/bin
-sudo wget https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage -O /opt/bin/appimagetool
-sudo chmod +x /opt/bin/appimagetool
\ No newline at end of file
diff --git a/.github/workflows/template-tauri-build-linux-x64.yml b/.github/workflows/template-tauri-build-linux-x64.yml
index 7ef9c88b1..b07faa0bc 100644
--- a/.github/workflows/template-tauri-build-linux-x64.yml
+++ b/.github/workflows/template-tauri-build-linux-x64.yml
@@ -145,12 +145,6 @@ jobs:
fi
- name: Build app
run: |
- # Pin linuxdeploy version to prevent @tauri-apps/cli-linux-x64-gnu from pulling in an outdated version
- TAURI_TOOLKIT_PATH="${XDG_CACHE_HOME:-$HOME/.cache}/tauri"
- mkdir -p "$TAURI_TOOLKIT_PATH"
- wget https://github.com/linuxdeploy/linuxdeploy/releases/download/1-alpha-20250213-2/linuxdeploy-x86_64.AppImage -O "$TAURI_TOOLKIT_PATH/linuxdeploy-x86_64.AppImage"
- chmod +x "$TAURI_TOOLKIT_PATH/linuxdeploy-x86_64.AppImage"
-
make build-tauri
APP_IMAGE=./src-tauri/target/release/bundle/appimage/$(ls ./src-tauri/target/release/bundle/appimage/ | grep AppImage | head -1)
diff --git a/Makefile b/Makefile
index 96a526342..5bd42c755 100644
--- a/Makefile
+++ b/Makefile
@@ -84,6 +84,7 @@ else ifeq ($(shell uname -s),Linux)
rm -rf ./src-tauri/target
rm -rf "~/jan/extensions"
rm -rf "~/.cache/jan*"
+ rm -rf "./.cache"
else
find . -name "node_modules" -type d -prune -exec rm -rf '{}' +
find . -name ".next" -type d -exec rm -rf '{}' +
diff --git a/mise.toml b/mise.toml
index 9f6cee5c7..86a90f742 100644
--- a/mise.toml
+++ b/mise.toml
@@ -164,6 +164,7 @@ elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
rm -rf ./src-tauri/target 2>/dev/null || true
rm -rf ~/jan/extensions 2>/dev/null || true
rm -rf "~/.cache/jan*" 2>/dev/null || true
+ rm -rf "./.cache" 2>/dev/null || true
else
# macOS cleanup (matches Makefile)
find . -name "node_modules" -type d -prune -exec rm -rf '{}' + 2>/dev/null || true
diff --git a/package.json b/package.json
index c0b29b6a3..ce2e96117 100644
--- a/package.json
+++ b/package.json
@@ -34,7 +34,7 @@
"copy:lib:darwin": "mkdir -p \"./src-tauri/resources/lib/\"",
"download:bin": "node ./scripts/download-bin.mjs",
"build:tauri:win32": "yarn download:bin && yarn tauri build",
- "build:tauri:linux": "yarn download:bin && yarn tauri build && ./src-tauri/build-utils/buildAppImage.sh",
+ "build:tauri:linux": "yarn download:bin && ./src-tauri/build-utils/shim-linuxdeploy.sh yarn tauri build && ./src-tauri/build-utils/buildAppImage.sh",
"build:tauri:darwin": "yarn tauri build --target universal-apple-darwin",
"build:tauri": "yarn install:cortex && yarn build:icon && yarn copy:assets:tauri && run-script-os",
"build:icon": "tauri icon ./src-tauri/icons/icon.png",
diff --git a/src-tauri/build-utils/shim-linuxdeploy.sh b/src-tauri/build-utils/shim-linuxdeploy.sh
new file mode 100755
index 000000000..359ccd5ba
--- /dev/null
+++ b/src-tauri/build-utils/shim-linuxdeploy.sh
@@ -0,0 +1,30 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+# wrapper script to pin linuxdeploy version and inject environment variables into the
+# build process. While yarn supports injecting environment vairables via env files,
+# this applies to all yarn scripts. Using a wrapper allows granular control over
+# when environment variables are injected, and avoids tainting the system .cache
+
+# avoid redownloading corepack if possible
+export COREPACK_HOME=${COREPACK_HOME:-${XDG_CACHE_HOME:-$HOME/.cache}/node/corepack}
+# move cache home to <project root>/.cache
+export XDG_CACHE_HOME=${PWD}/.cache
+
+LINUXDEPLOY_VER="1-alpha-20250213-2"
+LINUXDEPLOY="$XDG_CACHE_HOME/tauri/linuxdeploy-$LINUXDEPLOY_VER-x86_64.AppImage"
+SYMLINK="$XDG_CACHE_HOME/tauri/linuxdeploy-x86_64.AppImage"
+
+mkdir -p "$XDG_CACHE_HOME/tauri"
+
+if [ ! -f "$LINUXDEPLOY" ]; then
+ GLOB_PATTERN="$XDG_CACHE_HOME/tauri/linuxdeploy-*-x86_64.AppImage"
+ rm -f $GLOB_PATTERN
+ wget "https://github.com/linuxdeploy/linuxdeploy/releases/download/$LINUXDEPLOY_VER/linuxdeploy-x86_64.AppImage" -O "$LINUXDEPLOY"
+ chmod a+x "$LINUXDEPLOY"
+fi
+
+rm -f "$SYMLINK"
+ln -s "$LINUXDEPLOY" "$SYMLINK"
+
+"$@"
\ No newline at end of file