Skip to content

Commit 37ae553

Browse files
committed
mv to pkg build etc.
some symlinks to make transitioning easier
1 parent 8f23d11 commit 37ae553

9 files changed

Lines changed: 239 additions & 134 deletions

File tree

README.md

Lines changed: 58 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,69 @@
22

33
# BrewKit
44

5-
The BrewKit builds packages.
5+
BrewKit is build infrastructure for tea.
66

77
```sh
8-
tea +tea.xyz/brewkit build zlib.net
8+
tea +tea.xyz/brewkit pkg build zlib.net
99
```
1010

11-
If you are inside a pantry and tea magic is installed you can omit package
12-
names, BrewKit will figure out what packages you are editing and build them.
11+
If you are inside a pantry and tea magic is installed you can omit the `tea`
12+
preamable and package names, BrewKit will figure out what packages you are
13+
editing and build them.
1314

1415
```sh
15-
xc build
16+
$ pkg build
17+
tea.xyz/brewkit: building zlib.net
1618
```
1719

18-
Here [`xc`](xcfile.dev) reads the instructions from the pantry README to know
19-
to call the full command.
20+
You can build for Linux (via Docker) using `-L`, eg:
21+
22+
```sh
23+
pkg -L build
24+
```
25+
26+
## Without Magic
27+
28+
If you don’t have tea’s magic installed you need to explicitly add brewkit to
29+
the environment:
30+
31+
```sh
32+
tea +tea.xyz/brewkit pkg build
33+
```
34+
35+
## Outside a Pantry Checkout
36+
37+
Outside a pantry checkout you need to both ask `tea` to add brewkit to the
38+
environment and specify which package to operate on. Outside a pantry checkout
39+
we operate against your tea installation (which defaults to `~/.tea`).
40+
41+
```sh
42+
tea +tea.xyz/brewkit pkg build zlib.net
43+
```
44+
45+
## Additions
46+
47+
This repo is for tooling built on top of the tea primitives with the purpose
48+
of generalized building and testing of open source packages.
49+
50+
If you have an idea for an addition open a [discussion]!
51+
52+
[discussion]: https://github.com/orgs/teaxyz/discussions
53+
54+
# Stuff That Needs to be Added
55+
56+
Getting the `rpath` out of a macOS binary:
57+
58+
```sh
59+
lsrpath() {
60+
otool -l "$@" |
61+
awk '
62+
/^[^ ]/ {f = 0}
63+
$2 == "LC_RPATH" && $1 == "cmd" {f = 1}
64+
f && gsub(/^ *path | \(offset [0-9]+\)$/, "") == 2
65+
'
66+
}
67+
```
68+
69+
This should be added to a `pkg doctor` type thing I reckon. eg.
70+
`pkg doctor zlib.net -Q:rpath`.

bin/build

Lines changed: 0 additions & 88 deletions
This file was deleted.

bin/build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pkg-build

bin/pkg

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
arg="$1"
6+
shift
7+
8+
if test "$arg" = "-L"; then
9+
10+
if test -z "$TEA_PREFIX"; then
11+
echo "tea.xyz/brewkit: error: TEA_PREFIX unset" >&2
12+
exit 1
13+
fi
14+
15+
if test -z "$GITHUB_TOKEN"; then
16+
GITHUB_TOKEN=$(tea gh auth token)
17+
fi
18+
19+
if test -n "$SRCROOT"; then
20+
docker run \
21+
--name tea \
22+
--rm \
23+
--volume "$SRCROOT/tea.linux/home":/root \
24+
--volume "$SRCROOT/tea.linux":/root/.tea \
25+
--volume "$TEA_PREFIX/tea.xyz/var/www":/root/.tea/tea.xyz/var/www \
26+
--volume /root/.tea/tea.xyz/var/pantry \
27+
--volume /root/.tea/tea.xyz/var/pantries \
28+
--volume "$SRCROOT"/projects:/pantry/projects \
29+
--env GITHUB_TOKEN=$GITHUB_TOKEN \
30+
--env TEA_PANTRY_PATH=/pantry \
31+
ghcr.io/teaxyz/infuser \
32+
tea +tea.xyz/brewkit "$@"
33+
else
34+
docker run \
35+
--name tea \
36+
--rm \
37+
--volume "$TEA_PREFIX/tea.xyz/brewkit/mnt":/root \
38+
--volume "$TEA_PREFIX/tea.xyz/var/www":/root/.tea/tea.xyz/var/www \
39+
--volume /root/.tea/tea.xyz/var/pantries \
40+
--volume /root/.tea/tea.xyz/var/pantry \
41+
--env GITHUB_TOKEN=$GITHUB_TOKEN \
42+
ghcr.io/teaxyz/infuser \
43+
tea +tea.xyz/brewkit "$@"
44+
fi
45+
elif test -n "$arg"; then
46+
d="$(cd "$(dirname "$0")" && pwd)"
47+
export PATH="$d:$PATH"
48+
exec pkg-"$arg" "$@"
49+
else
50+
echo "tea.xyz/brewkit: error: invalid usage" >&2
51+
exit 1
52+
fi

bin/pkg-build

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
if test -n "$RUNNER_DEBUG" -a -n "$GITHUB_ACTIONS" -o -n "$VERBOSE"; then
6+
set -x
7+
fi
8+
9+
d="$(cd $(dirname $0)/.. && pwd)"
10+
PATH="$d/libexec:$PATH"
11+
12+
if test -z "$1"; then
13+
if test -z "$TEA_PANTRY_PATH"; then
14+
echo "error: TEA_PANTRY_PATH is not set" >&2
15+
exit 1
16+
fi
17+
for x in $(echo "$TEA_PANTRY_PATH" | tr ':' '\n'); do
18+
if test -d "$x"/.git; then
19+
PKGS="$(GIT_DIR="$x"/.git peek.sh) $PKGS"
20+
fi
21+
done
22+
else
23+
PKGS="$@"
24+
fi
25+
26+
if test -z "$GITHUB_TOKEN"; then
27+
export GITHUB_TOKEN=$(tea gh auth token)
28+
fi
29+
30+
# should one of these depend on the other:
31+
# ensure they are build in the correct order
32+
PKGS="$(sort.ts $PKGS --delimiter ' ')"
33+
34+
for PKG in $PKGS; do
35+
PKG="$(resolve.ts $PKG)"
36+
ZIP="$(query.ts $PKG --src)"
37+
PREFIX="$(query.ts $PKG --prefix)"
38+
SRCDIR="$(query.ts $PKG --srcdir)"
39+
40+
if test -n "$ZIP"; then
41+
fetch.ts $PKG -o "$ZIP"
42+
fi
43+
44+
if test -f "$ZIP"; then
45+
extract.ts "$ZIP" --pkg $PKG --output-dir "$SRCDIR"
46+
else
47+
mkdir -p "$SRCDIR"
48+
fi
49+
50+
DEPS=$(deps.ts $PKG --build) # eg. nodejs.org^4
51+
DEPS=$(install.ts $DEPS) # eg. ~/.tea/nodejs.org/v4.3.2
52+
53+
mkdir -p "$SRCDIR"
54+
BUILD_SCRIPT="$(stage.ts $PKG --srcdir "$SRCDIR" --prefix "$PREFIX" --deps "$DEPS")"
55+
56+
if command -v bash 2>/dev/null; then
57+
BASH=bash
58+
else
59+
BASH="tea bash"
60+
fi
61+
62+
$BASH -e "$BUILD_SCRIPT"
63+
64+
PATH="$d/share/brewkit:$PATH" fixup.ts "$PREFIX" --deps "$DEPS"
65+
66+
find "$PREFIX" -type f -name \*.la -delete
67+
68+
link.ts "$PREFIX" $PKG
69+
70+
if test -n "$GITHUB_ACTIONS"; then
71+
GH_PKGS="$PKG $GH_PKGS"
72+
GH_RELATIVE_PATHS="$GH_RELATIVE_PATHS ${PREFIX#$TEA_PREFIX/}"
73+
74+
if test -f "$ZIP"; then
75+
GH_SRCS="$GH_SRCS ${ZIP#$TEA_PREFIX/}"
76+
GH_SRCS_RELATIVE_PATHS="$GH_SRCS_RELATIVE_PATHS ${ZIP#$TEA_PREFIX/}"
77+
else
78+
GH_SRCS="$GH_SRCS ~"
79+
fi
80+
fi
81+
done
82+
83+
if test -n "$GITHUB_ACTIONS"; then
84+
echo "pkgs=$GH_PKGS" >> $GITHUB_OUTPUT
85+
echo "relative-paths=$GH_RELATIVE_PATHS" >> $GITHUB_OUTPUT
86+
echo "srcs=$GH_SRCS" >> $GITHUB_OUTPUT
87+
echo "srcs-relative-paths=$GH_SRCS_RELATIVE_PATHS" >> $GITHUB_OUTPUT
88+
fi
File renamed without changes.
File renamed without changes.
File renamed without changes.

bin/pkg-test

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
d="$(cd $(dirname $0)/.. && pwd)"
6+
PATH="$d/libexec:$PATH"
7+
8+
if test -z "$1"; then
9+
if test -z "$TEA_PANTRY_PATH"; then
10+
echo "error: TEA_PANTRY_PATH is not set" >&2
11+
exit 1
12+
fi
13+
for x in $(echo "$TEA_PANTRY_PATH" | tr ':' '\n'); do
14+
if test -d "$x"/.git; then
15+
PKGS="$(GIT_DIR="$x"/.git peek.sh) $PKGS"
16+
fi
17+
done
18+
else
19+
PKGS="$1"
20+
fi
21+
22+
for PKG in $PKGS; do
23+
PKG="$(resolve.ts $PKG --cellar)"
24+
DEPS="$(deps.ts $PKG --test)"
25+
DEPS="$(install.ts $DEPS)"
26+
DSTDIR="$(query.ts $PKG --testdir)"
27+
28+
mkdir -p "$DSTDIR"
29+
30+
stage-test.ts $PKG --deps "$DEPS" --dstdir "$DSTDIR"
31+
32+
if command -v bash 2>/dev/null; then
33+
BASH=bash
34+
else
35+
BASH="tea bash"
36+
fi
37+
38+
$BASH -e "$DSTDIR"/xyz.tea.test.sh
39+
done

bin/test

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)