From f08f71bdcad5e5cb8edc24ced69c4b864e0d432f Mon Sep 17 00:00:00 2001 From: HarshwardhanPatil07 Date: Mon, 22 Jun 2026 17:03:29 +0530 Subject: [PATCH] Auto-detect btrfs headers to fix build on systems without btrfs-progs-devel Add hack/btrfs_installed_tag.sh (same pattern as Podman/Buildah) that probes for btrfs/ioctl.h and emits exclude_graphdriver_btrfs when the headers are missing. Wire it into the Makefile via BUILDTAGS so `make build-bink` works out of the box on any system. Signed-off-by: HarshwardhanPatil07 --- Makefile | 6 +++++- hack/btrfs_installed_tag.sh | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100755 hack/btrfs_installed_tag.sh diff --git a/Makefile b/Makefile index 35ccab5..5875fe3 100644 --- a/Makefile +++ b/Makefile @@ -21,6 +21,10 @@ LDFLAGS := -X $(VERSION_PKG).Version=$(VERSION) \ -X $(VERSION_PKG).GitCommit=$(GIT_COMMIT) \ -X $(VERSION_PKG).BuildDate=$(BUILD_DATE) +# Build tags (auto-detect optional C dependencies) +BUILDTAGS ?= \ + $(shell hack/btrfs_installed_tag.sh) + # Directories VM_DIR := containerfiles/cluster-image @@ -29,7 +33,7 @@ all: build-bink # Build the bink CLI binary build-bink: @echo "=== Building bink CLI binary ===" - go build -ldflags "$(LDFLAGS)" -o $(BINK_BINARY) ./cmd/bink + go build -tags "$(BUILDTAGS)" -ldflags "$(LDFLAGS)" -o $(BINK_BINARY) ./cmd/bink @echo "✅ bink binary built: $(BINK_BINARY)" diff --git a/hack/btrfs_installed_tag.sh b/hack/btrfs_installed_tag.sh new file mode 100755 index 0000000..5cc687b --- /dev/null +++ b/hack/btrfs_installed_tag.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +${CPP:-${CC:-cc} -E} ${CPPFLAGS} - > /dev/null 2> /dev/null << EOF +#include +EOF +if test $? -ne 0; then + echo exclude_graphdriver_btrfs +fi