#!/bin/bash # Fetch upstream source tarball and vendor production node_modules. # # Produces two files next to the spec: # turborepo-remote-cache-.tar.gz (upstream src) # turborepo-remote-cache--node_modules_prod.tar.gz # # Requires: curl, tar, pnpm, node # # Run this before `rpmbuild` whenever VERSION changes. set -euo pipefail VERSION="${1:-2.8.2}" PKG="turborepo-remote-cache" UPSTREAM="https://github.com/ducktors/${PKG}" SPEC_DIR="$(cd "$(dirname "$0")" && pwd)" WORK="$(mktemp -d)" trap 'rm -rf "$WORK"' EXIT SRC_TARBALL="${PKG}-${VERSION}.tar.gz" DEPS_TARBALL="${PKG}-${VERSION}-node_modules_prod.tar.gz" echo ">>> Fetching ${UPSTREAM}/archive/refs/tags/v${VERSION}.tar.gz" curl -fsSL -o "${SPEC_DIR}/${SRC_TARBALL}" \ "${UPSTREAM}/archive/refs/tags/v${VERSION}.tar.gz" echo ">>> Extracting source to ${WORK}" tar -C "${WORK}" -xzf "${SPEC_DIR}/${SRC_TARBALL}" cd "${WORK}/${PKG}-${VERSION}" echo ">>> Installing production dependencies with pnpm" pnpm install --prod --frozen-lockfile --ignore-scripts echo ">>> Packing node_modules into ${DEPS_TARBALL}" tar -czf "${SPEC_DIR}/${DEPS_TARBALL}" node_modules echo echo "Done:" echo " ${SPEC_DIR}/${SRC_TARBALL}" echo " ${SPEC_DIR}/${DEPS_TARBALL}"