From 90de211ecfec1e434949ee1aea00922d5d6b4e5a Mon Sep 17 00:00:00 2001 From: Shulhan Date: Sat, 9 Jul 2022 13:38:11 +0700 Subject: all: add task to build package using devtools The devtools allow package to build in clean chroot [1]. In this build, we bind the host go, go-build cache, and .gradle cache to the chroot/build to minimize re-downloading Go and Java dependencies on the next rebuild. [1] https://wiki.archlinux.org/title/DeveloperWiki:Building_in_a_clean_chroot --- .gitignore | 2 ++ Makefile | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index fa33c86..5f272d4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ +*.log *.zst +/_build /collectd /fluent-bit /google-cloud-ops-agent-git diff --git a/Makefile b/Makefile index a0a2eab..25aa434 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: all check release +.PHONY: all check chrootpkg patch release all: makepkg -sd @@ -6,6 +6,21 @@ all: check: namcap PKGBUILD +## Build the package using devtools. +## +## We bind the host go, go-build cache, and .gradle cache to the chroot/build +## to minimize re-downloading Go and Java dependencies on the next rebuild. +chrootpkg: + mkdir -p $$HOME/go + mkdir -p $$HOME/.cache/go-build + mkdir -p $$HOME/.gradle + mkdir -p _build + mkarchroot _build/root base-devel systemd || exit 0 + makechrootpkg -d $$HOME/go:/build/go \ + -d $$HOME/.cache/go-build:/build/.cache/go-build \ + -d $$HOME/.gradle:/build/.gradle \ + -r _build + patch: git -C src/google-cloud-ops-agent-git diff > 0001-apps-hostmetrics.patch && \ makepkg -g -- cgit v1.3