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