From e04621953a02d6d3f70b44830e2ed876fa50de14 Mon Sep 17 00:00:00 2001 From: a23bc <51992419+a23bc@users.noreply.github.com> Date: Wed, 11 Nov 2026 20:10:12 +0800 Subject: [PATCH 1/2] fix(linux): make the AppImage mountable and usable on Ubuntu 24.04 Build Linux artifacts with mksquashfs' zlib default so AppImageHub's mount helper can read them, and add a launcher that only falls back to --no-sandbox inside an AppImage when unprivileged user namespaces are restricted. The .deb keeps its root-owned sandbox helper. --- electron-builder.yml | 6 ++++++ eslint.config.mjs | 20 ++++++++++++++++++++ scripts/after-pack.cjs | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 scripts/after-pack.cjs diff --git a/electron-builder.yml b/electron-builder.yml index 59420e2..06e1d05 100644 --- a/electron-builder.yml +++ b/electron-builder.yml @@ -36,6 +36,10 @@ asar: true asarUnpack: [] compression: maximum +# The AppImage launcher gets a sandbox fallback for kernels that restrict +# unprivileged user namespaces (Ubuntu 24.04+). See scripts/after-pack.cjs. +afterPack: scripts/after-pack.cjs + # No native modules in this project, so never attempt a rebuild. npmRebuild: false nodeGypRebuild: false @@ -109,6 +113,8 @@ linux: synopsis: Desktop front-end for ipatool maintainer: ipatool-gui contributors artifactName: ${name}-${version}-linux-${arch}.${ext} + # mksquashfs then defaults to zlib, which the catalog's mount helper supports. + compression: normal # ⚠️ Deliberately NO `arch:` here. Once a target declares its own arch list, # electron-builder stops consulting the CLI: computeArchToTargetNamesMap() # only uses --x64/--arm64 for target names it has to invent, and otherwise diff --git a/eslint.config.mjs b/eslint.config.mjs index efc522a..e10b835 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -60,6 +60,26 @@ export default tseslint.config( } }, + // --- CommonJS build hooks (electron-builder afterPack) --------------------- + { + files: ['scripts/**/*.cjs'], + languageOptions: { + ecmaVersion: 2023, + sourceType: 'commonjs', + globals: { + ...scriptGlobals, + require: 'readonly', + module: 'readonly', + __dirname: 'readonly' + } + }, + rules: { + '@typescript-eslint/no-require-imports': 'off', + 'no-console': 'off', + 'no-empty': ['error', { allowEmptyCatch: true }] + } + }, + // --- TypeScript (all layers) ---------------------------------------------- { files: ['**/*.{ts,tsx}'], diff --git a/scripts/after-pack.cjs b/scripts/after-pack.cjs new file mode 100644 index 0000000..d6a0813 --- /dev/null +++ b/scripts/after-pack.cjs @@ -0,0 +1,40 @@ +/** + * Ubuntu 24.04+ restricts unprivileged user namespaces through AppArmor. Inside + * an AppImage Chromium's SUID fallback cannot work (the payload is a user-owned + * FUSE mount), so the process aborts before the first window. Wrap the Linux + * executable and add --no-sandbox only in that situation; a .deb install keeps + * its root-owned chrome-sandbox and the normal sandbox. + * + * electron-builder runs this hook before the targets are assembled, so the + * wrapper is what AppRun and the .deb desktop entry both execute. + */ +const fs = require('node:fs/promises') +const path = require('node:path') + +module.exports = async function afterPack(context) { + if (context.electronPlatformName !== 'linux') return + if (!context.targets.some((target) => target.name === 'appImage')) return + + const executable = path.join(context.appOutDir, context.packager.executableName) + const real = `${executable}.bin` + const name = path.basename(executable) + + const wrapper = `#!/usr/bin/env bash +set -u +HERE="$(cd "$(dirname "$0")" && pwd)" + +if [ -n "\${APPIMAGE:-}" ]; then + restricted="$(cat /proc/sys/kernel/apparmor_restrict_unprivileged_userns 2>/dev/null || true)" + userns="$(cat /proc/sys/kernel/unprivileged_userns_clone 2>/dev/null || true)" + if [ "$restricted" = "1" ] || [ "$userns" = "0" ]; then + exec "$HERE/${name}.bin" --no-sandbox "$@" + fi +fi + +exec "$HERE/${name}.bin" "$@" +` + + await fs.rename(executable, real) + await fs.writeFile(executable, wrapper) + await fs.chmod(executable, 0o755) +} From 1784127a6b53650e61f5f561f1a2f6f99194d10c Mon Sep 17 00:00:00 2001 From: a23bc <51992419+a23bc@users.noreply.github.com> Date: Wed, 11 Nov 2026 20:10:17 +0800 Subject: [PATCH 2/2] feat(settings): let users turn off the launch ipatool update check The check and its toast already existed but always ran. Make it explicit in Settings and skip the GitHub request when disabled; it still never installs a newer engine without confirmation. --- src/main/index.ts | 5 +++-- src/main/settings.ts | 1 + src/renderer/src/i18n/en.ts | 2 ++ src/renderer/src/i18n/zh.ts | 2 ++ src/renderer/src/pages/SettingsView.tsx | 7 +++++++ src/renderer/src/store/app.ts | 1 + src/shared/types.ts | 2 ++ tests/dom/app-boot.test.ts | 2 +- tests/main-settings.test.ts | 2 ++ 9 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/main/index.ts b/src/main/index.ts index fbcc422..11d85b5 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -183,8 +183,9 @@ async function postStartup(): Promise { } // Tell the UI when a newer ipatool is out - the version picker can already - // see it, but nothing used to say "you are behind". - if (engineManager.state.state === 'ready') { + // see it, but nothing used to say "you are behind". Users who prefer no + // GitHub request on launch can turn this off in Settings. + if (settings.autoCheckEngineUpdates && engineManager.state.state === 'ready') { void engineManager .checkUpdate() .then((result) => { diff --git a/src/main/settings.ts b/src/main/settings.ts index fcd23e4..f906053 100644 --- a/src/main/settings.ts +++ b/src/main/settings.ts @@ -34,6 +34,7 @@ export function defaultSettings(): Settings { return { ipatoolPath: '', autoInstallEngine: true, + autoCheckEngineUpdates: true, engineVersion: '', githubMirror: '', downloadDir: defaultDownloadDir(), diff --git a/src/renderer/src/i18n/en.ts b/src/renderer/src/i18n/en.ts index f5a8e42..1d448b2 100644 --- a/src/renderer/src/i18n/en.ts +++ b/src/renderer/src/i18n/en.ts @@ -356,6 +356,8 @@ export const en = { 'settings.engine.redetect': 'Re-detect', 'settings.engine.autoInstall': 'Download automatically when missing', 'settings.engine.autoInstallHelp': 'Fetches from majd/ipatool releases and verifies the SHA-256 sidecar.', + 'settings.engine.autoCheck': 'Check for ipatool updates on launch', + 'settings.engine.autoCheckHelp': 'Looks for a newer ipatool release and shows a notification; it never installs without your confirmation.', 'settings.engine.version': 'Version to install', 'settings.engine.versionLatest': 'Latest release', 'settings.engine.releasesLoading': 'Loading releases…', diff --git a/src/renderer/src/i18n/zh.ts b/src/renderer/src/i18n/zh.ts index 21dbc6d..670431d 100644 --- a/src/renderer/src/i18n/zh.ts +++ b/src/renderer/src/i18n/zh.ts @@ -346,6 +346,8 @@ export const zh: Dict = { 'settings.engine.redetect': '重新检测', 'settings.engine.autoInstall': '缺失时自动下载', 'settings.engine.autoInstallHelp': '从 majd/ipatool 的 Releases 获取,并校验 SHA-256。', + 'settings.engine.autoCheck': '启动时检查 ipatool 更新', + 'settings.engine.autoCheckHelp': '启动后查询 ipatool 是否有新版本并提示;不会自动安装,确认后才会更新。', 'settings.engine.version': '要安装的版本', 'settings.engine.versionLatest': '最新版本', 'settings.engine.releasesLoading': '正在加载版本列表…', diff --git a/src/renderer/src/pages/SettingsView.tsx b/src/renderer/src/pages/SettingsView.tsx index 2056e7d..7933ea6 100644 --- a/src/renderer/src/pages/SettingsView.tsx +++ b/src/renderer/src/pages/SettingsView.tsx @@ -205,6 +205,13 @@ export function SettingsView(): ReactNode { + void update({ autoCheckEngineUpdates: value })} + label={t('settings.engine.autoCheck')} + hint={t('settings.engine.autoCheckHelp')} + /> +
()((set, get) => ({ // render from having to null-check every field. ipatoolPath: '', autoInstallEngine: true, + autoCheckEngineUpdates: true, engineVersion: '', githubMirror: '', downloadDir: '', diff --git a/src/shared/types.ts b/src/shared/types.ts index b85e846..a16d4d5 100644 --- a/src/shared/types.ts +++ b/src/shared/types.ts @@ -326,6 +326,8 @@ export interface Settings { ipatoolPath: string /** Automatically download ipatool from GitHub releases when missing. */ autoInstallEngine: boolean + /** Check GitHub for a newer ipatool release on launch (notification only). */ + autoCheckEngineUpdates: boolean /** Pin a specific ipatool version ("" = latest). */ engineVersion: string /** Prefix prepended to github.com URLs (for mirrors / proxies). */ diff --git a/tests/dom/app-boot.test.ts b/tests/dom/app-boot.test.ts index e6dac3b..0f30607 100644 --- a/tests/dom/app-boot.test.ts +++ b/tests/dom/app-boot.test.ts @@ -42,7 +42,7 @@ const APP_INFO: AppInfoPayload = { } const SETTINGS = { - ipatoolPath: '', autoInstallEngine: true, engineVersion: '', githubMirror: '', + ipatoolPath: '', autoInstallEngine: true, autoCheckEngineUpdates: true, engineVersion: '', githubMirror: '', downloadDir: '/tmp/dl', concurrency: 2, autoPurchase: true, defaultPlatform: '', searchLimit: 25, purchasesPageSize: 50, passphraseMode: 'auto', keychainPassphrase: '', isolateSessionHome: true, accounts: [], activeAccountId: '', accountCounter: 1, diff --git a/tests/main-settings.test.ts b/tests/main-settings.test.ts index b356aa5..162d7fc 100644 --- a/tests/main-settings.test.ts +++ b/tests/main-settings.test.ts @@ -61,6 +61,8 @@ describe('defaultSettings', () => { expect(settings.isolateSessionHome).toBe(true) // Obtaining a licence is a visible account action; opt in, do not default to it. expect(settings.autoPurchase).toBe(false) + // The launch check only notifies; it is on until the user opts out. + expect(settings.autoCheckEngineUpdates).toBe(true) expect(defaultSettings().downloadDir).toContain('ipatool') }) })