mirror of
https://github.com/ivabus/pantry
synced 2024-11-26 02:15:06 +03:00
getting there (#144)
This commit is contained in:
parent
746f2f16f3
commit
a5ff99c5e3
7 changed files with 55 additions and 61 deletions
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
|
@ -56,7 +56,7 @@ jobs:
|
|||
mkdir .git ../cli/.git
|
||||
|
||||
#FIXME needed for gdk-pixbuf
|
||||
apt --yes install shared-mime-info
|
||||
apt --yes install shared-mime-info curl
|
||||
;;
|
||||
macos-11)
|
||||
# screws up a lot of build scripts
|
||||
|
|
|
@ -29,22 +29,21 @@ build:
|
|||
--prefix="{{ prefix }}"
|
||||
make --jobs {{ hw.concurrency }} install
|
||||
|
||||
cd "{{prefix}}"/bin
|
||||
cd "{{prefix}}"
|
||||
|
||||
fix-shebangs.ts *
|
||||
fix-shebangs.ts bin/*
|
||||
|
||||
perl -pi -e 's|\x27{{prefix}}|"\$PREFIX"\x27|g' ./autoconf
|
||||
perl -pi -e 's|\x27{{prefix}}|"\$PREFIX"\x27|g' bin/autoconf
|
||||
|
||||
# fix specific m4 and perl paths
|
||||
perl -pi -e 's|/opt/perl.org/v[^/]+/bin/perl|perl|g' *
|
||||
perl -pi -e 's|/opt/gnu.org/m4/v[^/]+/bin/m4|m4|g' *
|
||||
perl -pi -e 's|{{ deps.perl.org.prefix }}/bin/perl|perl|g' bin/*
|
||||
perl -pi -e 's|{{ deps.gnu.org/m4.prefix }}/bin/m4|m4|g' bin/*
|
||||
|
||||
# fix hardcoded paths
|
||||
perl -pi -e "s|'{{prefix}}/|\\\$prefix.'/|" *
|
||||
git -C .. apply {{ pkg.pantry-prefix }}/relocatable.diff
|
||||
perl -pi -e "s|'{{prefix}}/|\\\$prefix.'/|" bin/*
|
||||
git apply $SRCROOT/props/relocatable.diff
|
||||
|
||||
cd ../share/autoconf
|
||||
perl -pi -e 's|{{prefix}}|\$PREFIX|' autom4te.cfg
|
||||
perl -pi -e 's|{{prefix}}|\$PREFIX|' share/autoconf/autom4te.cfg
|
||||
|
||||
test:
|
||||
dependencies:
|
||||
|
|
|
@ -25,13 +25,13 @@ build:
|
|||
--prefix="{{ prefix }}"
|
||||
make --jobs {{ hw.concurrency }} install
|
||||
|
||||
cd "{{prefix}}"/bin
|
||||
cd "{{prefix}}"
|
||||
|
||||
# fix hardcoded paths
|
||||
perl -pi -e "s|'{{prefix}}/|\\\$prefix.'/|" * ../share/automake-{{version.marketing}}/Automake/Config.pm
|
||||
git -C .. apply {{ pkg.pantry-prefix }}/relocatable.diff
|
||||
perl -pi -e "s|'{{prefix}}/|\\\$prefix.'/|" bin/* share/automake-{{version.marketing}}/Automake/Config.pm
|
||||
git apply "$SRCROOT"/props/relocatable.diff
|
||||
|
||||
fix-shebangs.ts *
|
||||
fix-shebangs.ts bin/*
|
||||
|
||||
# TODO to prove automake doesn't require autoconf we should
|
||||
# use “depend” on the autoconf test to generate our `configure` separately
|
||||
|
|
|
@ -48,6 +48,6 @@ for (const rq of dry) {
|
|||
}
|
||||
}
|
||||
|
||||
const built_pkgs = rv.map(({ project, version }) => `${project}@${version}`).join(" ")
|
||||
const built_pkgs = rv.map(pkgutils.str).join(" ")
|
||||
const txt = `::set-output name=pkgs::${built_pkgs}\n`
|
||||
await Deno.stdout.write(new TextEncoder().encode(txt))
|
||||
|
|
|
@ -2,7 +2,7 @@ import { useSourceUnarchiver, useCellar, usePantry, useCache, usePrefix } from "
|
|||
import { link, hydrate } from "prefab"
|
||||
import { Installation, Package } from "types"
|
||||
import useShellEnv, { expand } from "hooks/useShellEnv.ts"
|
||||
import { run, undent, host, pkg as pkgutils } from "utils"
|
||||
import { run, undent, host, tuplize } from "utils"
|
||||
import fix_pkg_config_files from "./fix-pkg-config-files.ts"
|
||||
import fix_linux_rpaths from "./fix-linux-rpaths.ts"
|
||||
import Path from "path"
|
||||
|
@ -16,13 +16,13 @@ export default async function _build(pkg: Package) {
|
|||
try {
|
||||
await __build(pkg)
|
||||
} catch (e) {
|
||||
cellar.keg(pkg).isEmpty()?.rm() // don’t leave empty kegs around
|
||||
cellar.keg(pkg).isDirectory()?.isEmpty()?.rm() // don’t leave empty kegs around
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
async function __build(pkg: Package) {
|
||||
const [deps, wet] = await calc_deps()
|
||||
const [deps, wet, resolved] = await calc_deps()
|
||||
await clean()
|
||||
const env = await mkenv()
|
||||
const dst = cellar.keg(pkg).mkpath()
|
||||
|
@ -38,9 +38,8 @@ async function __build(pkg: Package) {
|
|||
const deps = await pantry.getDeps(pkg)
|
||||
const wet = await hydrate([...deps.runtime, ...deps.build], pkg => pantry.getDeps(pkg).then(x => x.runtime))
|
||||
deps.runtime.push(...wet.pkgs)
|
||||
// deno-lint-ignore no-explicit-any
|
||||
function tuplize<T extends any[]>(...elements: T) { return elements }
|
||||
return tuplize(deps, wet)
|
||||
const resolved = await Promise.all(wet.pkgs.map(pkg => cellar.resolve(pkg)))
|
||||
return tuplize(deps, wet, resolved)
|
||||
}
|
||||
|
||||
async function clean() {
|
||||
|
@ -66,13 +65,8 @@ async function __build(pkg: Package) {
|
|||
}
|
||||
}
|
||||
|
||||
async function mkenv() {
|
||||
const env = await useShellEnv([...deps.runtime, ...deps.build])
|
||||
|
||||
if (env.pending.length) {
|
||||
console.error({uninstalled: env.pending.map(pkgutils.str)})
|
||||
throw new Error("uninstalled")
|
||||
}
|
||||
function mkenv() {
|
||||
const env = useShellEnv(resolved)
|
||||
|
||||
if (platform == 'darwin') {
|
||||
env.vars['MACOSX_DEPLOYMENT_TARGET'] = ['11.0']
|
||||
|
@ -82,7 +76,7 @@ async function __build(pkg: Package) {
|
|||
}
|
||||
|
||||
async function build() {
|
||||
const sh = await pantry.getScript(pkg, 'build')
|
||||
const sh = await pantry.getScript(pkg, 'build', resolved)
|
||||
|
||||
const cmd = src.parent().join("build.sh").write({ force: true, text: undent`
|
||||
#!/bin/bash
|
||||
|
@ -92,6 +86,7 @@ async function __build(pkg: Package) {
|
|||
set -x
|
||||
cd "${src}"
|
||||
|
||||
export SRCROOT="${src}"
|
||||
${expand(env.vars)}
|
||||
|
||||
${/*FIXME hardcoded paths*/ ''}
|
||||
|
@ -101,6 +96,13 @@ async function __build(pkg: Package) {
|
|||
`
|
||||
}).chmod(0o500)
|
||||
|
||||
// copy in auxillary files from pantry directory
|
||||
for await (const [path, {isFile}] of pantry.prefix(pkg).ls()) {
|
||||
if (isFile) {
|
||||
path.cp({ into: src.join("props").mkdir() })
|
||||
}
|
||||
}
|
||||
|
||||
await run({ cmd }) // THE BUILD
|
||||
|
||||
return { path: dst, pkg }
|
||||
|
@ -112,7 +114,7 @@ async function __build(pkg: Package) {
|
|||
await fix_macho(installation)
|
||||
break
|
||||
case 'linux': {
|
||||
const self = {project: pkg.project, constraint: new semver.Range(`=${pkg.version}`)}
|
||||
const self = {project: pkg.project, constraint: new semver.Range(pkg.version.toString())}
|
||||
await fix_linux_rpaths(installation, [...deps.runtime, self])
|
||||
}}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ const wet = await hydrate(dry, async (pkg, dry) => {
|
|||
const gas = wet.dry.map(x => x.project)
|
||||
|
||||
if (Deno.env.get("GITHUB_ACTIONS")) {
|
||||
const pre = wet.wet.map(pkg.str)
|
||||
const pre = wet.wet.map(x => `"${pkg.str(x)}"`)
|
||||
console.log(`::set-output name=pkgs::${gas.join(" ")}`)
|
||||
console.log(`::set-output name=pre-install::${pre.join(" ")}`)
|
||||
} else if (flags.json) {
|
||||
|
|
|
@ -12,40 +12,29 @@ args:
|
|||
- --import-map={{ srcroot }}/import-map.json
|
||||
---*/
|
||||
|
||||
import { PackageRequirement } from "types"
|
||||
import { Installation, Package, PackageRequirement } from "types"
|
||||
import { usePantry, useCellar, useFlags } from "hooks"
|
||||
import useShellEnv, { expand } from "hooks/useShellEnv.ts"
|
||||
import { run, undent, pkg as pkgutils } from "utils"
|
||||
import { resolve, install, hydrate, link } from "prefab"
|
||||
import Path from "path"
|
||||
import * as semver from "semver"
|
||||
|
||||
const { debug } = useFlags()
|
||||
const cellar = useCellar()
|
||||
const pantry = usePantry()
|
||||
|
||||
const pkg = await (async () => {
|
||||
const self = await (async () => {
|
||||
const project = Deno.args[0]
|
||||
const match = project.match(/projects\/(.+)\/package.yml/)
|
||||
const parsable = match ? match[1] : project
|
||||
const pkg = pkgutils.parse(parsable)
|
||||
const installed = await cellar.resolve(pkg)
|
||||
return installed.pkg
|
||||
return await cellar.resolve(pkg)
|
||||
})()
|
||||
|
||||
const self = {
|
||||
project: pkg.project,
|
||||
constraint: new semver.Range(pkg.version.toString())
|
||||
}
|
||||
const [yml] = await pantry.getYAML(pkg)
|
||||
const deps = (await hydrate(self, async (pkg, dry) => {
|
||||
const { runtime, test } = await pantry.getDeps(pkg)
|
||||
return dry ? [...runtime, ...test] : runtime
|
||||
})).pkgs
|
||||
|
||||
await install_if_needed(deps)
|
||||
|
||||
const env = await useShellEnv([self, ...deps])
|
||||
const [yml] = await pantry.getYAML(self.pkg)
|
||||
const deps = await deps4(self.pkg)
|
||||
const installations = await prepare(deps)
|
||||
const env = useShellEnv([self, ...installations])
|
||||
|
||||
let text = undent`
|
||||
#!/bin/bash
|
||||
|
@ -58,7 +47,7 @@ let text = undent`
|
|||
|
||||
`
|
||||
|
||||
const tmp = Path.mktmp({ prefix: `${pkg.project}-${pkg.version}+` })
|
||||
const tmp = Path.mktmp({ prefix: pkgutils.str(self.pkg) })
|
||||
|
||||
try {
|
||||
if (yml.test.fixture) {
|
||||
|
@ -70,10 +59,10 @@ try {
|
|||
|
||||
text += `cd "${cwd}"\n\n`
|
||||
|
||||
text += await pantry.getScript(pkg, 'test')
|
||||
text += await pantry.getScript(self.pkg, 'test', installations)
|
||||
text += "\n"
|
||||
|
||||
for await (const [path, {name, isFile}] of pantry.prefix(pkg).ls()) {
|
||||
for await (const [path, {name, isFile}] of pantry.prefix(self.pkg).ls()) {
|
||||
if (isFile && name != 'package.yml') path.cp({ into: cwd })
|
||||
}
|
||||
|
||||
|
@ -86,16 +75,20 @@ try {
|
|||
if (!debug) tmp.rm({ recursive: true })
|
||||
}
|
||||
|
||||
//TODO install step should do this for test requirements also
|
||||
async function install_if_needed(deps: PackageRequirement[]) {
|
||||
const needed: PackageRequirement[] = []
|
||||
for await (const rq of deps) {
|
||||
if (await cellar.has(rq)) continue
|
||||
needed.push(rq)
|
||||
}
|
||||
const wet = await resolve(needed)
|
||||
for (const pkg of wet) {
|
||||
//TODO install step in CI should do this for test requirements also
|
||||
async function prepare(reqs: (Package | PackageRequirement)[]) {
|
||||
const { pending, installed } = await resolve(reqs)
|
||||
for await (const pkg of pending) {
|
||||
const installation = await install(pkg)
|
||||
await link(installation)
|
||||
installed.push(installation)
|
||||
}
|
||||
return installed
|
||||
}
|
||||
|
||||
async function deps4(pkg: Package) {
|
||||
return (await hydrate(pkg, async (pkg, dry) => {
|
||||
const { runtime, test } = await pantry.getDeps(pkg)
|
||||
return dry ? [...runtime, ...test] : runtime
|
||||
})).pkgs
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue