build.ts only deps on deno

prevents dep injection
This commit is contained in:
Max Howell 2022-11-30 15:18:05 -05:00
parent d617f2e3b1
commit d9be5a35f9
5 changed files with 29 additions and 12 deletions

View file

@ -153,6 +153,7 @@ jobs:
- run: tea.xyz/var/pantry/scripts/test.ts ${{ inputs.projects }}
bottle:
name: ${{ matrix.name }}
needs: [test, build]
if: ${{ inputs.upload }}
runs-on: ${{ matrix.platform.os }}
@ -163,11 +164,15 @@ jobs:
matrix:
platform:
- os: macos-11
name: darwin+x86-64
- os: ubuntu-latest
name: linux+x86-64
- os: [self-hosted, macOS, ARM64]
tag: darwin-aarch64
name: darwin+aarch64
- os: [self-hosted, linux, ARM64]
tag: linux-aarch64
name: linux+aarch64
steps:
- uses: actions/checkout@v3
with:

View file

@ -1,10 +1,6 @@
#!/usr/bin/env -S tea -E
/*---
dependencies:
gnu.org/tar: 1
tukaani.org/xz: 5
sourceware.org/bzip2: 1
args:
- deno
- run

View file

@ -1,10 +1,6 @@
#!/usr/bin/env -S tea -E
/*---
dependencies:
gnu.org/tar: 1
tukaani.org/xz: 5
sourceware.org/bzip2: 1
args:
- deno
- run

View file

@ -6,7 +6,6 @@ import { run, undent, host, tuplize } from "utils"
import { str as pkgstr } from "utils/pkg.ts"
import fix_pkg_config_files from "./fix-pkg-config-files.ts"
import Path from "path"
import { fetch_src } from "../fetch.ts";
const cellar = useCellar()
const pantry = usePantry()
@ -142,3 +141,18 @@ async function __build(pkg: Package): Promise<BuildResult> {
}
}
}
async function fetch_src(pkg: Package): Promise<[Path, Path]> {
console.log('fetching', pkgstr(pkg))
// we run this as a script because we dont want these deps imported into *this* env
// since that leads to situations where we depend on things we didnt expect to
const script = new URL(import.meta.url).path().parent().parent().join('fetch.ts')
const proc = Deno.run({
cmd: [script.string, pkgstr(pkg)],
stdout: 'piped'
})
const out = await proc.output()
const [dstdir, tarball] = new TextDecoder().decode(out).split("\n")
return [new Path(dstdir), new Path(tarball)]
}

View file

@ -1,6 +1,10 @@
#!/usr/bin/env -S tea -E
/*---
dependencies:
gnu.org/tar: 1
tukaani.org/xz: 5
sourceware.org/bzip2: 1
args:
- deno
- run
@ -14,12 +18,14 @@ args:
//TODO verify the sha
import { usePantry, useCache, useDownload, useCellar, useSourceUnarchiver, useOffLicense } from "hooks"
import { usePantry, useCache, useDownload, useCellar, useSourceUnarchiver, useOffLicense, useFlags} from "hooks"
import { panic, print } from "utils"
import { Stowage, Package } from "types"
import * as ARGV from "./utils/args.ts"
import Path from "path"
useFlags()
const pantry = usePantry()
const { download } = useDownload()
@ -47,7 +53,7 @@ export async function fetch_src(pkg: Package): Promise<[Path, Path] | undefined>
if (import.meta.main) {
for await (let pkg of ARGV.pkgs()) {
pkg = await pantry.resolve(pkg)
const [dstdir] = await fetch_src(pkg) ?? panic()
await print(`${dstdir}\n`)
const rv = await fetch_src(pkg) ?? panic()
await print(rv.join("\n") + "\n")
}
}