bundle zstd for module artifact extraction
This commit is contained in:
+25
-2
@@ -71,6 +71,24 @@ function getAppIconPath(): string | undefined {
|
||||
return candidates.find((candidate) => existsSync(candidate))
|
||||
}
|
||||
|
||||
function getBundledResourcePath(...segments: string[]): string | null {
|
||||
const candidates = [
|
||||
join(process.resourcesPath, ...segments),
|
||||
join(process.resourcesPath, 'resources', ...segments),
|
||||
join(process.cwd(), 'resources', ...segments),
|
||||
join(app.getAppPath(), 'resources', ...segments)
|
||||
]
|
||||
|
||||
return candidates.find((candidate) => existsSync(candidate)) ?? null
|
||||
}
|
||||
|
||||
function getBundledZstdPath(): string | null {
|
||||
if (process.platform !== 'linux') return null
|
||||
const arch = process.arch === 'arm64' ? 'arm64' : process.arch === 'x64' ? 'x64' : null
|
||||
if (!arch) return null
|
||||
return getBundledResourcePath('bin', `linux-${arch}`, 'zstd')
|
||||
}
|
||||
|
||||
type CachedModuleFiles = {
|
||||
root: string | null
|
||||
absoluteRoot: string | null
|
||||
@@ -610,7 +628,11 @@ async function ensureArtifactFile(url?: string | null, fileName?: string | null,
|
||||
|
||||
function tarArgsFor(filePath: string, mode: 'list' | 'extract'): string[] {
|
||||
const lower = filePath.toLowerCase()
|
||||
if (lower.endsWith('.tar.zst') || lower.endsWith('.tzst')) return mode === 'list' ? ['--zstd', '-tf'] : ['--zstd', '-xf']
|
||||
if (lower.endsWith('.tar.zst') || lower.endsWith('.tzst')) {
|
||||
const zstdPath = getBundledZstdPath()
|
||||
const compressionArgs = zstdPath ? [`--use-compress-program=${zstdPath}`] : ['--zstd']
|
||||
return mode === 'list' ? [...compressionArgs, '-tf'] : [...compressionArgs, '-xf']
|
||||
}
|
||||
if (lower.endsWith('.tar.gz') || lower.endsWith('.tgz')) return mode === 'list' ? ['-tzf'] : ['-xzf']
|
||||
return mode === 'list' ? ['-tf'] : ['-xf']
|
||||
}
|
||||
@@ -659,7 +681,8 @@ async function prepareRuntimeImages(images?: RuntimeImageArtifact[] | null): Pro
|
||||
continue
|
||||
}
|
||||
if (filePath.toLowerCase().endsWith('.tar.zst') || filePath.toLowerCase().endsWith('.tzst')) {
|
||||
await runCommand('bash', ['-lc', 'zstd -dc "$1" | docker load', 'autonomy-studio-runtime-image', filePath], undefined, undefined, 900000)
|
||||
const zstdPath = getBundledZstdPath() ?? 'zstd'
|
||||
await runCommand('bash', ['-lc', '"$1" -dc "$2" | docker load', 'autonomy-studio-runtime-image', zstdPath, filePath], undefined, undefined, 900000)
|
||||
} else {
|
||||
await runCommand('docker', ['load', '-i', filePath], undefined, undefined, 900000)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user