Skip to content

Commit 77c90bb

Browse files
committed
Only symlink posix prefixes (#15)
Fixes #13
1 parent a98c464 commit 77c90bb

2 files changed

Lines changed: 29 additions & 14 deletions

File tree

.github/workflows/ci.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,17 @@ jobs:
2828
- uses: actions/checkout@v4
2929
- uses: pkgxdev/setup@v3
3030
- run: ./pkgm.ts i git
31-
3231
- run: /usr/local/bin/git --version
3332

3433
- run: ./pkgm.ts i pkgx.sh/brewkit
3534
- run: /usr/local/bin/bk --help
35+
36+
- run: |
37+
if [[ "$(/usr/local/bin/pkgx --version)" != "pkgx 2"* ]]; then
38+
exit 1
39+
fi
40+
41+
# TODO pending: https://github.com/pkgxdev/pantry/issues/8487
42+
# - run: ./pkgm.ts i xpra.org # https://github.com/pkgxdev/pkgm/issues/13
43+
# - run: ls -la /usr/local/pkgs/xpra.org/v6.2.3/venv/bin
44+
# - run: xpra --version

pkgm.ts

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -148,25 +148,26 @@ async function sudo_install(
148148
) {
149149
const dst = "/usr/local";
150150
for (const pkg_prefix of pkg_prefixes) {
151-
if (pkg_prefix == "pkgx.sh") {
152-
// don’t overwrite ourselves
153-
// * https://github.com/pkgxdev/pkgm/issues/14
154-
// * https://github.com/pkgxdev/pkgm/issues/17
155-
continue;
156-
}
157151
// create /usr/local/pkgs/${prefix}
158-
await mirror_directory("/usr/local/pkgs", pkgx_dir, pkg_prefix);
152+
await mirror_directory(join(dst, "pkgs"), pkgx_dir, pkg_prefix);
159153
// symlink /usr/local/pkgs/${prefix} to /usr/local
160-
await symlink(join("/usr/local/pkgs", pkg_prefix), dst);
154+
if (!pkg_prefix.startsWith("pkgx.sh/v")) {
155+
// ^^ don’t overwrite ourselves
156+
// ^^ * https://github.com/pkgxdev/pkgm/issues/14
157+
// ^^ * https://github.com/pkgxdev/pkgm/issues/17
158+
await symlink(join(dst, "pkgs", pkg_prefix), dst);
159+
}
161160
// create v1, etc. symlinks
162-
await create_v_symlinks(join("/usr/local/pkgs", pkg_prefix));
161+
await create_v_symlinks(join(dst, "pkgs", pkg_prefix));
163162
}
164163

165164
for (const [project, env] of Object.entries(runtime_env)) {
165+
if (project == "pkgx.sh") continue;
166+
166167
const pkg_prefix = pkg_prefixes.find((x) => x.startsWith(project))!;
167-
if (pkg_prefix == "pkgx.sh") {
168-
continue;
169-
}
168+
169+
if (!pkg_prefix) continue; //FIXME wtf?
170+
170171
for (const bin of ["bin", "sbin"]) {
171172
const bin_prefix = join("/usr/local/pkgs", pkg_prefix, bin);
172173

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

223224
async function symlink(src: string, dst: string) {
224-
await processEntry(src, dst);
225+
for (const base of ["bin", "sbin", "share", "lib", "libexec", "var", "etc"]) {
226+
const foo = join(src, base);
227+
if (existsSync(foo)) {
228+
await processEntry(foo, join(dst, base));
229+
}
230+
}
225231

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

0 commit comments

Comments
 (0)