Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions .github/workflows/ci.cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ jobs:
- pyapp.com/2
- stark.com/foo@1.2.3
- git-clone.com
- pc-cmake.com

runs-on: ${{ matrix.platform.os }}
container: ${{ matrix.platform.img }}
steps:
Expand Down Expand Up @@ -78,13 +80,3 @@ jobs:
set +e
bin/bk build unavailable.com
test $? -eq 2

fix-up:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pkgxdev/setup@v2
- run: pkgx --sync
- run: bin/bk build pc-cmake.com
- run: bin/bk test pc-cmake.com
- run: bin/bk audit pc-cmake.com
4 changes: 2 additions & 2 deletions bin/cmd/build
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const yml = YAML.parse(await config.path.yaml.read()) as any

/// fetch
await gum('fetch & extract')
let fetched: undefined | 'git' | 'tarball'
let fetched: Path | 'git' | 'tarball' | undefined
if (yml.distributable) {
fetched = await fetch(config)
} else {
Expand Down Expand Up @@ -100,7 +100,7 @@ const env: Record<string, string> = {
PATH: '/usr/bin:/bin:/usr/sbin:/sbin',
PKGX_DIR: useConfig().prefix.string
}
for (const key of ['HOME', 'PKGX_PANTRY_PATH', 'XDG_DATA_HOME', 'GITHUB_TOKEN']) {
for (const key of ['HOME', 'PKGX_PANTRY_PATH', 'XDG_DATA_HOME', 'GITHUB_TOKEN', 'LANG', 'LOGNAME', 'USER']) {
const value = Deno.env.get(key)
if (value) env[key] = value
}
Expand Down
4 changes: 2 additions & 2 deletions bin/cmd/test
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const gum_ = find_in_PATH('gum')
const depstr = (deps: (PackageRequirement | Package)[]) => deps.map(x => `"+${utils.pkg.str(x)}"`).join(' ')
const env_plus = `${depstr([config.pkg])} ${depstr(config.deps.dry.runtime)} ${depstr(config.deps.dry.test)}`.trim()

const user_script = await usePantry().getScript(config.pkg, 'test', config.deps.gas, config.path.install)
const user_script = await usePantry().getScript(config.pkg, 'test', config.deps.gas, config)

const script_text = undent`
#!${bash}
Expand Down Expand Up @@ -87,7 +87,7 @@ script.write({ force: true, text: script_text }).chmod(0o755)
await gum("test")

const env: Record<string, string> = {PATH: '/usr/bin:/bin:/usr/sbin:/sbin'}
for (const key of ['HOME', 'PKGX_PANTRY_PATH', 'XDG_DATA_HOME', 'GITHUB_TOKEN']) {
for (const key of ['HOME', 'PKGX_PANTRY_PATH', 'XDG_DATA_HOME', 'GITHUB_TOKEN', 'LANG', 'LOGNAME', 'USER']) {
const value = Deno.env.get(key)
if (value) env[key] = value
}
Expand Down
19 changes: 14 additions & 5 deletions lib/hooks/usePantry.getScript.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import useConfig from "libpkgx/hooks/useConfig.ts"
import usePkgxConfig from "libpkgx/hooks/useConfig.ts"
import { Config as BrewkitConfig } from "brewkit/config.ts"
import { SupportedPlatforms, SupportedArchitectures } from "libpkgx/utils/host.ts"
import { isArray, isString, isPlainObject, PlainObject, isPrimitive, isBoolean, isNumber } from "is-what"
import { Package, Installation, hooks, utils, semver, Path, PantryParseError } from "libpkgx"
Expand All @@ -7,19 +8,27 @@ import undent from "outdent"
const { validate, host } = utils
const { useMoustaches } = hooks

export const getScript = async (pkg: Package, key: 'build' | 'test', deps: Installation[], install_prefix: Path) => {
export const getScript = async (pkg: Package, key: 'build' | 'test', deps: Installation[], config: BrewkitConfig) => {
const install_path = key == 'build' ? config.path.build_install : config.path.install
const yml = await hooks.usePantry().project(pkg).yaml()
const node = yml[key]

const mm = useMoustaches()
const tokens = mm.tokenize.all(pkg, deps)
tokens.push({
from: "pkgx.dir", to: useConfig().prefix.string
from: "pkgx.dir", to: usePkgxConfig().prefix.string
})
if (key == 'build') {
tokens.push({
from: "srcroot", to: config.path.build.string
}, {
from: "props", to: config.path.build.join("props").string
})
}

for (const [index, token] of tokens.entries()) {
if (token.from == "prefix") {
tokens[index] = { from: "prefix", to: install_prefix.string }
tokens[index] = { from: "prefix", to: install_path.string }
}
}

Expand Down Expand Up @@ -87,7 +96,7 @@ export const getScript = async (pkg: Package, key: 'build' | 'test', deps: Insta
const rv = []
for (const token of tokens) {
if (token.from == "prefix") {
rv.push({from: "prefix", to: install_prefix.string})
rv.push({from: "prefix", to: install_path.string})
} else {
rv.push(token)
}
Expand Down
4 changes: 2 additions & 2 deletions lib/porcelain/build-script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const { host } = utils
export default async function(config: Config, PATH?: Path): Promise<string> {
const depstr = (deps: PackageRequirement[]) => deps.map(x => `"+${utils.pkg.str(x)}"`).join(' ')
const env_plus = `${depstr(config.deps.dry.runtime)} ${depstr(config.deps.dry.build)}`.trim()
const user_script = await usePantry().getScript(config.pkg, 'build', config.deps.gas, config.path.build_install)
const user_script = await usePantry().getScript(config.pkg, 'build', config.deps.gas, config)

const pkgx = find_in_PATH('pkgx')
const bash = find_in_PATH('bash')
Expand Down Expand Up @@ -45,7 +45,7 @@ export default async function(config: Config, PATH?: Path): Promise<string> {
export FORCE_UNSAFE_CONFIGURE=1
fi
mkdir -p $HOME
${FLAGS.join('\n')}
${FLAGS.join('\n ')}

env -u GH_TOKEN -u GITHUB_TOKEN

Expand Down
8 changes: 7 additions & 1 deletion projects/stark.com/foo/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ build:
- test "$SRCROOT" = "$PWD"

# verify GNU sed (doesn’t require a backup file)
- sed -i s/sup_bro/sup_unc/g props/package.yml
- sed -i s/sup_bro/sup_unc/g {{props}}/package.yml

- |
test {{props}} = $PWD/props
test {{srcroot}} = $SRCROOT
test {{srcroot}} = $PWD
test -d {{pkgx.dir}}

# verify pkgx is not here
- |
Expand Down