|
| 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_RELATIVE_PATHS="$GH_RELATIVE_PATHS ${PREFIX#$TEA_PREFIX/}" |
| 72 | + |
| 73 | + if test -f "$ZIP"; then |
| 74 | + GH_SRCS="$GH_SRCS ${ZIP#$TEA_PREFIX/}" |
| 75 | + GH_SRCS_RELATIVE_PATHS="$GH_SRCS_RELATIVE_PATHS ${ZIP#$TEA_PREFIX/}" |
| 76 | + else |
| 77 | + GH_SRCS="$GH_SRCS ~" |
| 78 | + fi |
| 79 | + fi |
| 80 | +done |
| 81 | + |
| 82 | +if test -n "$GITHUB_ACTIONS"; then |
| 83 | + echo "pkgs=$PKGS" >> $GITHUB_OUTPUT |
| 84 | + echo "relative-paths=$GH_RELATIVE_PATHS" >> $GITHUB_OUTPUT |
| 85 | + echo "srcs=$GH_SRCS" >> $GITHUB_OUTPUT |
| 86 | + echo "srcs-relative-paths=$GH_SRCS_RELATIVE_PATHS" >> $GITHUB_OUTPUT |
| 87 | +fi |
0 commit comments