fix: preserve appimage plugin name

This commit is contained in:
lucaronin
2026-05-14 16:44:46 +02:00
parent d445c72edb
commit 8b83b2c691
2 changed files with 24 additions and 2 deletions

View File

@@ -11,7 +11,7 @@ import {
writeFile,
} from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join, resolve } from 'node:path'
import { dirname, join, resolve } from 'node:path'
import process from 'node:process'
import { fileURLToPath } from 'node:url'
@@ -20,7 +20,8 @@ export const BROKEN_LINUXDEPLOY_APPRUN_DIR_LINE =
export const FIXED_LINUXDEPLOY_APPRUN_DIR_LINE =
'this_dir="$(dirname "$(readlink -f "$0")")"'
export const APPIMAGE_PLUGIN_WRAPPER_NAME = 'linuxdeploy-plugin-appimage.AppImage'
export const REAL_APPIMAGE_PLUGIN_NAME = 'linuxdeploy-plugin-appimage.real.AppImage'
export const REAL_APPIMAGE_PLUGIN_NAME =
'tolaria-real-linuxdeploy-plugin-appimage/linuxdeploy-plugin-appimage.AppImage'
export const APPIMAGE_FCITX_GTK3_IM_MODULE_PATH =
'usr/lib/x86_64-linux-gnu/gtk-3.0/3.0.0/immodules/im-fcitx5.so'
export const APPIMAGE_FCITX_GCLIENT_LIBRARY_PATH =
@@ -115,6 +116,7 @@ download_real_plugin() {
local tmp_plugin="$REAL_PLUGIN.tmp.$$"
rm -f "$tmp_plugin"
mkdir -p "$(dirname -- "$REAL_PLUGIN")"
if command -v curl >/dev/null 2>&1; then
curl -fsSL -o "$tmp_plugin" "$PLUGIN_URL"
@@ -208,6 +210,7 @@ export async function preparePluginWrapper({
if (existsSync(wrapperPath) && !existsSync(realPluginPath)) {
const existing = await readFile(wrapperPath, 'utf8').catch(() => '')
if (!existing.includes(WRAPPER_MARKER)) {
await mkdir(dirname(realPluginPath), { recursive: true })
await rename(wrapperPath, realPluginPath)
}
}

View File

@@ -17,8 +17,10 @@ import test from 'node:test'
import {
BROKEN_LINUXDEPLOY_APPRUN_DIR_LINE,
FIXED_LINUXDEPLOY_APPRUN_DIR_LINE,
REAL_APPIMAGE_PLUGIN_NAME,
appImagePluginWrapperSource,
patchAppRunText,
preparePluginWrapper,
} from './appimage-launcher-tools.mjs'
function brokenResolverDir(invokedPath) {
@@ -113,6 +115,23 @@ test('plugin wrapper patches AppRun before delegating to the real output plugin'
assert.equal(patched.includes(FIXED_LINUXDEPLOY_APPRUN_DIR_LINE), true)
})
test('plugin wrapper keeps the delegated appimage plugin basename canonical', async () => {
const root = await mkdtemp(join(tmpdir(), 'tolaria-appimage-tools-'))
const { realPluginPath, wrapperPath } = await preparePluginWrapper({
toolsDir: root,
})
assert.equal(basename(wrapperPath), 'linuxdeploy-plugin-appimage.AppImage')
assert.equal(
realPluginPath,
join(root, 'tolaria-real-linuxdeploy-plugin-appimage', 'linuxdeploy-plugin-appimage.AppImage'),
)
assert.equal(REAL_APPIMAGE_PLUGIN_NAME.endsWith('/linuxdeploy-plugin-appimage.AppImage'), true)
const wrapper = await readFile(wrapperPath, 'utf8')
assert.equal(wrapper.includes('linuxdeploy-plugin-appimage.real.AppImage'), false)
})
test('plugin wrapper bundles fcitx GTK3 input module before sealing AppImage', async () => {
const root = await mkdtemp(join(tmpdir(), 'tolaria-appimage-fcitx-'))
const appDir = join(root, 'Tolaria.AppDir')