Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions electron-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -109,6 +113,8 @@ linux:
synopsis: Desktop front-end for ipatool
maintainer: ipatool-gui contributors <noreply@example.com>
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
Expand Down
20 changes: 20 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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}'],
Expand Down
40 changes: 40 additions & 0 deletions scripts/after-pack.cjs
Original file line number Diff line number Diff line change
@@ -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)
}
5 changes: 3 additions & 2 deletions src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,9 @@ async function postStartup(): Promise<void> {
}

// 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) => {
Expand Down
1 change: 1 addition & 0 deletions src/main/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export function defaultSettings(): Settings {
return {
ipatoolPath: '',
autoInstallEngine: true,
autoCheckEngineUpdates: true,
engineVersion: '',
githubMirror: '',
downloadDir: defaultDownloadDir(),
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/src/i18n/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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…',
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/src/i18n/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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': '正在加载版本列表…',
Expand Down
7 changes: 7 additions & 0 deletions src/renderer/src/pages/SettingsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,13 @@ export function SettingsView(): ReactNode {
</div>
</Field>

<Toggle
checked={settings.autoCheckEngineUpdates}
onChange={(value) => void update({ autoCheckEngineUpdates: value })}
label={t('settings.engine.autoCheck')}
hint={t('settings.engine.autoCheckHelp')}
/>

<Field label={t('settings.engine.path')} hint={t('settings.engine.pathHelp')} stacked>
<div className="flex items-center gap-2">
<TextInput
Expand Down
1 change: 1 addition & 0 deletions src/renderer/src/store/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ export const useAppStore = create<AppState>()((set, get) => ({
// render from having to null-check every field.
ipatoolPath: '',
autoInstallEngine: true,
autoCheckEngineUpdates: true,
engineVersion: '',
githubMirror: '',
downloadDir: '',
Expand Down
2 changes: 2 additions & 0 deletions src/shared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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). */
Expand Down
2 changes: 1 addition & 1 deletion tests/dom/app-boot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions tests/main-settings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
})
})
Expand Down
Loading