Skip to content

Commit

Permalink
Only symlink posix prefixes (#15)
Browse files Browse the repository at this point in the history
Fixes #13
  • Loading branch information
mxcl committed Jan 23, 2025
1 parent a98c464 commit 77c90bb
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,17 @@ jobs:
- uses: actions/checkout@v4
- uses: pkgxdev/setup@v3
- run: ./pkgm.ts i git

- run: /usr/local/bin/git --version

- run: ./pkgm.ts i pkgx.sh/brewkit
- run: /usr/local/bin/bk --help

- run: |
if [[ "$(/usr/local/bin/pkgx --version)" != "pkgx 2"* ]]; then
exit 1
fi
# TODO pending: https://github.com/pkgxdev/pantry/issues/8487
# - run: ./pkgm.ts i xpra.org # https://github.com/pkgxdev/pkgm/issues/13
# - run: ls -la /usr/local/pkgs/xpra.org/v6.2.3/venv/bin
# - run: xpra --version
32 changes: 19 additions & 13 deletions pkgm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,25 +148,26 @@ async function sudo_install(
) {
const dst = "/usr/local";
for (const pkg_prefix of pkg_prefixes) {
if (pkg_prefix == "pkgx.sh") {
// don’t overwrite ourselves
// * https://github.com/pkgxdev/pkgm/issues/14
// * https://github.com/pkgxdev/pkgm/issues/17
continue;
}
// create /usr/local/pkgs/${prefix}
await mirror_directory("/usr/local/pkgs", pkgx_dir, pkg_prefix);
await mirror_directory(join(dst, "pkgs"), pkgx_dir, pkg_prefix);
// symlink /usr/local/pkgs/${prefix} to /usr/local
await symlink(join("/usr/local/pkgs", pkg_prefix), dst);
if (!pkg_prefix.startsWith("pkgx.sh/v")) {
// ^^ don’t overwrite ourselves
// ^^ * https://github.com/pkgxdev/pkgm/issues/14
// ^^ * https://github.com/pkgxdev/pkgm/issues/17
await symlink(join(dst, "pkgs", pkg_prefix), dst);
}
// create v1, etc. symlinks
await create_v_symlinks(join("/usr/local/pkgs", pkg_prefix));
await create_v_symlinks(join(dst, "pkgs", pkg_prefix));
}

for (const [project, env] of Object.entries(runtime_env)) {
if (project == "pkgx.sh") continue;

const pkg_prefix = pkg_prefixes.find((x) => x.startsWith(project))!;
if (pkg_prefix == "pkgx.sh") {
continue;
}

if (!pkg_prefix) continue; //FIXME wtf?

for (const bin of ["bin", "sbin"]) {
const bin_prefix = join("/usr/local/pkgs", pkg_prefix, bin);

Expand Down Expand Up @@ -221,7 +222,12 @@ async function mirror_directory(dst: string, src: string, prefix: string) {
}

async function symlink(src: string, dst: string) {
await processEntry(src, dst);
for (const base of ["bin", "sbin", "share", "lib", "libexec", "var", "etc"]) {
const foo = join(src, base);
if (existsSync(foo)) {
await processEntry(foo, join(dst, base));
}
}

async function processEntry(sourcePath: string, targetPath: string) {
const fileInfo = await Deno.lstat(sourcePath);
Expand Down

0 comments on commit 77c90bb

Please sign in to comment.