Continue to optimize packaging issues under Linux
This commit is contained in:
55
bin/builders/BaseBuilder.ts
vendored
55
bin/builders/BaseBuilder.ts
vendored
@@ -162,11 +162,15 @@ export default abstract class BaseBuilder {
|
||||
// Show static message to keep the status visible
|
||||
logger.warn('✸ Building app...');
|
||||
|
||||
const buildEnv = {
|
||||
...this.getBuildEnvironment(),
|
||||
...(process.env.NO_STRIP && { NO_STRIP: process.env.NO_STRIP }),
|
||||
const baseEnv = this.getBuildEnvironment();
|
||||
let buildEnv: Record<string, string> = {
|
||||
...(baseEnv ?? {}),
|
||||
...(process.env.NO_STRIP ? { NO_STRIP: process.env.NO_STRIP } : {}),
|
||||
};
|
||||
|
||||
const resolveExecEnv = () =>
|
||||
Object.keys(buildEnv).length > 0 ? buildEnv : undefined;
|
||||
|
||||
// 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+.
|
||||
@@ -181,11 +185,31 @@ export default abstract class BaseBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
await shellExec(
|
||||
`cd "${npmDirectory}" && ${this.getBuildCommand(packageManager)}`,
|
||||
this.getBuildTimeout(),
|
||||
buildEnv,
|
||||
);
|
||||
const buildCommand = `cd "${npmDirectory}" && ${this.getBuildCommand(packageManager)}`;
|
||||
const buildTimeout = this.getBuildTimeout();
|
||||
|
||||
try {
|
||||
await shellExec(buildCommand, buildTimeout, resolveExecEnv());
|
||||
} catch (error) {
|
||||
const shouldRetryWithoutStrip =
|
||||
process.platform === 'linux' &&
|
||||
this.options.targets === 'appimage' &&
|
||||
!buildEnv.NO_STRIP &&
|
||||
this.isLinuxDeployStripError(error);
|
||||
|
||||
if (shouldRetryWithoutStrip) {
|
||||
logger.warn(
|
||||
'⚠ AppImage build failed during linuxdeploy strip step, retrying with NO_STRIP=1 automatically.',
|
||||
);
|
||||
buildEnv = {
|
||||
...buildEnv,
|
||||
NO_STRIP: '1',
|
||||
};
|
||||
await shellExec(buildCommand, buildTimeout, resolveExecEnv());
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// Copy app
|
||||
const fileName = this.getFileName();
|
||||
@@ -216,6 +240,21 @@ export default abstract class BaseBuilder {
|
||||
|
||||
abstract getFileName(): string;
|
||||
|
||||
private isLinuxDeployStripError(error: unknown): boolean {
|
||||
if (!(error instanceof Error) || !error.message) {
|
||||
return false;
|
||||
}
|
||||
const message = error.message.toLowerCase();
|
||||
return (
|
||||
message.includes('linuxdeploy') ||
|
||||
message.includes('failed to run linuxdeploy') ||
|
||||
message.includes('strip:') ||
|
||||
message.includes('unable to recognise the format of the input file') ||
|
||||
message.includes('appimage tool failed') ||
|
||||
message.includes('strip tool')
|
||||
);
|
||||
}
|
||||
|
||||
// 架构映射配置
|
||||
protected static readonly ARCH_MAPPINGS: Record<
|
||||
string,
|
||||
|
||||
20
bin/utils/shell.ts
vendored
20
bin/utils/shell.ts
vendored
@@ -31,11 +31,13 @@ export async function shellExec(
|
||||
|
||||
// Provide helpful guidance for common Linux AppImage build failures
|
||||
// caused by strip tool incompatibility with modern glibc (2.38+)
|
||||
const lowerError = errorMessage.toLowerCase();
|
||||
|
||||
if (
|
||||
process.platform === 'linux' &&
|
||||
(errorMessage.includes('linuxdeploy') ||
|
||||
errorMessage.includes('appimage') ||
|
||||
errorMessage.includes('strip'))
|
||||
(lowerError.includes('linuxdeploy') ||
|
||||
lowerError.includes('appimage') ||
|
||||
lowerError.includes('strip'))
|
||||
) {
|
||||
errorMsg +=
|
||||
'\n\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n' +
|
||||
@@ -50,6 +52,18 @@ export async function shellExec(
|
||||
' • Update binutils: sudo apt install binutils (or pacman -S binutils)\n' +
|
||||
' • Detailed guide: https://github.com/tw93/Pake/blob/main/docs/faq.md\n' +
|
||||
'━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━';
|
||||
|
||||
if (
|
||||
lowerError.includes('fuse') ||
|
||||
lowerError.includes('operation not permitted') ||
|
||||
lowerError.includes('/dev/fuse')
|
||||
) {
|
||||
errorMsg +=
|
||||
'\n\nDocker / Container hint:\n' +
|
||||
' AppImage tooling needs access to /dev/fuse. When running inside Docker, add:\n' +
|
||||
' --privileged --device /dev/fuse --security-opt apparmor=unconfined\n' +
|
||||
' or run on the host directly.';
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error(errorMsg);
|
||||
|
||||
Reference in New Issue
Block a user