#!/usr/bin/env node /** * Build the optional Linux (Ubuntu) desktop bundle for Luminary. * * Like windows/build.mjs this is *outside* the main build: it only reads the * repository (`dist/`, `server/`, `package.json`) and writes everything into a * directory outside the checkout. Nothing in `src/`, `server/`, `package.json`, * the Dockerfile, the deploy script or `dist/` is modified by this file, and no * npm script is added for it. Run it directly: * * node linux/build.mjs # build dist/ then the bundle * node linux/build.mjs --skip-build # reuse the existing dist/ * node linux/build.mjs --out /srv/lum # choose the output directory * * The bundle keeps the layout the server expects (it derives `DIST_DIR` from * the parent of `server/`), so it is a plain folder plus a launcher: * * /Luminary/ * luminary bash launcher: start, health wait, app window * install.sh adds Luminary to the Ubuntu applications menu * Luminary.png icon * runtime/bin/node official Node 24 linux-x64, SHA-256 checked * app/ unchanged server/, dist/, production node_modules/ * README-linux.txt * version.txt */ import { createHash } from 'node:crypto'; import { spawnSync } from 'node:child_process'; import { chmodSync, cpSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, statSync, symlinkSync, writeFileSync, } from 'node:fs'; import os from 'node:os'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; const HERE = path.dirname(fileURLToPath(import.meta.url)); const ROOT = path.resolve(HERE, '..'); const LAUNCHER_FILES = path.join(HERE, 'launcher'); const RELEASES_DIR = path.join(HERE, 'releases'); const NPM = 'npm'; const DEFAULT_NODE = 'v24.22.2'; const HELP = `Luminary Linux (Ubuntu) bundle Usage: node linux/build.mjs [options] --out output directory (default: /luminary-linux). Must be outside this repository; the bundle is staged in /stage and archived to /Luminary--linux-x64.tar.gz. --skip-build reuse the existing dist/ instead of running npm run build --node bundled Node version, e.g. v24.22.2 (must be >= 24) --allow-dirty skip the check that the checkout is clean outside linux/ --publish copy the finished tar.gz and .deb to linux/releases (plus a SHA256SUMS.txt) so they can be handed off or uploaded --help print this text Nothing in the repository is modified: the only writes outside the output directory are the ones npm and nodejs.org make for their own caches. `; function fail(message) { process.stderr.write(`linux: FAILED: ${message}\n`); process.exit(1); } function log(step, message) { process.stdout.write(`linux: ${step.padEnd(9)} ${message}\n`); } function warn(message) { process.stderr.write(`linux: warning: ${message}\n`); } function defaultOutDir() { return path.join(process.env.XDG_CACHE_HOME || path.join(os.homedir(), '.cache'), 'luminary-linux'); } function parseArgs(argv) { const options = { out: defaultOutDir(), node: DEFAULT_NODE, build: true, allowDirty: false, publish: false, help: false, }; const value = (index, flag) => { const next = argv[index + 1]; if (!next || next.startsWith('--')) fail(`${flag} needs a value`); return next; }; for (let i = 0; i < argv.length; i++) { const arg = argv[i]; if (arg === '--out') { options.out = path.resolve(value(i, arg)); i += 1; } else if (arg === '--node') { const version = value(i, arg); options.node = version.startsWith('v') ? version : `v${version}`; i += 1; } else if (arg === '--skip-build') { options.build = false; } else if (arg === '--allow-dirty') { options.allowDirty = true; } else if (arg === '--publish') { options.publish = true; } else if (arg === '--help' || arg === '-h') { options.help = true; } else { fail(`unknown option ${arg} (see --help)`); } } if (!/^v\d+\.\d+\.\d+$/.test(options.node)) { fail(`--node must look like v24.22.2 (got ${options.node})`); } return options; } function git(args, { trim = true } = {}) { const result = spawnSync('git', args, { cwd: ROOT, encoding: 'utf8' }); if (result.error || result.status !== 0) return null; return trim ? result.stdout.trim() : result.stdout; } /** * The bundle must not land in the checkout: a staged Node runtime and * node_modules would otherwise be rsynced to production by scripts/deploy.mjs * and grow the Docker build context. */ function assertOutsideRepo(outDir) { const relative = path.relative(ROOT, outDir); const inside = !relative.startsWith('..') && !path.isAbsolute(relative); if (inside) { fail( `--out resolves inside the repository (${outDir}).\n` + 'The bundle is large and would be copied by the deploy rsync; pick an\n' + 'output directory outside the checkout, or omit --out to use the cache.', ); } } /** * Only this folder may be dirty. `logo.png` is a long-standing untracked asset * in this checkout and is not part of the app, so it is tolerated. */ function checkRepoClean(options) { const status = git(['status', '--porcelain'], { trim: false }); if (status === null) { warn('git is unavailable here; skipping the worktree check'); return; } const unexpected = status .split('\n') .filter((line) => line.length > 3) .map((line) => line.slice(3).replace(/^"|"$/g, '').replace(/^.* -> /, '').trim()) .filter((file) => file && !file.startsWith('linux/') && file !== 'logo.png'); if (!unexpected.length) return; if (options.allowDirty) { warn(`building from a modified checkout: ${unexpected.join(', ')}`); return; } fail( `the checkout has changes outside linux/:\n ${unexpected.join('\n ')}\n` + 'Commit or stash them, or pass --allow-dirty to build anyway.', ); } function readPackage() { const file = path.join(ROOT, 'package.json'); if (!existsSync(file)) fail('run this from a Luminary checkout (package.json missing)'); return JSON.parse(readFileSync(file, 'utf8')); } function run(command, args, cwd, extraEnv) { log('run', [command, ...args].join(' ')); const result = spawnSync(command, args, { cwd, stdio: 'inherit', env: extraEnv ? { ...process.env, ...extraEnv } : process.env, }); if (result.error) fail(`${command} could not start: ${result.error.message}`); if (result.status !== 0) fail(`${command} ${args.join(' ')} exited with ${result.status}`); } function ensureUi(options) { const dist = path.join(ROOT, 'dist', 'index.html'); if (options.build) { log('ui', 'npm run build (typecheck + vite build, the normal artifact)'); run(NPM, ['run', 'build'], ROOT); } else { log('ui', 'reusing the existing dist/ (--skip-build)'); } if (!existsSync(dist)) { fail('dist/index.html is missing; drop --skip-build or run "npm run build" first'); } return dist; } function copyServer(bundle) { const server = path.join(bundle, 'app', 'server'); cpSync(path.join(ROOT, 'server'), server, { recursive: true, filter: (source) => { const relative = path.relative(path.join(ROOT, 'server'), source).split(path.sep).join('/'); // The developer catalog and the test files never belong in a bundle. if (relative === 'data' || relative.startsWith('data/')) return false; if (/\.test\.mjs$/.test(relative)) return false; return true; }, }); } function copyLegal(bundle) { for (const name of ['LICENSE', 'THIRD_PARTY_NOTICES.md']) { const source = path.join(ROOT, name); if (existsSync(source)) cpSync(source, path.join(bundle, name)); } const licenses = path.join(ROOT, 'licenses'); if (existsSync(licenses)) cpSync(licenses, path.join(bundle, 'licenses'), { recursive: true }); } function installLinuxDeps(bundle) { const appDir = path.join(bundle, 'app'); cpSync(path.join(ROOT, 'package.json'), path.join(appDir, 'package.json')); cpSync(path.join(ROOT, 'package-lock.json'), path.join(appDir, 'package-lock.json')); log('deps', 'npm ci --omit=dev --os=linux --cpu=x64 (sharp linux-x64 prebuild)'); // --ignore-scripts is safe: sharp 0.35 has no install step, it resolves the // prebuilt binary through optionalDependencies. ONNXRUNTIME_NODE_INSTALL=skip // also keeps onnxruntime-node's postinstall from pulling the CUDA libraries; // the package already ships its CPU binaries. run( NPM, ['ci', '--omit=dev', '--os=linux', '--cpu=x64', '--no-audit', '--no-fund', '--ignore-scripts'], appDir, { ONNXRUNTIME_NODE_INSTALL: 'skip' }, ); // .bin shims are for an interactive shell, not for `node server/index.mjs`. rmSync(path.join(appDir, 'node_modules', '.bin'), { recursive: true, force: true }); verifySharp(appDir); } function verifySharp(appDir) { const dir = path.join(appDir, 'node_modules', '@img', 'sharp-linux-x64'); if (!existsSync(dir)) { warn('@img/sharp-linux-x64 is missing; the server will fall back to PNG proxies'); return; } const binaries = []; const walk = (current) => { for (const entry of readdirSync(current, { withFileTypes: true })) { const absolute = path.join(current, entry.name); if (entry.isDirectory()) walk(absolute); else if (/\.(node|so(\.\d+)*)$/i.test(entry.name)) binaries.push(path.relative(dir, absolute)); } }; walk(dir); if (!binaries.some((file) => file.endsWith('.node'))) { warn('@img/sharp-linux-x64 has no .node binary; check the installed package'); } else { log('deps', `sharp linux-x64 ready (${binaries.length} native files)`); } } function sha256File(file) { return createHash('sha256').update(readFileSync(file)).digest('hex'); } async function download(url) { const response = await fetch(url); if (!response.ok) throw new Error(`${response.status} ${response.statusText} from ${url}`); return Buffer.from(await response.arrayBuffer()); } function extractTar(archive, destination) { mkdirSync(destination, { recursive: true }); const result = spawnSync( 'tar', ['-xzf', archive, '-C', destination, '--strip-components=1'], { stdio: 'inherit' }, ); if (result.error || result.status !== 0) { fail(`could not extract ${path.basename(archive)} (is tar installed?)`); } } async function ensureNode(outDir, version) { const major = Number(version.slice(1).split('.')[0]); if (major < 24) { fail(`Node ${version} is too old: node:sqlite and type stripping need 24 LTS`); } const cache = path.join(outDir, 'cache'); mkdirSync(cache, { recursive: true }); const name = `node-${version}-linux-x64.tar.gz`; const archive = path.join(cache, name); const sums = path.join(cache, `SHASUMS256-${version}.txt`); const base = `https://nodejs.org/dist/${version}`; if (!existsSync(archive)) { // Unlike the Windows node.exe, the Linux tarballs sit at the dist root. log('node', `downloading ${base}/${name}`); try { writeFileSync(archive, await download(`${base}/${name}`)); } catch (error) { fail(`could not download ${name}: ${error.message}`); } } else { log('node', `using cached ${name}`); } if (!existsSync(sums)) { try { writeFileSync(sums, (await download(`${base}/SHASUMS256.txt`)).toString('utf8')); } catch (error) { warn(`could not fetch SHASUMS256.txt (${error.message}); the cached tarball is unverified`); } } const hash = sha256File(archive); if (existsSync(sums)) { const line = readFileSync(sums, 'utf8') .split('\n') .map((row) => row.trim().split(/\s+/)) .find((row) => row[1] === name); if (!line) fail(`SHASUMS256.txt for ${version} has no ${name} entry`); if (hash !== line[0]) { rmSync(archive, { force: true }); fail(`${name} failed its SHA-256 check (${hash} != ${line[0]}); re-run to download again`); } log('node', `${version} linux-x64 verified (sha256 ${hash.slice(0, 12)}…)`); } else { warn(`using the Node tarball without a published checksum (sha256 ${hash})`); } return { archive, hash }; } function installRuntime(bundle, archive) { const runtime = path.join(bundle, 'runtime'); rmSync(runtime, { recursive: true, force: true }); log('runtime', 'extracting Node into runtime/ (bin/node, lib/node_modules)'); extractTar(archive, runtime); const nodeBin = path.join(runtime, 'bin', 'node'); if (!existsSync(nodeBin)) fail('the Node tarball did not contain runtime/bin/node'); chmodSync(nodeBin, 0o755); const check = spawnSync(nodeBin, ['--version'], { encoding: 'utf8' }); if (check.status !== 0) fail(`the bundled node binary does not run here: ${check.stderr || ''}`); log('runtime', `bundled ${check.stdout.trim()} runs on this host`); return nodeBin; } function installLauncher(bundle) { const launcher = path.join(bundle, 'luminary'); cpSync(path.join(LAUNCHER_FILES, 'luminary'), launcher); chmodSync(launcher, 0o755); const installer = path.join(bundle, 'install.sh'); cpSync(path.join(LAUNCHER_FILES, 'install.sh'), installer); chmodSync(installer, 0o755); // Ships with the bundle so the first-run check is one command, and travels // into /opt/luminary in the .deb. const smoke = path.join(HERE, 'SMOKE-LINUX.sh'); if (existsSync(smoke)) { cpSync(smoke, path.join(bundle, 'SMOKE-LINUX.sh')); chmodSync(path.join(bundle, 'SMOKE-LINUX.sh'), 0o755); } log('launcher', 'luminary (app window + --stop/--status/--install), install.sh, SMOKE-LINUX.sh'); } async function writeIcon(bundle) { const logo = path.join(ROOT, 'logo.png'); const target = path.join(bundle, 'Luminary.png'); if (!existsSync(logo)) { warn('logo.png is missing; the bundle has no menu icon'); return; } try { const { default: sharp } = await import('sharp'); await sharp(logo).resize(256, 256, { fit: 'cover' }).png().toFile(target); log('icon', `Luminary.png (${(statSync(target).size / 1024).toFixed(0)} KB)`); } catch (error) { cpSync(logo, target); warn(`could not resize logo.png (${error.message}); copied it unchanged`); } } function writeVersion(bundle, pkg, nodeVersion, nodeHash, nodeSize) { const commit = git(['rev-parse', '--short', 'HEAD']) ?? 'unknown'; const lines = [ `Luminary ${pkg.version}`, `commit ${commit}`, `built ${new Date().toISOString()}`, `node ${nodeVersion} linux-x64 sha256 ${nodeHash} size ${nodeSize}`, 'launcher luminary (bash)', ]; writeFileSync(path.join(bundle, 'version.txt'), `${lines.join('\n')}\n`); return { version: pkg.version, commit }; } function writeBundleReadme(bundle, info) { const body = `Luminary ${info.version} for Linux (x64) — portable bundle ============================================== Start: ./luminary Stop: ./luminary --stop Menu: ./install.sh (adds Luminary to your applications menu) Open tab: ./luminary --browser Status: ./luminary --status Data: ~/.local/share/luminary (originals, previews, SQLite catalog) Logs: ~/.local/share/luminary/logs/server.out.log and server.err.log Sign-in: none — single-user desktop mode, no account setup Requirements - Ubuntu 22.04 or 24.04, 64-bit (any glibc distribution of similar age works). - A Chromium-based browser for the app window: Chrome, Chromium, Edge, Brave or Vivaldi. Firefox is used as a normal window, and the default browser is the last resort. WebGL2 is needed for the Develop module. - Nothing to install: Node.js is included in runtime/, and sharp's Linux binaries are bundled. No root, no apt, no deb package. - About 250 MB free where the data folder lives. Extract the tarball anywhere, then run ./luminary from the extracted folder. Nothing is written into /usr or /opt, so moving or deleting the folder is safe; the catalog lives in ~/.local/share/luminary and is not touched on removal. ./install.sh adds a menu entry (~/.local/share/applications/luminary.desktop) using this folder's absolute path, so install after you have put the folder where you want to keep it. ./luminary --uninstall removes the entry again. Back up the catalog by copying ~/.local/share/luminary while Luminary is stopped, including lumenroom.db, lumenroom.db-wal, lumenroom.db-shm and secret.key. Updating: stop Luminary, replace app/ and runtime/ from a newer bundle, start again. The data folder is outside the bundle and is untouched. Notes - The server listens on 127.0.0.1 only. Set HOST=0.0.0.0 when starting it directly with node if client proofing galleries must reach other devices. - The app window is the browser's own app mode with a private profile, so it has no tabs or address bar. Some Wayland desktops ignore the requested window class; the window still opens. - RAW decoding uses the bundled libraw WebAssembly, so no system codec packages are needed. - Photo libraries on NTFS/exFAT drives work, but SQLite is happiest on a native Linux filesystem. `; writeFileSync(path.join(bundle, 'README-linux.txt'), body); } /* ------------------------------------------------------------------ deb ---- */ function walkBytes(dir) { let total = 0; for (const entry of readdirSync(dir, { withFileTypes: true })) { const absolute = path.join(dir, entry.name); if (entry.isDirectory()) total += walkBytes(absolute); else total += lstatSync(absolute).size; } return total; } const DEB_MAINTAINER_SCRIPT = `#!/bin/sh set -e # Refresh the menu and icon caches so Luminary appears without a logout. if command -v update-desktop-database >/dev/null 2>&1; then update-desktop-database -q /usr/share/applications || true fi if command -v gtk-update-icon-cache >/dev/null 2>&1; then gtk-update-icon-cache -q -t -f /usr/share/icons/hicolor || true fi exit 0 `; function debControlFile(pkg, installedBytes) { return [ 'Package: luminary', `Version: ${pkg.version}`, 'Architecture: amd64', 'Maintainer: Brian Hursey ', `Installed-Size: ${Math.ceil(installedBytes / 1024)}`, 'Depends: libc6, libstdc++6, libgomp1', 'Recommends: chromium | google-chrome-stable | microsoft-edge-stable | firefox', 'Section: graphics', 'Priority: optional', 'Homepage: https://git.maple-street.net/bhursey/luminary', 'Description: photo library and raw editor', ' Luminary catalogs photos, develops camera raw files and serves client', ' proofing galleries. This package bundles the Node runtime and the server,', ' so it installs with no other dependencies. Photos and the catalog live in', ' ~/.local/share/luminary and are kept when the package is removed.', '', ].join('\n'); } function debDesktopEntry() { return [ '[Desktop Entry]', 'Type=Application', 'Version=1.0', 'Name=Luminary', 'GenericName=Photo library', 'Comment=Photo library and raw editor', 'Exec=/usr/bin/luminary', 'Path=/opt/luminary', 'Icon=luminary', 'Terminal=false', 'Categories=Graphics;Photography;', 'Keywords=photo;raw;catalog;editor;', 'StartupNotify=true', 'StartupWMClass=Luminary', '', ].join('\n'); } function debCopyright() { return [ 'Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/', 'Upstream-Name: Luminary', 'Source: https://git.maple-street.net/bhursey/luminary', '', 'Files: *', 'Copyright: 2026 Brian Hursey', 'License: MIT', ' The full MIT licence text is in /opt/luminary/LICENSE.', '', 'Files: opt/luminary/app/node_modules/onnxruntime-node/*', 'Copyright: Microsoft Corporation', 'License: MIT', ' ONNX Runtime; see /opt/luminary/THIRD_PARTY_NOTICES.md.', '', 'Files: opt/luminary/app/server/denoise/scunet_color_25.onnx*', 'Copyright: Kai Zhang and SCUNet contributors', 'License: Apache-2.0', ' See /opt/luminary/THIRD_PARTY_NOTICES.md.', '', ].join('\n'); } /** * Builds the opt-in Ubuntu package from the same staged bundle. Installed as * /opt/luminary so the bundle layout (and therefore the launcher's bundle * detection) is unchanged; the data folder stays in the user's home. */ function buildDeb(outDir, pkg, bundle) { const probe = spawnSync('dpkg-deb', ['--version'], { encoding: 'utf8' }); if (probe.error || probe.status !== 0) { warn('dpkg-deb is not installed; skipping the .deb (install the dpkg package)'); return null; } const work = path.join(outDir, 'deb.next'); rmSync(work, { recursive: true, force: true }); const root = path.join(work, 'root'); log('deb', 'staging /opt/luminary, /usr/bin/luminary and the menu entry'); const appTarget = path.join(root, 'opt', 'luminary'); mkdirSync(path.dirname(appTarget), { recursive: true }); cpSync(bundle, appTarget, { recursive: true }); const binDir = path.join(root, 'usr', 'bin'); mkdirSync(binDir, { recursive: true }); // Relative link so the package works whatever the prefix. symlinkSync('../opt/luminary/luminary', path.join(binDir, 'luminary')); const appsDir = path.join(root, 'usr', 'share', 'applications'); mkdirSync(appsDir, { recursive: true }); writeFileSync(path.join(appsDir, 'luminary.desktop'), debDesktopEntry()); const icon = path.join(bundle, 'Luminary.png'); const iconDir = path.join(root, 'usr', 'share', 'icons', 'hicolor', '256x256', 'apps'); mkdirSync(iconDir, { recursive: true }); if (existsSync(icon)) cpSync(icon, path.join(iconDir, 'luminary.png')); else warn('the bundle has no Luminary.png; the menu entry will use a generic icon'); const docDir = path.join(root, 'usr', 'share', 'doc', 'luminary'); mkdirSync(docDir, { recursive: true }); cpSync(path.join(bundle, 'README-linux.txt'), path.join(docDir, 'README-linux.txt')); writeFileSync(path.join(docDir, 'copyright'), debCopyright()); const installedBytes = walkBytes(root); const controlDir = path.join(root, 'DEBIAN'); mkdirSync(controlDir, { recursive: true }); writeFileSync(path.join(controlDir, 'control'), debControlFile(pkg, installedBytes)); for (const name of ['postinst', 'postrm']) { const file = path.join(controlDir, name); writeFileSync(file, DEB_MAINTAINER_SCRIPT); chmodSync(file, 0o755); } const debPath = path.join(outDir, `Luminary-${pkg.version}-linux-amd64.deb`); rmSync(debPath, { force: true }); const result = spawnSync( 'dpkg-deb', ['--root-owner-group', '-Zxz', '--build', root, debPath], { stdio: 'inherit' }, ); if (result.error || result.status !== 0) fail('dpkg-deb could not build the package'); const listed = spawnSync('dpkg-deb', ['--contents', debPath], { encoding: 'utf8' }); if (listed.status !== 0) fail('the .deb could not be read back'); for (const required of [ 'opt/luminary/luminary', 'opt/luminary/runtime/bin/node', 'usr/bin/luminary', 'usr/share/applications/luminary.desktop', ]) { if (!listed.stdout.includes(required)) fail(`the .deb is missing ${required}`); } log('deb', `${path.basename(debPath)} (${(statSync(debPath).size / 1024 / 1024).toFixed(1)} MB)`); rmSync(work, { recursive: true, force: true }); return debPath; } /* ------------------------------------------------------------------ tar ---- */ function createArchive(workRoot, tarPath) { rmSync(tarPath, { force: true }); const deterministic = [ '--sort=name', '--owner=0', '--group=0', '--numeric-owner', '--mtime=@1577836800', '-czf', tarPath, '-C', workRoot, 'Luminary', ]; let result = spawnSync('tar', deterministic, { stdio: 'inherit' }); if (result.error || result.status !== 0) { warn('this tar has no --sort/--owner support; writing a plain archive instead'); result = spawnSync('tar', ['-czf', tarPath, '-C', workRoot, 'Luminary'], { stdio: 'inherit' }); } if (result.error || result.status !== 0) fail('tar could not create the archive'); const list = spawnSync('tar', ['-tzf', tarPath], { encoding: 'utf8' }); if (list.status !== 0) fail('the archive could not be read back'); const entries = list.stdout.split('\n').filter(Boolean); for (const required of [ 'Luminary/luminary', 'Luminary/runtime/bin/node', 'Luminary/app/server/index.mjs', 'Luminary/app/dist/index.html', ]) { if (!entries.includes(required)) fail(`the archive is missing ${required}`); } return { files: entries.length, bytes: statSync(tarPath).size }; } /* ----------------------------------------------------------------- main ---- */ async function main() { const options = parseArgs(process.argv.slice(2)); if (options.help) { process.stdout.write(HELP); return 0; } assertOutsideRepo(options.out); const pkg = readPackage(); log('repo', `${pkg.name} ${pkg.version} at ${ROOT}`); log('out', options.out); checkRepoClean(options); ensureUi(options); // Build into a sibling and swap at the end, so a failed run never replaces // the last complete bundle with a partial tree. const stageRoot = path.join(options.out, 'stage'); const workRoot = path.join(options.out, 'stage.next'); const bundle = path.join(workRoot, 'Luminary'); rmSync(workRoot, { recursive: true, force: true }); mkdirSync(path.join(bundle, 'app'), { recursive: true }); log('stage', 'copying dist/ and server/ (unchanged layout the server expects)'); cpSync(path.join(ROOT, 'dist'), path.join(bundle, 'app', 'dist'), { recursive: true }); copyServer(bundle); copyLegal(bundle); installLinuxDeps(bundle); const node = await ensureNode(options.out, options.node); const nodeBin = installRuntime(bundle, node.archive); // Remember the size now: the bundle is renamed into stage/ before the summary. const nodeBinSize = statSync(nodeBin).size; installLauncher(bundle); await writeIcon(bundle); const info = writeVersion( bundle, pkg, options.node, node.hash, statSync(node.archive).size, ); writeBundleReadme(bundle, info); const tarPath = path.join(options.out, `Luminary-${pkg.version}-linux-x64.tar.gz`); log('tar', path.basename(tarPath)); const archive = createArchive(workRoot, tarPath); // The .deb is built from the same staged bundle, before it is moved into // stage/, so both artifacts are guaranteed to come from one build. const debPath = buildDeb(options.out, pkg, bundle); rmSync(stageRoot, { recursive: true, force: true }); renameSync(workRoot, stageRoot); // The isolation contract: nothing outside linux/ may have changed. if (!options.allowDirty) checkRepoClean(options); const stagedBundle = path.join(stageRoot, 'Luminary'); // Hand-off copy. Staging and the archives stay outside the checkout; this is // the one write into the repository, into linux/releases. const published = []; if (options.publish) { mkdirSync(RELEASES_DIR, { recursive: true }); const sums = []; for (const artifact of [tarPath, ...(debPath ? [debPath] : [])]) { const target = path.join(RELEASES_DIR, path.basename(artifact)); cpSync(artifact, target); sums.push(`${sha256File(target)} ${path.basename(target)}`); log('publish', path.relative(ROOT, target)); published.push(target); } writeFileSync(path.join(RELEASES_DIR, 'SHA256SUMS.txt'), `${sums.join('\n')}\n`); } process.stdout.write( [ '', 'linux build PASSED', ` artifact ${tarPath}`, ` size ${(archive.bytes / 1024 / 1024).toFixed(1)} MB (${archive.files} entries)`, ` sha256 ${sha256File(tarPath)}`, ` node ${options.node} linux-x64 (${(nodeBinSize / 1024 / 1024).toFixed(0)} MB binary)`, ` launcher luminary (bash)`, ...(debPath ? [ ` deb ${debPath}`, ` deb size ${(statSync(debPath).size / 1024 / 1024).toFixed(1)} MB`, ] : []), ` staged ${stagedBundle}`, ...published.map((file) => ` publish ${path.relative(ROOT, file)}`), '', published.length ? 'Only linux/ was written: the archives in linux/releases are ready to transfer.' : 'The repository was not modified; only linux/ and the output directory were touched.', '', ].join('\n'), ); return 0; } main().then( (code) => { process.exitCode = code; }, (error) => { fail(error instanceof Error ? error.message : String(error)); }, );