Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ NAME := goose
PKG_NAME := $(NAME)
TOOL2RPM := rust2rpm
FAS_USERNAME := $(shell copr whoami)
DIST_GIT_CHECKOUT ?= ../goose-fedora
VERSION := $(shell rpmspec -q --qf "%{VERSION}" goose.spec)
VENDOR_TARBALL := goose-$(VERSION)-vendor.tar.xz
SRPM = $(shell srpm=$$(ls goose-$(VERSION)*.src.rpm 2>/dev/null | tail -n 1); if [ -f "$$srpm" ]; then echo $$(realpath "$$srpm"); else echo MISSING; fi)

.PHONY: create-copr-repo
create-copr-repo:
Expand All @@ -13,10 +17,24 @@ create-copr-repo:
sources:
spectool -g $(NAME).spec

.PHONY: srpm
srpm:
# Dynamic targets that will not run if the file exists.
$(VENDOR_TARBALL):
./generate-vendor-tarball.sh

$(SRPM):
fedpkg --release rawhide srpm

# Static targets that provide a consistent interface.
.PHONY: vendor-tarball
vendor-tarball: $(VENDOR_TARBALL)

.PHONY: srpm
srpm: vendor-tarball $(SRPM)

.PHONY: import
import: srpm
@(cd $(DIST_GIT_CHECKOUT) && fedpkg import $(SRPM))
Comment thread
samdoran marked this conversation as resolved.

.PHONY: build
build: srpm
copr build $(NAME) $(NAME)*.src.rpm \
Expand Down Expand Up @@ -63,7 +81,7 @@ logs:

.PHONY: clean
clean:
rm -rf *.src.rpm *.tar.gz *.tar.xz *.crate vendor
rm -rf *.src.rpm *.tar.gz *.tar.xz *.crate vendor goose-*

.PHONY: freeze
freeze:
Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ Before executing a new build, run the initial setup first:
```bash
# Create a new copr repository
make create-copr-repo

# Will create a specfile based on project settings.
# This is only needed in case the goose.spec is missing.
make spec
```

## Building
Expand Down
48 changes: 46 additions & 2 deletions docs/makefile.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,40 @@ files are placed in the repository root directory.
make sources
```

### `vendor-tarball`

Generates the vendored crate tarball using `generate-vendor-tarball.sh`. This
is a prerequisite of the `srpm` target and is skipped if the tarball already
exists.
Comment thread
samdoran marked this conversation as resolved.

```bash
make vendor-tarball
```

### `srpm`

Generates a source RPM (`.src.rpm`) using `fedpkg` targeting the Rawhide
release. This is automatically called by the `build` target, but can be run
independently to verify that the spec file produces a valid SRPM.
release. Depends on `vendor-tarball` to ensure the vendored crate tarball
exists first. This is automatically called by the `build` target, but can be
run independently to verify that the spec file produces a valid SRPM.

```bash
make srpm
```

### `import`

Imports the SRPM into the dist-git checkout directory. Depends on `srpm` to
ensure the SRPM exists. Runs `fedpkg import` inside the directory specified
by the `DIST_GIT_CHECKOUT` variable (defaults to `../goose-fedora`).

```bash
make import

# Or with a custom dist-git checkout path
make import DIST_GIT_CHECKOUT=/path/to/dist-git
```

### `build`

Builds the package in COPR. This target first generates an SRPM (via the
Expand All @@ -58,6 +82,16 @@ Builds the package in COPR. This target first generates an SRPM (via the
make build
```

### `build-all`

Builds the package in COPR across all supported chroots: Fedora 43, 44, and
Rawhide (x86_64, aarch64, ppc64le, s390x), EPEL 9 and 10, and RHEL 9 and 10.
Uses a 10-hour timeout.

```bash
make build-all
```

### `logs`

Watches COPR build logs in real time using
Expand All @@ -77,6 +111,7 @@ Removes generated build artifacts from the repository root:
- `*.tar.gz`, `*.tar.xz` -- source tarballs
- `*.crate` -- Rust crate archives
- `vendor/` -- vendored dependencies directory
- `goose-*` -- extracted source and vendor directories

```bash
make clean
Expand All @@ -92,6 +127,15 @@ under `requirements/`.
make freeze
```

## Variables

| Variable | Default | Description |
|----------|---------|-------------|
| `DIST_GIT_CHECKOUT` | `../goose-fedora` | Path to the dist-git checkout used by `make import`. Override with `make import DIST_GIT_CHECKOUT=/path/to/checkout`. |
| `SRPM` | Auto-detected | Resolves to the absolute path of the most recent `.src.rpm` in the repo root, or `MISSING` if none exists. |
| `VERSION` | From spec | Extracted from `goose.spec` using `rpmspec`. |
| `VENDOR_TARBALL` | `goose-$(VERSION)-vendor.tar.xz` | Name of the vendored crate tarball. |

## Typical Workflow

A standard build cycle looks like this:
Expand Down
12 changes: 10 additions & 2 deletions generate-vendor-tarball.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,20 @@ if [ ! -f "$GOOSE_SOURCE_TARBALL" ]; then
fi

echo "[+] Tarball found, extracting..."
rm -rf "$GOOSE_SOURCE" && tar xf "$GOOSE_SOURCE_TARBALL" >/dev/null 2>&1
rm -rf "$GOOSE_SOURCE"
tar -xzf "$GOOSE_SOURCE_TARBALL" \
--exclude "goose-${VERSION}/.claude" \
--exclude "goose-${VERSION}/.codex" \
--exclude "goose-${VERSION}/.cursor" \
--exclude "goose-${VERSION}/evals" \
--exclude "goose-${VERSION}/services" \
--exclude "goose-${VERSION}/oidc-proxy" \
--exclude "goose-${VERSION}/vendor/v8"

echo "[+] Applying patches..."
pushd "$GOOSE_SOURCE" >/dev/null
for patch in "${PATCHES[@]}"; do
patch -p1 <"../$patch"
patch -p1 <"../$patch"
echo "[!] Applied patch $patch"
done

Expand Down