From 0ef8d300072321ff90420493adfe18b6fbbf15fd Mon Sep 17 00:00:00 2001 From: smail Date: Sun, 18 Oct 2026 17:32:17 +0800 Subject: [PATCH] =?UTF-8?q?fix(package):=20=E7=BB=9F=E4=B8=80=E5=85=A8?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E5=8F=91=E5=B8=83=E5=8C=85=E5=9D=87=E5=8C=85?= =?UTF-8?q?=E5=90=ABdeploy=E9=83=A8=E7=BD=B2=E8=BF=90=E7=BB=B4=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=E5=B9=B6=E5=90=8C=E6=AD=A5=E6=B5=8B=E8=AF=95=E4=B8=8E?= =?UTF-8?q?=E5=9B=9E=E6=89=A7=E6=96=AD=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/package.mjs | 9 +++++---- test/frontend/package-release.test.mjs | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/deploy/package.mjs b/deploy/package.mjs index cca81026..a0079f18 100644 --- a/deploy/package.mjs +++ b/deploy/package.mjs @@ -9,13 +9,12 @@ import { buildPlan, root, targets } from './build-plugins.mjs' const execute = promisify(execFile) const runtimeDirectories = ['config', 'data', 'ssl', 'log'] -async function copyDeployFiles(stagingSmailDir, target, workspace) { - if (!target.startsWith('linux_')) return +async function copyDeployFiles(stagingSmailDir, target, workspace, files) { const deployDir = path.join(stagingSmailDir, 'deploy') const systemdDir = path.join(deployDir, 'systemd') await mkdir(deployDir, { recursive: true, mode: 0o755 }) await mkdir(systemdDir, { recursive: true, mode: 0o755 }) - const srcDeploy = path.join(workspace, 'deploy') + const srcDeploy = path.join(root, 'deploy') const deployFiles = ['install-systemd.sh', 'update-systemd.sh'] for (const f of deployFiles) { const src = path.join(srcDeploy, f) @@ -23,6 +22,7 @@ async function copyDeployFiles(stagingSmailDir, target, workspace) { try { await copyFile(src, dst) await chmod(dst, 0o755) + if (files) files.push({ name: ['deploy', f].join('/'), ...await digestFile(dst) }) } catch (e) {} } const srcSystemd = path.join(srcDeploy, 'systemd') @@ -33,6 +33,7 @@ async function copyDeployFiles(stagingSmailDir, target, workspace) { try { await copyFile(src, dst) await chmod(dst, 0o755) + if (files) files.push({ name: ['deploy', 'systemd', f].join('/'), ...await digestFile(dst) }) } catch (e) {} } } @@ -146,7 +147,7 @@ export async function packageRelease(selectedTargets = targets, { workspace = ro await chmod(destination, 0o755) files.push({ name, ...await digestFile(destination) }) } - await copyDeployFiles(runtime, target, workspace) + await copyDeployFiles(runtime, target, workspace, files) const version = await resolveAppVersion(workspace) const baseExt = target.startsWith('windows_') ? 'zip' : 'tar.gz' const archiveName = version && version !== 'dev' ? `Smail_${version}_${target}.${baseExt}` : `${name}.${baseExt}` diff --git a/test/frontend/package-release.test.mjs b/test/frontend/package-release.test.mjs index 03fd48f8..5fc8be4e 100644 --- a/test/frontend/package-release.test.mjs +++ b/test/frontend/package-release.test.mjs @@ -50,14 +50,24 @@ test('六个平台发布包只包含三个程序和四个空目录,解压后 const programs = ['smail', 'smail-admin', 'smail-config'].map(name => name + extension) const directories = ['config', 'data', 'log', 'ssl'] const entries = await listArchiveEntries(release.archive) + const deployEntries = [ + 'smail/deploy/', + 'smail/deploy/install-systemd.sh', + 'smail/deploy/update-systemd.sh', + 'smail/deploy/systemd/', + 'smail/deploy/systemd/smail.service', + 'smail/deploy/systemd/smail-admin.service', + 'smail/deploy/systemd/smail-tls-sync.service', + 'smail/deploy/systemd/smail-tls-sync.path' + ] assert.deepEqual(entries.sort(), [ - 'smail/', ...programs.map(name => `smail/${name}`), ...directories.map(name => `smail/${name}/`) + 'smail/', ...programs.map(name => 'smail/' + name), ...directories.map(name => 'smail/' + name + '/'), ...deployEntries ].sort()) const extracted = path.join(workspace, 'extracted', release.target) await mkdir(extracted, { recursive: true }) await extractArchive(release.archive, extracted) const receipt = JSON.parse(await readFile(release.receipt, 'utf8')) - assert.equal(receipt.files.length, 3) + assert.equal(receipt.files.length, 9) assert.equal(receipt.archive.name, path.basename(release.archive)) const archiveBytes = await readFile(release.archive) assert.equal(receipt.archive.bytes, archiveBytes.length)