From a8d614ed18062e59e3ed3f8819960a453bc090ed Mon Sep 17 00:00:00 2001 From: Tw93 Date: Fri, 17 Oct 2025 18:01:43 +0800 Subject: [PATCH] Continue to optimize appimage packaging --- bin/builders/BaseBuilder.ts | 23 ++++++++++++++++++++--- bin/builders/LinuxBuilder.ts | 7 +++++++ bin/helpers/rust.ts | 1 - bin/utils/shell.ts | 23 +++++++++++++++++------ 4 files changed, 44 insertions(+), 10 deletions(-) diff --git a/bin/builders/BaseBuilder.ts b/bin/builders/BaseBuilder.ts index e204c57..0d71fc0 100644 --- a/bin/builders/BaseBuilder.ts +++ b/bin/builders/BaseBuilder.ts @@ -123,14 +123,12 @@ export default abstract class BaseBuilder { `cd "${npmDirectory}" && ${packageManager} install${registryOption}${peerDepsOption}`, timeout, buildEnv, - this.options.debug, ); } else { await shellExec( `cd "${npmDirectory}" && ${packageManager} install${peerDepsOption}`, timeout, buildEnv, - this.options.debug, ); } spinner.succeed(chalk.green('Package installed!')); @@ -169,11 +167,24 @@ export default abstract class BaseBuilder { ...(process.env.NO_STRIP && { NO_STRIP: process.env.NO_STRIP }), }; + // Warn users about potential AppImage build failures on modern Linux systems. + // The linuxdeploy tool bundled in Tauri uses an older strip tool that doesn't + // recognize the .relr.dyn section introduced in glibc 2.38+. + if (process.platform === 'linux' && this.options.targets === 'appimage') { + if (!buildEnv.NO_STRIP) { + logger.warn( + '⚠ Building AppImage on Linux may fail due to strip incompatibility with glibc 2.38+', + ); + logger.warn( + '⚠ If build fails, retry with: NO_STRIP=1 pake --targets appimage', + ); + } + } + await shellExec( `cd "${npmDirectory}" && ${this.getBuildCommand(packageManager)}`, this.getBuildTimeout(), buildEnv, - this.options.debug, ); // Copy app @@ -280,6 +291,12 @@ export default abstract class BaseBuilder { fullCommand += ` --target ${target}`; } + // Enable verbose output in debug mode to help diagnose build issues. + // This provides detailed logs from Tauri CLI and bundler tools. + if (this.options.debug) { + fullCommand += ' --verbose'; + } + return fullCommand; } diff --git a/bin/builders/LinuxBuilder.ts b/bin/builders/LinuxBuilder.ts index bc0189b..2b12cbe 100644 --- a/bin/builders/LinuxBuilder.ts +++ b/bin/builders/LinuxBuilder.ts @@ -78,6 +78,13 @@ export default class LinuxBuilder extends BaseBuilder { fullCommand += ` --features ${features.join(',')}`; } + // Enable verbose output for AppImage builds when debugging or PAKE_VERBOSE is set. + // AppImage builds often fail with minimal error messages from linuxdeploy, + // so verbose mode helps diagnose issues like strip failures and missing dependencies. + if (this.options.targets === 'appimage' && (this.options.debug || process.env.PAKE_VERBOSE)) { + fullCommand += ' --verbose'; + } + return fullCommand; } diff --git a/bin/helpers/rust.ts b/bin/helpers/rust.ts index 4dfb6ee..dde4d20 100644 --- a/bin/helpers/rust.ts +++ b/bin/helpers/rust.ts @@ -83,7 +83,6 @@ export async function installRust() { IS_WIN ? rustInstallScriptForWindows : rustInstallScriptForMac, 300000, undefined, - true, ); spinner.succeed(chalk.green('✔ Rust installed successfully!')); ensureRustEnv(); diff --git a/bin/utils/shell.ts b/bin/utils/shell.ts index f8d6fcc..7c14980 100644 --- a/bin/utils/shell.ts +++ b/bin/utils/shell.ts @@ -5,12 +5,13 @@ export async function shellExec( command: string, timeout: number = 300000, env?: Record, - showOutput: boolean = false, ) { try { const { exitCode } = await execa(command, { cwd: npmDirectory, - stdio: showOutput ? 'inherit' : ['inherit', 'pipe', 'inherit'], + // Use 'inherit' to show all output directly to user in real-time. + // This ensures linuxdeploy and other tool outputs are visible during builds. + stdio: 'inherit', shell: true, timeout, env: env ? { ...process.env, ...env } : process.env, @@ -28,6 +29,8 @@ export async function shellExec( let errorMsg = `Error occurred while executing command "${command}". Exit code: ${exitCode}. Details: ${errorMessage}`; + // Provide helpful guidance for common Linux AppImage build failures + // caused by strip tool incompatibility with modern glibc (2.38+) if ( process.platform === 'linux' && (errorMessage.includes('linuxdeploy') || @@ -35,10 +38,18 @@ export async function shellExec( errorMessage.includes('strip')) ) { errorMsg += - '\n\nLinux AppImage build error. Try one of these solutions:\n' + - ' 1. Run with: NO_STRIP=true pake --targets appimage\n' + - ' 2. Use DEB format instead: pake --targets deb\n' + - ' 3. See detailed solutions: https://github.com/tw93/Pake/blob/main/docs/faq.md'; + '\n\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n' + + 'Linux AppImage Build Failed\n' + + '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n' + + 'Cause: Strip tool incompatibility with glibc 2.38+\n' + + ' (affects Debian Trixie, Arch Linux, and other modern distros)\n\n' + + 'Quick fix:\n' + + ' NO_STRIP=1 pake --targets appimage --debug\n\n' + + 'Alternatives:\n' + + ' • Use DEB format: pake --targets deb\n' + + ' • Update binutils: sudo apt install binutils (or pacman -S binutils)\n' + + ' • Detailed guide: https://github.com/tw93/Pake/blob/main/docs/faq.md\n' + + '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'; } throw new Error(errorMsg);