mirror of
https://github.com/ivabus/pantry
synced 2024-11-27 02:35:08 +03:00
Relax requirement to build to /opt (#19)
Improve README somewhat. Don’t overlay files into pantry, use `TEA_PANTRY_PATH` instead. Requires tea/cli 0.11.6 for `env` key in YAML-FM
This commit is contained in:
parent
c160f4f6d7
commit
eb1c8e5aee
10 changed files with 60 additions and 85 deletions
59
.github/workflows/build.yml
vendored
59
.github/workflows/build.yml
vendored
|
@ -1,4 +1,5 @@
|
||||||
name: build
|
name: build
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_call:
|
workflow_call:
|
||||||
inputs:
|
inputs:
|
||||||
|
@ -10,6 +11,9 @@ on:
|
||||||
type: boolean
|
type: boolean
|
||||||
default: false
|
default: false
|
||||||
|
|
||||||
|
env:
|
||||||
|
TEA_PANTRY_PATH: ${{ github.workspace }}/pantry
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
@ -41,11 +45,11 @@ jobs:
|
||||||
with:
|
with:
|
||||||
path: cli
|
path: cli
|
||||||
repository: teaxyz/cli
|
repository: teaxyz/cli
|
||||||
token: ${{ secrets.TEMP_JACOBS_GITHUB_PAT }}
|
|
||||||
|
|
||||||
- uses: teaxyz/setup@v0
|
- uses: teaxyz/setup@v0
|
||||||
id: tea
|
id: tea
|
||||||
with:
|
with:
|
||||||
|
# necessary because we currently require a `.git` directory
|
||||||
srcroot: /opt/tea.xyz/var/pantry
|
srcroot: /opt/tea.xyz/var/pantry
|
||||||
prefix: /opt
|
prefix: /opt
|
||||||
|
|
||||||
|
@ -64,22 +68,14 @@ jobs:
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
- run: |
|
ln -s $GITHUB_WORKSPACE/cli /opt/tea.xyz/var/cli
|
||||||
find $GITHUB_WORKSPACE/pantry \
|
|
||||||
-not -type l \
|
|
||||||
-mindepth 1 \
|
|
||||||
-maxdepth 1 \
|
|
||||||
-print0 | \
|
|
||||||
xargs -0 -I{} cp -Rv {} /opt/tea.xyz/var/pantry
|
|
||||||
cp -a cli /opt/tea.xyz/var/
|
|
||||||
|
|
||||||
- run: /opt/tea.xyz/var/pantry/scripts/sort.ts ${{ inputs.projects }}
|
- run: /opt/tea.xyz/var/pantry/scripts/sort.ts ${{ inputs.projects }}
|
||||||
id: sorted
|
id: sorted
|
||||||
|
|
||||||
- run: cli/scripts/install.ts ${{ steps.sorted.outputs.pre-install }}
|
- run: cli/scripts/install.ts ${{ steps.sorted.outputs.pre-install }}
|
||||||
|
|
||||||
- run: cat /opt/tea.xyz/var/pantry/projects/zlib.net/package.yml
|
# running out of /opt because only pantry.core has these scripts
|
||||||
|
|
||||||
- run: /opt/tea.xyz/var/pantry/scripts/build.ts ${{ steps.sorted.outputs.pkgs }}
|
- run: /opt/tea.xyz/var/pantry/scripts/build.ts ${{ steps.sorted.outputs.pkgs }}
|
||||||
id: build
|
id: build
|
||||||
env:
|
env:
|
||||||
|
@ -123,18 +119,12 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
path: pantry
|
path: tea.xyz/var/cli
|
||||||
|
repository: teaxyz/cli
|
||||||
|
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
path: tea.xyz/var/cli
|
path: pantry
|
||||||
repository: teaxyz/cli
|
|
||||||
token: ${{ secrets.TEMP_JACOBS_GITHUB_PAT }}
|
|
||||||
|
|
||||||
- run: |
|
|
||||||
apt-get update
|
|
||||||
apt-get --yes install libc-dev libstdc++-8-dev libgcc-8-dev
|
|
||||||
if: ${{ matrix.container != '' }}
|
|
||||||
|
|
||||||
- uses: teaxyz/setup@v0
|
- uses: teaxyz/setup@v0
|
||||||
id: tea
|
id: tea
|
||||||
|
@ -142,14 +132,10 @@ jobs:
|
||||||
srcroot: tea.xyz/var/pantry
|
srcroot: tea.xyz/var/pantry
|
||||||
prefix: ${{ github.workspace }}
|
prefix: ${{ github.workspace }}
|
||||||
|
|
||||||
- name: overlay our pantry
|
- run: |
|
||||||
run: |
|
apt-get update
|
||||||
find pantry \
|
apt-get --yes install libc-dev libstdc++-8-dev libgcc-8-dev
|
||||||
-not -type l \
|
if: ${{ matrix.container != '' }}
|
||||||
-mindepth 1 \
|
|
||||||
-maxdepth 1 \
|
|
||||||
-print0 | \
|
|
||||||
xargs -0 -I{} cp -Rv {} tea.xyz/var/pantry
|
|
||||||
|
|
||||||
- uses: actions/download-artifact@v3
|
- uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
|
@ -157,7 +143,6 @@ jobs:
|
||||||
|
|
||||||
- run: tar xzf artifacts.tgz
|
- run: tar xzf artifacts.tgz
|
||||||
|
|
||||||
# script comes from pantry.core, which _might_not_be_this_pantry_
|
|
||||||
- run: tea.xyz/var/pantry/scripts/test.ts ${{ inputs.projects }}
|
- run: tea.xyz/var/pantry/scripts/test.ts ${{ inputs.projects }}
|
||||||
|
|
||||||
bottle:
|
bottle:
|
||||||
|
@ -178,13 +163,12 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
path: pantry
|
path: tea.xyz/var/cli
|
||||||
|
repository: teaxyz/cli
|
||||||
|
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
path: tea.xyz/var/cli
|
path: pantry
|
||||||
repository: teaxyz/cli
|
|
||||||
token: ${{ secrets.TEMP_JACOBS_GITHUB_PAT }}
|
|
||||||
|
|
||||||
- uses: teaxyz/setup@v0
|
- uses: teaxyz/setup@v0
|
||||||
id: tea
|
id: tea
|
||||||
|
@ -192,15 +176,6 @@ jobs:
|
||||||
srcroot: tea.xyz/var/pantry
|
srcroot: tea.xyz/var/pantry
|
||||||
prefix: ${{ github.workspace }}
|
prefix: ${{ github.workspace }}
|
||||||
|
|
||||||
- name: overlay our pantry
|
|
||||||
run: |
|
|
||||||
find $GITHUB_WORKSPACE/pantry \
|
|
||||||
-not -type l \
|
|
||||||
-mindepth 1 \
|
|
||||||
-maxdepth 1 \
|
|
||||||
-print0 | \
|
|
||||||
xargs -0 -I{} cp -Rv {} .
|
|
||||||
|
|
||||||
- uses: actions/download-artifact@v3
|
- uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: ${{ matrix.platform.tag || matrix.platform.os }}
|
name: ${{ matrix.platform.tag || matrix.platform.os }}
|
||||||
|
|
43
README.md
43
README.md
|
@ -16,30 +16,38 @@ At this time pantries are not versioned.
|
||||||
|
|
||||||
# Contributing
|
# Contributing
|
||||||
|
|
||||||
Firstly, clone this repository, you’ll edit files here.
|
Firstly, clone this repository, you’ll edit files here. *Don’t work out of
|
||||||
|
`~/.tea/tea.xyz/var/pantry`, it’s not a git directory!*
|
||||||
|
|
||||||
|
You also must (currently, we know it sucks) clone tea/cli to the same *parent*
|
||||||
|
directory. So you’ll have:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ ls
|
||||||
|
cli
|
||||||
|
pantry.core
|
||||||
|
```
|
||||||
|
|
||||||
|
Keep tea/cli updated, currently there is unversioned revlock between the two.
|
||||||
|
Also you should update your installed tea/cli frequently!)†
|
||||||
|
|
||||||
|
> † `sh <(curl tea.xyz)` updates the installed tea/cli
|
||||||
|
|
||||||
> Note that packages are split across multiple pantries, so to see the
|
> Note that packages are split across multiple pantries, so to see the
|
||||||
> `package.yml` files for all your dependencies you may want to open another
|
> `package.yml` files for all your dependencies you may want to open another
|
||||||
> editor at `~/.tea/tea.xyz/var/pantry`
|
> editor at `~/.tea/tea.xyz/var/pantry`
|
||||||
|
|
||||||
Create new `package.yml` files namespaced as per our current patterns under
|
Create new `package.yml` files namespaced as per our current patterns under
|
||||||
the [`./projects/`] folder.
|
the [`./projects/`] folder. The `package.yml` format is not documented
|
||||||
|
(sorry!), but it is not complex, pick an existing entry for tips.
|
||||||
|
|
||||||
The `package.yml` format is not documented, but it is not complex, pick an
|
You should verify that your package builds before submitting it.
|
||||||
existing entry for tips.
|
|
||||||
|
|
||||||
You should verify that your package builds before submitting it. At this time
|
|
||||||
we require that we build all packages ourselves†. `tea` requires that
|
|
||||||
packages are built to `/opt` to minimize potential build problems. You do not
|
|
||||||
need to install `tea` to opt first, but you may need to make `/opt` writable
|
|
||||||
first (`sudo chmod g+w /opt`).
|
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
export GITHUB_TOKEN=… # you need a (zero permissions) [PAT]
|
export GITHUB_TOKEN=… # you need a (zero permissions) [PAT]
|
||||||
export TEA_PREFIX=/opt
|
|
||||||
export TEA_PANTRY_PATH="$PWD"
|
|
||||||
./scripts/build.ts pkg.com
|
./scripts/build.ts pkg.com
|
||||||
# ^^ you will need to have installed all dependencies *manually* first
|
# ^^ you will need to have installed all dependencies *manually* first
|
||||||
|
# try `scripts/deps.ts -b pkg.com | xargs ../cli/scripts/install.ts`
|
||||||
```
|
```
|
||||||
|
|
||||||
Packages require a `test` YAML node. This script should thoroughly verify all
|
Packages require a `test` YAML node. This script should thoroughly verify all
|
||||||
|
@ -50,14 +58,13 @@ the functionality of the package is working. You can run the test with:
|
||||||
```
|
```
|
||||||
|
|
||||||
tea requires all packages be relocatable. Our CI will verify this for you.
|
tea requires all packages be relocatable. Our CI will verify this for you.
|
||||||
You can check locally by moving the installation from `/opt` to `~/.tea` and
|
You can check locally by moving the installation from `~/.tea` to another tea
|
||||||
running the test again.
|
installation (eg. `~/.tea.build`‡ and running the test again.
|
||||||
|
|
||||||
> † we intend to relax this and accept pre-built binaries from third parties
|
|
||||||
> however we will require third party verification for security reasons.
|
|
||||||
|
|
||||||
Now make a pull request! We’ll test on all platforms we support in the PR. If
|
Now make a pull request! We’ll test on all platforms we support in the PR. If
|
||||||
it passes both CI and review we’ll merge.
|
it passes both CI and review: we’ll merge!
|
||||||
|
|
||||||
|
> ‡ `TEA_PREFIX=~/.tea.build sh <(curl tea.xyz)`
|
||||||
|
|
||||||
## Packaging Guide
|
## Packaging Guide
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,8 @@ args:
|
||||||
- --allow-read
|
- --allow-read
|
||||||
- --allow-write
|
- --allow-write
|
||||||
- --import-map={{ srcroot }}/import-map.json
|
- --import-map={{ srcroot }}/import-map.json
|
||||||
|
env:
|
||||||
|
TEA_PANTRY_PATH: "{{srcroot}}"
|
||||||
--- */
|
--- */
|
||||||
|
|
||||||
import { Installation } from "types"
|
import { Installation } from "types"
|
||||||
|
|
|
@ -14,6 +14,8 @@ args:
|
||||||
- --allow-write={{tea.prefix}}
|
- --allow-write={{tea.prefix}}
|
||||||
- --allow-env
|
- --allow-env
|
||||||
- --import-map={{ srcroot }}/import-map.json
|
- --import-map={{ srcroot }}/import-map.json
|
||||||
|
env:
|
||||||
|
TEA_PANTRY_PATH: "{{srcroot}}"
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
import { usePantry } from "hooks"
|
import { usePantry } from "hooks"
|
||||||
|
@ -21,7 +23,6 @@ import { Installation } from "types"
|
||||||
import { pkg as pkgutils } from "utils"
|
import { pkg as pkgutils } from "utils"
|
||||||
import { useFlags, usePrefix } from "hooks"
|
import { useFlags, usePrefix } from "hooks"
|
||||||
import { set_output } from "./utils/gha.ts"
|
import { set_output } from "./utils/gha.ts"
|
||||||
import { overlay_this_pantry } from "./utils/misc.ts"
|
|
||||||
import build, { BuildResult } from "./build/build.ts"
|
import build, { BuildResult } from "./build/build.ts"
|
||||||
import * as ARGV from "./utils/args.ts"
|
import * as ARGV from "./utils/args.ts"
|
||||||
import Path from "path"
|
import Path from "path"
|
||||||
|
@ -34,13 +35,6 @@ const gha = !!Deno.env.get("GITHUB_ACTIONS")
|
||||||
const group_it = gha && dry.length > 1
|
const group_it = gha && dry.length > 1
|
||||||
const rv: BuildResult[] = []
|
const rv: BuildResult[] = []
|
||||||
|
|
||||||
if (usePrefix().string != "/opt") {
|
|
||||||
console.error({ TEA_PREFIX: usePrefix().string })
|
|
||||||
throw new Error("builds must be performed in /opt (try TEA_PREFIX=/opt)")
|
|
||||||
}
|
|
||||||
|
|
||||||
await overlay_this_pantry()
|
|
||||||
|
|
||||||
for (const rq of dry) {
|
for (const rq of dry) {
|
||||||
const pkg = await pantry.resolve(rq)
|
const pkg = await pantry.resolve(rq)
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,8 @@ args:
|
||||||
- --allow-read
|
- --allow-read
|
||||||
- --allow-env
|
- --allow-env
|
||||||
- --import-map={{ srcroot }}/import-map.json
|
- --import-map={{ srcroot }}/import-map.json
|
||||||
|
env:
|
||||||
|
TEA_PANTRY_PATH: "{{srcroot}}"
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
import { PackageRequirement } from "types"
|
import { PackageRequirement } from "types"
|
||||||
|
|
|
@ -10,6 +10,8 @@ args:
|
||||||
- --allow-write={{ tea.prefix }}
|
- --allow-write={{ tea.prefix }}
|
||||||
- --allow-env
|
- --allow-env
|
||||||
- --import-map={{ srcroot }}/import-map.json
|
- --import-map={{ srcroot }}/import-map.json
|
||||||
|
env:
|
||||||
|
TEA_PANTRY_PATH: "{{srcroot}}"
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
//TODO verify the sha
|
//TODO verify the sha
|
||||||
|
|
|
@ -14,6 +14,7 @@ args:
|
||||||
import Path from "path"
|
import Path from "path"
|
||||||
import { useFlags, usePrefix } from "hooks"
|
import { useFlags, usePrefix } from "hooks"
|
||||||
|
|
||||||
|
//FIXME needs to get actual paths from usePantry
|
||||||
const prefix = new Path(`${usePrefix()}/tea.xyz/var/pantry/projects`)
|
const prefix = new Path(`${usePrefix()}/tea.xyz/var/pantry/projects`)
|
||||||
|
|
||||||
interface Entry {
|
interface Entry {
|
||||||
|
|
|
@ -7,6 +7,8 @@ args:
|
||||||
- --allow-read
|
- --allow-read
|
||||||
- --allow-env
|
- --allow-env
|
||||||
- --import-map={{ srcroot }}/import-map.json
|
- --import-map={{ srcroot }}/import-map.json
|
||||||
|
env:
|
||||||
|
TEA_PANTRY_PATH: "{{srcroot}}"
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
// sorts input for building
|
// sorts input for building
|
||||||
|
|
|
@ -11,6 +11,8 @@ args:
|
||||||
- --allow-env
|
- --allow-env
|
||||||
- --unstable
|
- --unstable
|
||||||
- --import-map={{ srcroot }}/import-map.json
|
- --import-map={{ srcroot }}/import-map.json
|
||||||
|
env:
|
||||||
|
TEA_PANTRY_PATH: "{{srcroot}}"
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
import { Installation, Package, PackageRequirement } from "types"
|
import { Installation, Package, PackageRequirement } from "types"
|
||||||
|
@ -18,12 +20,10 @@ import { usePantry, useFlags, usePrefix } 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 { overlay_this_pantry } from "./utils/misc.ts"
|
|
||||||
import * as ARGV from "./utils/args.ts"
|
import * as ARGV from "./utils/args.ts"
|
||||||
import Path from "path"
|
import Path from "path"
|
||||||
|
|
||||||
useFlags()
|
useFlags()
|
||||||
|
|
||||||
const pantry = usePantry()
|
const pantry = usePantry()
|
||||||
|
|
||||||
for await (const pkg of ARGV.installs()) {
|
for await (const pkg of ARGV.installs()) {
|
||||||
|
@ -31,8 +31,6 @@ for await (const pkg of ARGV.installs()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function test(self: Installation) {
|
async function test(self: Installation) {
|
||||||
await overlay_this_pantry()
|
|
||||||
|
|
||||||
const yml = await pantry.getYAML(self.pkg).parse()
|
const yml = await pantry.getYAML(self.pkg).parse()
|
||||||
const deps = await deps4(self.pkg)
|
const deps = await deps4(self.pkg)
|
||||||
const installations = await prepare(deps)
|
const installations = await prepare(deps)
|
||||||
|
|
|
@ -1,17 +1,9 @@
|
||||||
import { usePrefix } from "hooks"
|
export function overlay_this_pantry() {
|
||||||
|
|
||||||
export async function overlay_this_pantry() {
|
|
||||||
const pantry_prefix = usePrefix().join("tea.xyz/var/pantry")
|
|
||||||
const self = new URL(import.meta.url).path().parent().parent().parent().join("projects")
|
const self = new URL(import.meta.url).path().parent().parent().parent().join("projects")
|
||||||
|
|
||||||
// noop, but also THIS FUCKS SHIT UP
|
// if unset just assume the user wants this
|
||||||
if (self.parent().eq(pantry_prefix)) return
|
// this is magic in a bad way, but for now is what we're doing
|
||||||
|
if (!!Deno.env.get("TEA_PANTRY_PATH")) {
|
||||||
const to = pantry_prefix.join("projects")
|
Deno.env.set("TEA_PANTRY_PATH", self.string)
|
||||||
for await (const [path, {isFile}] of self.walk()) {
|
|
||||||
if (isFile) {
|
|
||||||
const dst = to.join(path.relative({ to: self }))
|
|
||||||
path.cp({ into: dst.parent().mkpath() })
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue