From 987271072024cbef751492cb9d70747faef42cd2 Mon Sep 17 00:00:00 2001 From: trapexit Date: Wed, 6 Aug 2025 13:24:25 -0400 Subject: [PATCH] More makefile tweaks, build log, smaller git clones (#1503) --- Makefile | 51 +++++++++++++++--------- buildtools/build-mergerfs | 9 ++++- buildtools/build-release | 15 ++++++- buildtools/containerfiles/static.amd64 | 2 +- buildtools/containerfiles/static.arm64 | 2 +- buildtools/containerfiles/static.armhf | 2 +- buildtools/containerfiles/static.i386 | 2 +- buildtools/containerfiles/static.riscv64 | 2 +- buildtools/containerfiles/tarball | 6 +-- 9 files changed, 62 insertions(+), 29 deletions(-) diff --git a/Makefile b/Makefile index bb06d7d2..5bc0bbff 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ TOUCH ?= touch BUILDDIR := build -ifneq ($(GIT_REPO),0) +ifndef GIT_REPO ifneq ($(shell $(GIT) --version 2> /dev/null),) ifeq ($(shell test -e .git; echo $$?),0) GIT_REPO = 1 @@ -41,32 +41,32 @@ endif USE_XATTR ?= 1 UGID_USE_RWLOCK ?= 0 -ifeq ($(NDEBUG),1) +ifdef NDEBUG OPT_FLAGS := -O2 -DNDEBUG else OPT_FLAGS := -O0 -g -fno-omit-frame-pointer -DDEBUG endif -ifeq ($(STATIC),1) +ifdef STATIC STATIC_FLAGS := -static else STATIC_FLAGS := endif -ifeq ($(LTO),1) +ifdef LTO LTO_FLAGS := -flto else LTO_FLAGS := endif -SRC := $(wildcard src/*.cpp) -OBJS := $(SRC:src/%.cpp=build/.src/%.o) -DEPS := $(SRC:src/%.cpp=build/.src/%.d) +SRC := $(wildcard src/*.cpp) +OBJS := $(SRC:src/%.cpp=build/.src/%.o) +DEPS := $(SRC:src/%.cpp=build/.src/%.d) -TESTS := $(wildcard tests/*.cpp) -TESTS_OBJS := $(filter-out build/.src/mergerfs.o,$(OBJS)) +TESTS := $(wildcard tests/*.cpp) +TESTS_OBJS := $(filter-out build/.src/mergerfs.o,$(OBJS)) TESTS_OBJS += $(TESTS:tests/%.cpp=build/.tests/%.o) -TESTS_DEPS := $(TESTS:tests/%.cpp=build/.tests/%.d) +TESTS_DEPS := $(TESTS:tests/%.cpp=build/.tests/%.d) TESTS_DEPS += $(DEPS) MANPAGE := mergerfs.1 @@ -161,7 +161,7 @@ libfuse: tests: $(BUILDDIR)/tests changelog: -ifeq ($(GIT_REPO),1) +ifdef GIT_REPO $(GIT2DEBCL) --name mergerfs > ChangeLog else @echo "WARNING: need git repo to generate ChangeLog" @@ -195,7 +195,7 @@ clean: rpm-clean $(MAKE) -C libfuse clean distclean: clean -ifeq ($(GIT_REPO),1) +ifdef GIT_REPO $(GIT) clean -xfd endif @@ -253,7 +253,7 @@ tarball: changelog version .PHONY: debian-changelog debian-changelog: -ifeq ($(GIT_REPO),1) +ifdef GIT_REPO $(GIT2DEBCL) --name mergerfs > debian/changelog else $(CP) -v ChangeLog debian/changelog @@ -293,54 +293,67 @@ rpm: tarball install-build-pkgs: ./buildtools/install-build-pkgs +.PHONY: install-build-tools +install-build-tools: + ./bulidtools/install-build-tools + .PHONY: release release: ./buildtools/build-release \ --target=all \ - --cleanup \ + $(if $(CLEANUP),--cleanup) \ --branch=$(shell git branch --show-current) .PHONY: release-sample release-sample: ./buildtools/build-release \ --target=debian.12.amd64 \ + $(if $(CLEANUP),--cleanup) \ --branch=$(shell git branch --show-current) .PHONY: release-amd64 release-amd64: ./buildtools/build-release \ --target=amd64 \ - --cleanup \ + $(if $(CLEANUP),--cleanup) \ --branch=$(shell git branch --show-current) .PHONY: release-arm64 release-arm64: ./buildtools/build-release \ --target=arm64 \ - --cleanup \ + $(if $(CLEANUP),--cleanup) \ --branch=$(shell git branch --show-current) .PHONY: release-riscv64 release-riscv64: ./buildtools/build-release \ --target=riscv64 \ - --cleanup \ + $(if $(CLEANUP),--cleanup) \ --branch=$(shell git branch --show-current) .PHONY: release-armhf release-armhf: ./buildtools/build-release \ --target=armhf \ - --cleanup \ + $(if $(CLEANUP),--cleanup) \ --branch=$(shell git branch --show-current) .PHONY: release-static release-static: ./buildtools/build-release \ --target=static \ - --cleanup \ + $(if $(CLEANUP),--cleanup) \ --branch=$(shell git branch --show-current) +.PHONY: release-tarball +release-tarball: + ./buildtools/build-release \ + --target=tarball \ + $(if $(CLEANUP),--cleanup) \ + --branch=$(shell git branch --show-current) + + .PHONY: tags tags: rm -fv TAGS diff --git a/buildtools/build-mergerfs b/buildtools/build-mergerfs index 6b6eb3b4..e1307fa9 100755 --- a/buildtools/build-mergerfs +++ b/buildtools/build-mergerfs @@ -2,8 +2,15 @@ BRANCH="${1:-master}" SRCDIR="/tmp/mergerfs" +REPO_URL="https://github.com/trapexit/mergerfs" -git clone https://github.com/trapexit/mergerfs "${SRCDIR}" -b "${BRANCH}" +git \ + clone \ + --single-branch \ + --branch="${BRANCH}" \ + --depth=1 \ + "${REPO_URL}" \ + "${SRCDIR}" cd "${SRCDIR}" diff --git a/buildtools/build-release b/buildtools/build-release index 01091594..d0d4955f 100755 --- a/buildtools/build-release +++ b/buildtools/build-release @@ -20,8 +20,21 @@ def build(containerfile, f'--build-arg=BRANCH={branch}', f'--build-arg=BUILD_TIMESTAMP={timestamp}', 'buildtools/'] + # TODO: Capture output and write to log print(args) - subprocess.run(args) + rv = subprocess.run(args) + report_filepath = os.path.join(pkgdirpath,"build-report.txt") + with open(report_filepath,"a+") as f: + build = os.path.basename(containerfile) + f.write(build + ": ") + f.write(f"branch={branch}; ") + f.write(f"timestamp={timestamp}; ") + f.write("rv=") + if rv.returncode == 0: + f.write("success;") + else: + f.write("fail;") + f.write("\n") def setup(): diff --git a/buildtools/containerfiles/static.amd64 b/buildtools/containerfiles/static.amd64 index 0f859ac3..e7b50015 100644 --- a/buildtools/containerfiles/static.amd64 +++ b/buildtools/containerfiles/static.amd64 @@ -3,7 +3,7 @@ FROM --platform=linux/amd64 alpine:latest as build COPY install-build-pkgs /tmp/ RUN /tmp/install-build-pkgs ARG BRANCH=master -RUN git clone https://github.com/trapexit/mergerfs /tmp/mergerfs -b "${BRANCH}" +RUN git clone --single-branch --depth=1 https://github.com/trapexit/mergerfs /tmp/mergerfs --branch="${BRANCH}" WORKDIR /tmp/mergerfs RUN make NDEBUG=1 LTO=1 STATIC=1 DESTDIR=/tmp -j$(nproc) install RUN mkdir /build diff --git a/buildtools/containerfiles/static.arm64 b/buildtools/containerfiles/static.arm64 index 6043beba..ad57d8e4 100644 --- a/buildtools/containerfiles/static.arm64 +++ b/buildtools/containerfiles/static.arm64 @@ -3,7 +3,7 @@ FROM --platform=linux/arm64 alpine:latest as build COPY install-build-pkgs /tmp/ RUN /tmp/install-build-pkgs ARG BRANCH=master -RUN git clone https://github.com/trapexit/mergerfs /tmp/mergerfs -b "${BRANCH}" +RUN git clone --single-branch --depth=1 https://github.com/trapexit/mergerfs /tmp/mergerfs --branch="${BRANCH}" WORKDIR /tmp/mergerfs RUN make NDEBUG=1 LTO=1 STATIC=1 DESTDIR=/tmp -j$(nproc) install RUN mkdir /build diff --git a/buildtools/containerfiles/static.armhf b/buildtools/containerfiles/static.armhf index c3ee863b..cf418139 100644 --- a/buildtools/containerfiles/static.armhf +++ b/buildtools/containerfiles/static.armhf @@ -3,7 +3,7 @@ FROM --platform=linux/armhf alpine:latest as build COPY install-build-pkgs /tmp/ RUN /tmp/install-build-pkgs ARG BRANCH=master -RUN git clone https://github.com/trapexit/mergerfs /tmp/mergerfs -b "${BRANCH}" +RUN git clone --single-branch --depth=1 https://github.com/trapexit/mergerfs /tmp/mergerfs --branch="${BRANCH}" WORKDIR /tmp/mergerfs RUN make NDEBUG=1 LTO=1 STATIC=1 DESTDIR=/tmp -j$(nproc) install RUN mkdir /build diff --git a/buildtools/containerfiles/static.i386 b/buildtools/containerfiles/static.i386 index baf44102..10ee3d71 100644 --- a/buildtools/containerfiles/static.i386 +++ b/buildtools/containerfiles/static.i386 @@ -3,7 +3,7 @@ FROM --platform=linux/i386 alpine:latest as build COPY install-build-pkgs /tmp/ RUN /tmp/install-build-pkgs ARG BRANCH=master -RUN git clone https://github.com/trapexit/mergerfs /tmp/mergerfs -b "${BRANCH}" +RUN git clone --single-branch --depth=1 https://github.com/trapexit/mergerfs /tmp/mergerfs --branch="${BRANCH}" WORKDIR /tmp/mergerfs RUN make NDEBUG=1 LTO=1 STATIC=1 DESTDIR=/tmp -j$(nproc) install RUN mkdir /build diff --git a/buildtools/containerfiles/static.riscv64 b/buildtools/containerfiles/static.riscv64 index 88381479..e6c5fd65 100644 --- a/buildtools/containerfiles/static.riscv64 +++ b/buildtools/containerfiles/static.riscv64 @@ -3,7 +3,7 @@ FROM --platform=linux/riscv64 alpine:latest as build COPY install-build-pkgs /tmp/ RUN /tmp/install-build-pkgs ARG BRANCH=master -RUN git clone https://github.com/trapexit/mergerfs /tmp/mergerfs -b "${BRANCH}" +RUN git clone --single-branch --depth=1 https://github.com/trapexit/mergerfs /tmp/mergerfs --branch="${BRANCH}" WORKDIR /tmp/mergerfs RUN make NDEBUG=1 LTO=1 STATIC=1 DESTDIR=/tmp -j$(nproc) install RUN mkdir /build diff --git a/buildtools/containerfiles/tarball b/buildtools/containerfiles/tarball index 04a12b9c..529f494a 100644 --- a/buildtools/containerfiles/tarball +++ b/buildtools/containerfiles/tarball @@ -1,9 +1,9 @@ -FROM debian:buster as tarball +ARG BUILD_TIMESTAMP=0 +FROM alpine:latest as tarball COPY install-build-pkgs /tmp/ RUN /tmp/install-build-pkgs -ARG BUILD_TIMESTAMP=0 ARG BRANCH=master -RUN git clone https://github.com/trapexit/mergerfs /tmp/mergerfs -b "${BRANCH}" +RUN git clone --single-branch --depth=1 https://github.com/trapexit/mergerfs /tmp/mergerfs --branch="${BRANCH}" RUN cd /tmp/mergerfs && make version tarball RUN mkdir /build RUN cp -v /tmp/mergerfs/*.tar.gz /build/