Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
mxcl committed Feb 24, 2025
1 parent bb4d8f5 commit f0e4099
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions pkgm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,18 +132,6 @@ async function install(args: string[], basePath: string) {

const runtime_env = expand_runtime_env(json.runtime_env, basePath);

// fix https://github.com/pkgxdev/pkgm/pull/30#issuecomment-2678957666
if (Deno.build.os == "linux") {
for (const { project } of json.pkgs) {
const foo = runtime_env[project] ?? (runtime_env[project] = {});
if (foo.LD_LIBRARY_PATH) {
foo.LD_LIBRARY_PATH = `${basePath}/lib:${foo.LD_LIBRARY_PATH}`;
} else {
foo.LD_LIBRARY_PATH = `${basePath}/lib`;
}
}
}

args = [
"pkgx",
"deno^2.1",
Expand Down Expand Up @@ -326,16 +314,30 @@ function expand_runtime_env(
runtime_env: Record<string, Record<string, string>>,
basePath: string,
) {
const expanded: Record<string, Record<string, string>> = {};
//FIXME this combines all runtime env which is strictly overkill
// for transitive deps that may not need it

const expanded: Record<string, Set<string>> = {};
for (const [project, env] of Object.entries(runtime_env)) {
const expanded_env: Record<string, string> = {};
for (const [key, value] of Object.entries(env)) {
//TODO expand all moustaches
const new_value = value.replaceAll(/\$?{{.*prefix}}/g, basePath);
expanded_env[key] = new_value;
expanded[key] ??= new Set<string>();
expanded[key].add(new_value);
}
expanded[project] = expanded_env;
}
return expanded;

// fix https://github.com/pkgxdev/pkgm/pull/30#issuecomment-2678957666
if (Deno.build.os == "linux") {
expanded["LD_LIBRARY_PATH"] ??= new Set<string>();
expanded["LD_LIBRARY_PATH"].add(`${basePath}/lib`);
}

const rv: Record<string, string> = {};
for (const [key, set] of Object.entries(expanded)) {
rv[key] = [...set].join(":");
}
return rv;
}

function symlink_with_overwrite(src: string, dst: string) {
Expand Down

0 comments on commit f0e4099

Please sign in to comment.