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) +} 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') }) })