Skip to content

Commit 6e9130c

Browse files
committed
update libexec for pkgx^2
- no longer produces `v*`. - uses PKGX_PANTRY_DIR instead of PKGX_PANTRY_PATH.
1 parent 552d4b6 commit 6e9130c

23 files changed

Lines changed: 81 additions & 38 deletions

File tree

.github/workflows/ci.actions.yml

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ jobs:
88
outputs:
99
pkg: ${{ steps.build.outputs.pkgjson }}
1010
env:
11-
PKGX_PANTRY_PATH: ${{github.workspace}}/co
11+
PKGX_PANTRY_PATH: ${{github.workspace}}/co # v1
12+
PKGX_PANTRY_DIR: ${{github.workspace}}/co # v2
1213
strategy:
1314
matrix:
1415
platform:
@@ -21,9 +22,9 @@ jobs:
2122
steps:
2223
- uses: actions/checkout@v4
2324
with:
24-
path: co # test that things working isn’t just a coincident of PWD == BREKWIT_DIR
25+
path: co # test that things working isn’t just a coincident of PWD == BREKWIT_DIR
2526

26-
- uses: pkgxdev/setup@v2
27+
- uses: pkgxdev/setup@v4
2728

2829
- uses: ./co/build
2930
id: build
@@ -51,11 +52,12 @@ jobs:
5152
runs-on: ubuntu-latest
5253
env:
5354
PKGX_PANTRY_PATH: ${{github.workspace}}/co
55+
PKGX_PANTRY_DIR: ${{github.workspace}}/co
5456
steps:
5557
- uses: actions/checkout@v4
5658
with:
57-
path: co # test that things working isn’t just a coincident of PWD == BREKWIT_DIR
58-
- uses: pkgxdev/setup@v2
59+
path: co # test that things working isn’t just a coincident of PWD == BREKWIT_DIR
60+
- uses: pkgxdev/setup@v4
5961
- uses: ./co/download-build-artifact
6062
with:
6163
pkg: ${{ needs.build.outputs.pkg }}
@@ -74,11 +76,12 @@ jobs:
7476
- macos-latest
7577
env:
7678
PKGX_PANTRY_PATH: ${{github.workspace}}/co
79+
PKGX_PANTRY_DIR: ${{github.workspace}}/co
7780
steps:
7881
- uses: actions/checkout@v4
7982
with:
80-
path: co # test that things working isn’t just a coincident of PWD == BREKWIT_DIR
81-
- uses: pkgxdev/setup@v2
83+
path: co # test that things working isn’t just a coincident of PWD == BREKWIT_DIR
84+
- uses: pkgxdev/setup@v4
8285
- uses: ./co/download-build-artifact
8386
with:
8487
pkg: ${{ needs.build.outputs.pkg }}
@@ -97,12 +100,13 @@ jobs:
97100
- linux+x86-64
98101
env:
99102
PKGX_PANTRY_PATH: ${{github.workspace}}/co
103+
PKGX_PANTRY_DIR: ${{github.workspace}}/co
100104
steps:
101105
- uses: actions/checkout@v4
102106
with:
103-
path: co # test that things working isn’t just a coincident of PWD == BREKWIT_DIR
107+
path: co # test that things working isn’t just a coincident of PWD == BREKWIT_DIR
104108

105-
- uses: pkgxdev/setup@v2
109+
- uses: pkgxdev/setup@v4
106110

107111
- uses: ./co/download-build-artifact
108112
id: dl
@@ -119,21 +123,22 @@ jobs:
119123

120124
- uses: actions/upload-artifact@v4
121125
with:
122-
path: ${{ steps.bottle.outputs.filename }}
123-
name: ${{ steps.bottle.outputs.name }}
126+
path: ${{ steps.bottle.outputs.filename }}
127+
name: ${{ steps.bottle.outputs.name }}
124128

125129
unavailable:
126130
runs-on: ubuntu-latest
127131
steps:
128132
- uses: actions/checkout@v4
129-
- uses: pkgxdev/setup@v2
133+
- uses: pkgxdev/setup@v4
130134

131135
- uses: ./build
132136
id: build
133137
with:
134138
pkg: unavailable.com
135139
env:
136140
PKGX_PANTRY_PATH: ${{github.workspace}}
141+
PKGX_PANTRY_DIR: ${{github.workspace}}
137142

138143
- run: echo ${{steps.build.outputs.noop}}
139144

@@ -143,18 +148,20 @@ jobs:
143148
id:
144149
env:
145150
PKGX_PANTRY_PATH: ${{github.workspace}}
151+
PKGX_PANTRY_DIR: ${{github.workspace}}
146152
runs-on: ubuntu-latest
147153
outputs:
148154
pkgs: ${{ steps.id.outputs.pkgs }}
149155
steps:
150156
- uses: actions/checkout@v4
151-
- uses: pkgxdev/setup@v2
157+
- uses: pkgxdev/setup@v4
152158
- uses: ./id
153159
id: id
154160
with:
155161
pkg: stark.com/foo
156162
env:
157163
PKGX_PANTRY_PATH: ${{github.workspace}}
164+
PKGX_PANTRY_DIR: ${{github.workspace}}
158165
- run: test ${{ steps.id.outputs.version }} = 2.3.4
159166
- run: test ${{ steps.id.outputs.version-raw }} = 2.3.4
160167
- run: test -z "${{ steps.id.outputs.version-tag }}"

.github/workflows/ci.cli.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
env:
66
GITHUB_TOKEN: ${{github.token}}
77
PKGX_PANTRY_PATH: ${{github.workspace}}
8+
PKGX_PANTRY_DIR: ${{github.workspace}}
89

910
jobs:
1011
integration-tests:
@@ -34,7 +35,7 @@ jobs:
3435
container: ${{ matrix.platform.img }}
3536
steps:
3637
- uses: actions/checkout@v4
37-
- uses: pkgxdev/setup@v2
38+
- uses: pkgxdev/setup@v4
3839

3940
# otherwise, we're getting some weird race conditions on CI
4041
- run: pkgx --sync
@@ -47,7 +48,7 @@ jobs:
4748
runs-on: ubuntu-latest
4849
steps:
4950
- uses: actions/checkout@v4
50-
- uses: pkgxdev/setup@v2
51+
- uses: pkgxdev/setup@v4
5152
- uses: ./.github/modify-pantry
5253
- run: test $(bin/bk status) = stark.com/foo
5354
- run: bin/bk build
@@ -61,6 +62,7 @@ jobs:
6162
runs-on: ubuntu-latest
6263
env:
6364
PKGX_PANTRY_PATH: null
65+
PKGX_PANTRY_DIR: null
6466
steps:
6567
- uses: actions/checkout@v4
6668
- uses: pkgxdev/dev@v1
@@ -71,7 +73,7 @@ jobs:
7173
runs-on: ubuntu-latest
7274
steps:
7375
- uses: actions/checkout@v4
74-
- uses: pkgxdev/setup@v2
76+
- uses: pkgxdev/setup@v4
7577
- run: pkgx --sync # FIXME PKGX_PANTRY_PATH causes auto sync to fail
7678
- name: build
7779
run: |

audit/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ inputs:
55
description: |
66
* eg. pkgx.sh@1.1
77
* if unset uses `$BREWKIT_PKGSPEC`
8-
* if unset checks for modifications in `$PKGX_PANTRY_PATH`
8+
* if unset checks for modifications in `$PKGX_PANTRY_PATH || $PKGX_PANTRY_DIR`
99
required: false
1010
token:
1111
default: ${{ github.token }}

bin/bk-docker

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ if [ -n "$VERBOSE" ]; then
1414
set -x
1515
fi
1616

17+
# name changed in v2
18+
export PKGX_PANTRY_PATH="${PKGX_PANTRY_PATH:-$PKGX_PANTRY_DIR}"
19+
1720
if [ ! -d "$PKGX_PANTRY_PATH" ]; then
1821
echo "error: \`brewkit docker\` can only be run from a pantry checkout" >&2
1922
exit 64

bin/bk-edit

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
set -eo pipefail
44

55
d="$(cd "$(dirname "$0")/.." && pwd)"
6+
# name changed in v2
7+
export PKGX_PANTRY_PATH="${PKGX_PANTRY_PATH:-$PKGX_PANTRY_DIR}"
68

79
if [ -z "$1" ]; then
810
if [ -z "$PKGX_PANTRY_PATH" ]; then

bin/bk-init

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
set -eo pipefail
55

6+
# name changed in v2
7+
export PKGX_PANTRY_PATH="${PKGX_PANTRY_PATH:-$PKGX_PANTRY_DIR}"
8+
69
if test -z "$PKGX_PANTRY_PATH"; then
710
echo "error: PKGX_PANTRY_PATH is not set" >&2
811
exit 1

bin/bk-status

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/usr/bin/env -S pkgx +git +column bash -eo pipefail
22
# shellcheck shell=bash
33

4+
# name changed in v2
5+
export PKGX_PANTRY_PATH="${PKGX_PANTRY_PATH:-$PKGX_PANTRY_DIR}"
6+
47
GIT_DIR="$PKGX_PANTRY_PATH"
58

69
if ! d="$(git rev-parse --show-toplevel 2>/dev/null)"; then

build/action.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ runs:
5454
5555
- name: build
5656
run: |
57-
if [ -d projects -a -z "$PKGX_PANTRY_PATH" ]; then
57+
if [ -d projects -a -z "$PKGX_PANTRY_PATH" -a -z "$PKGX_PANTRY_DIR" ]; then
5858
export PKGX_PANTRY_PATH="$PWD/projects"
59+
export PKGX_PANTRY_DIR="$PWD/projects"
5960
fi
6061
6162
set +e

build/build.ts

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ await rsync(config.path.yaml.parent(), config.path.build.join("props"))
8181
// }), force: true })
8282

8383
/// create toolchain if necessary
84-
const toolchain_PATH = make_toolchain()
84+
const toolchain_PATH = await make_toolchain()
8585

8686
if (toolchain_PATH) {
8787
await gum('toolchain')
@@ -118,6 +118,7 @@ const env: Record<string, string> = {
118118
for (const key of [
119119
'HOME',
120120
'PKGX_PANTRY_PATH', // otherwise we cannot build against the user’s pantry
121+
'PKGX_PANTRY_DIR', // otherwise we cannot build against the user’s pantry - v2
121122
'GITHUB_TOKEN', // pass through for `gh` and that sort of thing
122123
'LANG', 'LOGNAME', 'USER', 'TERM' // prevent POSIX tools from breaking
123124
]) {
@@ -173,7 +174,7 @@ if (ghout) {
173174
}
174175

175176
///////////////////////////////////////////////////////////////////
176-
function make_toolchain() {
177+
async function make_toolchain() {
177178
if (yml?.build?.skip === 'shims' || yml?.build?.skip?.includes?.('shims')) {
178179
return
179180
}
@@ -185,13 +186,33 @@ function make_toolchain() {
185186
const has_llvm = deps.has('llvm.org')
186187
const has_binutils = deps.has('gnu.org/binutils')
187188

189+
// ensure default compiler is installed before creating toolchain symlinks
190+
if (!has_gcc && !has_llvm) {
191+
const rv = await new Deno.Command('pkgx', { args: ['+llvm.org', '--', 'true'] }).output()
192+
if (!rv.success) throw new Error('failed to install default llvm')
193+
}
194+
188195
// rm ∵ // https://github.com/pkgxdev/brewkit/issues/303
189196
const d = config.path.home.join('toolchain').rm({ recursive: true }).mkdir('p')
190197
const prefix = useConfig().prefix
191198

192-
const llvm = (bin: string) => prefix.join('llvm.org/v*/bin', bin)
193-
const gcc = (bin: string) => prefix.join('gnu.org/gcc/v*/bin', bin)
194-
const binutils = (bin: string) => prefix.join('gnu.org/binutils/v*/bin', bin)
199+
const dep_bin = (project: string, bin: string): Path => {
200+
const dep = config.deps.gas.find(x => x.pkg.project === project)
201+
if (dep) return dep.path.join('bin', bin)
202+
// fallback: resolve from installed versions
203+
const dir = prefix.join(project)
204+
if (dir.isDirectory()) {
205+
const versions = [...Deno.readDirSync(dir.string)]
206+
.filter(e => e.isDirectory && e.name.startsWith('v'))
207+
.sort((a, b) => a.name.localeCompare(b.name, undefined, { numeric: true }))
208+
if (versions.length) return dir.join(versions.at(-1)!.name, 'bin', bin)
209+
}
210+
throw new Error(`cannot find ${project} installation`)
211+
}
212+
213+
const llvm = (bin: string) => dep_bin('llvm.org', bin)
214+
const gcc = (bin: string) => dep_bin('gnu.org/gcc', bin)
215+
const binutils = (bin: string) => dep_bin('gnu.org/binutils', bin)
195216

196217
const symlink = (names: string[], target: Path) => {
197218
for (const name of names) {

lib/config.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ export default async function config(arg?: string): Promise<Config> {
4747
pantry = pantry.parent()
4848
}
4949

50-
if (Deno.env.get("PKGX_PANTRY_PATH")) {
51-
const checkout = new Path(Deno.env.get("PKGX_PANTRY_PATH")!)
50+
// env key changed in pkgx-v2
51+
if (Deno.env.get("PKGX_PANTRY_DIR") || Deno.env.get("PKGX_PANTRY_PATH")) {
52+
const checkout = new Path((Deno.env.get("PKGX_PANTRY_DIR") || Deno.env.get("PKGX_PANTRY_PATH"))!)
5253
const slug = pkg.project.replace(/\//g, "__") //FIXME use real folders probs
5354
const pkgspec = `${slug}-${pkg.version}`
5455
return await construct_config({

0 commit comments

Comments
 (0)