Continue to optimize appimage packaging

This commit is contained in:
Tw93
2025-10-17 18:01:43 +08:00
parent d12efb5fdf
commit a8d614ed18
4 changed files with 44 additions and 10 deletions

View File

@@ -123,14 +123,12 @@ export default abstract class BaseBuilder {
`cd "${npmDirectory}" && ${packageManager} install${registryOption}${peerDepsOption}`, `cd "${npmDirectory}" && ${packageManager} install${registryOption}${peerDepsOption}`,
timeout, timeout,
buildEnv, buildEnv,
this.options.debug,
); );
} else { } else {
await shellExec( await shellExec(
`cd "${npmDirectory}" && ${packageManager} install${peerDepsOption}`, `cd "${npmDirectory}" && ${packageManager} install${peerDepsOption}`,
timeout, timeout,
buildEnv, buildEnv,
this.options.debug,
); );
} }
spinner.succeed(chalk.green('Package installed!')); 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 }), ...(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 <url> --targets appimage',
);
}
}
await shellExec( await shellExec(
`cd "${npmDirectory}" && ${this.getBuildCommand(packageManager)}`, `cd "${npmDirectory}" && ${this.getBuildCommand(packageManager)}`,
this.getBuildTimeout(), this.getBuildTimeout(),
buildEnv, buildEnv,
this.options.debug,
); );
// Copy app // Copy app
@@ -280,6 +291,12 @@ export default abstract class BaseBuilder {
fullCommand += ` --target ${target}`; 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; return fullCommand;
} }

View File

@@ -78,6 +78,13 @@ export default class LinuxBuilder extends BaseBuilder {
fullCommand += ` --features ${features.join(',')}`; 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; return fullCommand;
} }

1
bin/helpers/rust.ts vendored
View File

@@ -83,7 +83,6 @@ export async function installRust() {
IS_WIN ? rustInstallScriptForWindows : rustInstallScriptForMac, IS_WIN ? rustInstallScriptForWindows : rustInstallScriptForMac,
300000, 300000,
undefined, undefined,
true,
); );
spinner.succeed(chalk.green('✔ Rust installed successfully!')); spinner.succeed(chalk.green('✔ Rust installed successfully!'));
ensureRustEnv(); ensureRustEnv();

23
bin/utils/shell.ts vendored
View File

@@ -5,12 +5,13 @@ export async function shellExec(
command: string, command: string,
timeout: number = 300000, timeout: number = 300000,
env?: Record<string, string>, env?: Record<string, string>,
showOutput: boolean = false,
) { ) {
try { try {
const { exitCode } = await execa(command, { const { exitCode } = await execa(command, {
cwd: npmDirectory, 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, shell: true,
timeout, timeout,
env: env ? { ...process.env, ...env } : process.env, 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}`; 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 ( if (
process.platform === 'linux' && process.platform === 'linux' &&
(errorMessage.includes('linuxdeploy') || (errorMessage.includes('linuxdeploy') ||
@@ -35,10 +38,18 @@ export async function shellExec(
errorMessage.includes('strip')) errorMessage.includes('strip'))
) { ) {
errorMsg += errorMsg +=
'\n\nLinux AppImage build error. Try one of these solutions:\n' + '\n\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n' +
' 1. Run with: NO_STRIP=true pake <url> --targets appimage\n' + 'Linux AppImage Build Failed\n' +
' 2. Use DEB format instead: pake <url> --targets deb\n' + '━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\n' +
' 3. See detailed solutions: https://github.com/tw93/Pake/blob/main/docs/faq.md'; '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 <url> --targets appimage --debug\n\n' +
'Alternatives:\n' +
' • Use DEB format: pake <url> --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); throw new Error(errorMsg);