Documented tree replacement (the history has no git-subtree metadata): 3-way merge of the old subtree (570201a:engine/strata) against upstream 41cf05a06a25dd29103b7b27a2279a3f60c21876 (2026-10-25), merge base = the old pin d9ab8435 (tree-identical to upstream 5b734e42; d9ab8435 is not an ancestor of upstream main). Local patches re-applied by hand where they conflicted (15 files): STRATA_CUDA_STATIC profile, experimental KAR experts and KAR PLE arms, keyless V-only arm (now beside upstream's K8V4 hybrid KV and fused norm+rope). Details, conflict table and left-out files are in docs/upstream.md. Left out (weights, captures, logs, media): new bench/results (2022 files), binary media and app assets (61), docs/work/evidence (24), *.bin / *.gguf data files, and the 7 files the first import already left out. scripts/build-cpu.sh: build the 11 CPU tests upstream registered since the old pin (they ran as "Not Run"). Checked: build-cpu.sh 16/16 ctest in WSL; sm_86 CUDA objects of the patched files compile, also with the KAR macros on. No GPU run, no quality gate. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
72 lines
4.0 KiB
JavaScript
72 lines
4.0 KiB
JavaScript
/**
|
|
* The environment for programs that are NOT part of Strata: the folder chooser (zenity, kdialog, gdbus), xdg-open and the browser it
|
|
* starts, and the shell and tools the coding assistant runs for the person.
|
|
*
|
|
* Why: the Linux AppImage starts Strata with its own libraries and settings in the environment (LD_LIBRARY_PATH, GTK_*, GIO_*,
|
|
* GSETTINGS_SCHEMA_DIR, XDG_DATA_DIRS, PYTHONHOME, ...). A system program that inherits them loads Strata's copies of libssl, GTK and
|
|
* GLib instead of its own and dies (tester report 2026-10-17: zenity "libssl.so.3: version OPENSSL_3.2.0 not found", so the folder
|
|
* picker did nothing). Programs Strata ships itself (its Python, Node and engine) keep the environment they were built for; everything
|
|
* else gets the environment the AppImage was started from.
|
|
*
|
|
* The AppImage's launcher records that original environment in STRATA_ORIGINAL_ENV (repack-appimage.sh adds the hook). An older
|
|
* AppImage without the record is cleaned instead: every variable that points into the AppImage's own folder is dropped, and its
|
|
* folders are removed from the path lists.
|
|
*/
|
|
const RECORD = 'STRATA_ORIGINAL_ENV';
|
|
|
|
/** Variables the AppImage tooling sets only for itself; never meant for another program. */
|
|
const APPIMAGE_ONLY = [
|
|
'APPDIR', 'APPIMAGE', 'ARGV0', 'OWD', 'APPIMAGE_SILENT_INSTALL', 'APPIMAGE_EXTRACT_AND_RUN',
|
|
'GTK_DATA_PREFIX', 'GTK_EXE_PREFIX', 'GTK_PATH', 'GTK_IM_MODULE_FILE', 'GTK_THEME', 'GDK_PIXBUF_MODULE_FILE', 'GDK_PIXBUF_MODULEDIR',
|
|
'GSETTINGS_SCHEMA_DIR', 'GI_TYPELIB_PATH', 'GIO_MODULE_DIR', 'GIO_EXTRA_MODULES',
|
|
'GST_REGISTRY_REUSE_PLUGIN_SCANNER', 'GST_PLUGIN_SYSTEM_PATH_1_0', 'GST_PLUGIN_PATH_1_0', 'GST_PLUGIN_SCANNER_1_0', 'GST_PTP_HELPER_1_0',
|
|
'WEBKIT_EXEC_PATH', 'WEBKIT_INJECTED_BUNDLE_PATH', 'STRATA_ORIGINAL_ENV', 'STRATA_APPDIR',
|
|
];
|
|
/** Lists of folders: the AppImage prepends its own; only its entries are removed. */
|
|
const PATH_LISTS = ['PATH', 'XDG_DATA_DIRS', 'XDG_CONFIG_DIRS', 'LD_LIBRARY_PATH', 'LD_PRELOAD', 'LIBRARY_PATH', 'PYTHONPATH', 'PYTHONHOME', 'PERLLIB', 'PERL5LIB', 'QT_PLUGIN_PATH', 'QML2_IMPORT_PATH', 'GST_PLUGIN_PATH', 'GTK_PATH', 'GIO_MODULE_DIR'];
|
|
|
|
/** The environment the program was started from, decoded from the launcher's record, or null when there is none. */
|
|
export function recordedOriginal(env = process.env) {
|
|
const raw = env[RECORD];
|
|
if (!raw) return null;
|
|
try {
|
|
const text = Buffer.from(raw, 'base64').toString('utf8');
|
|
const out = {};
|
|
for (const entry of text.split('\0')) {
|
|
const at = entry.indexOf('=');
|
|
if (at > 0) out[entry.slice(0, at)] = entry.slice(at + 1);
|
|
}
|
|
return Object.keys(out).length ? out : null;
|
|
} catch { return null; }
|
|
}
|
|
|
|
/** `env` with everything that belongs to a running AppImage removed (no record needed). */
|
|
export function withoutAppImage(env = process.env) {
|
|
const dir = env.APPDIR || '';
|
|
const out = { ...env };
|
|
const inside = value => !!dir && (value === dir || value.startsWith(`${dir}/`) || value.startsWith(`${dir}//`));
|
|
for (const name of APPIMAGE_ONLY) delete out[name];
|
|
if (dir) {
|
|
for (const name of Object.keys(out)) if (/^(GTK|GDK|GIO|GST|GI_|GSETTINGS|WEBKIT)/.test(name) && typeof out[name] === 'string' && out[name].includes(dir)) delete out[name];
|
|
for (const name of PATH_LISTS) {
|
|
if (typeof out[name] !== 'string') continue;
|
|
const kept = out[name].split(':').filter(part => part && !inside(part));
|
|
if (kept.length) out[name] = kept.join(':'); else delete out[name];
|
|
}
|
|
}
|
|
return out;
|
|
}
|
|
|
|
/** True when this process was started from an AppImage. */
|
|
export const insideAppImage = (env = process.env) => !!(env.APPIMAGE || env.APPDIR);
|
|
|
|
/**
|
|
* The environment for an external program (see the top of this file). Outside an AppImage it is `env` unchanged.
|
|
* `extra` is added last (a variable the caller really means to pass).
|
|
*/
|
|
export function externalEnvironment(env = process.env, extra = {}) {
|
|
if (!insideAppImage(env) && !env[RECORD]) return { ...env, ...extra };
|
|
const original = recordedOriginal(env);
|
|
return { ...(original ?? withoutAppImage(env)), ...extra };
|
|
}
|