-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
55 lines (52 loc) · 2.45 KB
/
Makefile
File metadata and controls
55 lines (52 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
SOURCE_FORMULAS := dryrun fixturize regresql
BINARY_FORMULAS := qshape
FORMULAS := $(SOURCE_FORMULAS) $(BINARY_FORMULAS)
.PHONY: update update-binary
## update a source-build formula to a new tag.
## usage: make update FORMULA=fixturize TAG=v0.4.0
update:
ifndef FORMULA
$(error FORMULA is required ($(SOURCE_FORMULAS)). Usage: make update FORMULA=fixturize TAG=v0.4.0)
endif
ifndef TAG
$(error TAG is required. Usage: make update FORMULA=$(FORMULA) TAG=v0.4.0)
endif
@URL="https://github.com/boringSQL/$(FORMULA)/archive/refs/tags/$(TAG).tar.gz"; \
echo "Fetching $$URL ..."; \
STATUS=$$(curl -sL -o /dev/null -w '%{http_code}' "$$URL"); \
if [ "$$STATUS" != "200" ]; then \
echo "Error: tag $(TAG) not found for $(FORMULA) (HTTP $$STATUS)"; exit 1; \
fi; \
SHA=$$(curl -sL "$$URL" | shasum -a 256 | cut -d' ' -f1); \
echo "Updating Formula/$(FORMULA).rb to $(TAG) (sha256: $$SHA)"; \
sed -i '' "s|url \".*\"|url \"$$URL\"|" Formula/$(FORMULA).rb; \
sed -i '' "s|sha256 \".*\"|sha256 \"$$SHA\"|" Formula/$(FORMULA).rb; \
echo "Done. Review with: git diff Formula/$(FORMULA).rb"
## update a binary-release formula to a new tag by pulling per-arch SHAs
## from the release's checksums.txt.
## usage: make update-binary FORMULA=qshape TAG=v0.1.0
update-binary:
ifndef FORMULA
$(error FORMULA is required ($(BINARY_FORMULAS)). Usage: make update-binary FORMULA=qshape TAG=v0.1.0)
endif
ifndef TAG
$(error TAG is required. Usage: make update-binary FORMULA=$(FORMULA) TAG=v0.1.0)
endif
@VER=$$(echo "$(TAG)" | sed 's/^v//'); \
SUMS_URL="https://github.com/boringSQL/$(FORMULA)/releases/download/$(TAG)/checksums.txt"; \
echo "Fetching $$SUMS_URL ..."; \
SUMS=$$(curl -sLf "$$SUMS_URL") || { echo "Error: could not fetch $$SUMS_URL"; exit 1; }; \
echo "Updating Formula/$(FORMULA).rb to $(TAG)"; \
sed -i '' "s|^ version \".*\"| version \"$$VER\"|" Formula/$(FORMULA).rb; \
for arch in darwin_arm64 darwin_amd64 linux_arm64 linux_amd64; do \
FILE="$(FORMULA)_$${VER}_$${arch}.tar.gz"; \
SHA=$$(printf '%s\n' "$$SUMS" | awk -v f="$$FILE" '$$2==f {print $$1}'); \
if [ -z "$$SHA" ]; then echo "Error: no checksum for $$FILE"; exit 1; \
fi; \
awk -v arch="$$arch" -v sha="$$SHA" ' \
$$0 ~ arch "\\.tar\\.gz" { seen=1 } \
seen && /sha256 "/ { sub(/"[^"]*"/, "\"" sha "\""); seen=0 } \
{ print }' Formula/$(FORMULA).rb > Formula/$(FORMULA).rb.tmp; \
mv Formula/$(FORMULA).rb.tmp Formula/$(FORMULA).rb; \
done; \
echo "Done. Review with: git diff Formula/$(FORMULA).rb"