From 1103985f845b1ff74a78e965579aaf5b854051bf Mon Sep 17 00:00:00 2001 From: Thomas Parrott Date: Fri, 4 Oct 2024 15:18:09 +0100 Subject: [PATCH 1/4] Makefile: Build lxd-user as static binary This is a precursor to potentially using it for the callhook handler for container stops. Signed-off-by: Thomas Parrott --- Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index b41c7bd09473..e3e0946d104d 100644 --- a/Makefile +++ b/Makefile @@ -36,9 +36,11 @@ ifeq "$(TAG_SQLITE3)" "" endif ifeq "$(GOCOVERDIR)" "" - CC="$(CC)" CGO_LDFLAGS_ALLOW="$(CGO_LDFLAGS_ALLOW)" go install -v -tags "$(TAG_SQLITE3)" -trimpath $(DEBUG) ./lxd ./lxc-to-lxd ./lxd-user ./lxd-benchmark + CC="$(CC)" CGO_LDFLAGS_ALLOW="$(CGO_LDFLAGS_ALLOW)" go install -v -tags "$(TAG_SQLITE3)" -trimpath $(DEBUG) ./lxd ./lxc-to-lxd ./lxd-benchmark + CGO_ENABLED=0 go install -v -tags netgo -trimpath $(DEBUG) ./lxd-user else - CC="$(CC)" CGO_LDFLAGS_ALLOW="$(CGO_LDFLAGS_ALLOW)" go install -v -tags "$(TAG_SQLITE3)" -trimpath -cover $(DEBUG) ./lxd ./lxc-to-lxd ./lxd-user ./lxd-benchmark + CC="$(CC)" CGO_LDFLAGS_ALLOW="$(CGO_LDFLAGS_ALLOW)" go install -v -tags "$(TAG_SQLITE3)" -trimpath -cover $(DEBUG) ./lxd ./lxc-to-lxd ./lxd-benchmark + CGO_ENABLED=0 go install -v -tags netgo -trimpath -cover $(DEBUG) ./lxd-user endif @echo "LXD built successfully" From d38f5158c87ff3dac7de5c4178e094a807df15bb Mon Sep 17 00:00:00 2001 From: Thomas Parrott Date: Fri, 4 Oct 2024 15:18:43 +0100 Subject: [PATCH 2/4] Makefile: Remove unused nocache and race targets Cache can be cleared using `go clean -cache` and make race was not used. Signed-off-by: Thomas Parrott --- Makefile | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/Makefile b/Makefile index e3e0946d104d..37ea6800b3dd 100644 --- a/Makefile +++ b/Makefile @@ -173,29 +173,6 @@ endif CGO_ENABLED=0 go install -v -trimpath -tags "agent,netgo,logdebug" ./lxd-agent @echo "LXD built successfully" -.PHONY: nocache -nocache: -ifeq "$(TAG_SQLITE3)" "" - @echo "Missing custom libsqlite3, run \"make deps\" to setup." - exit 1 -endif - - CC="$(CC)" CGO_LDFLAGS_ALLOW="$(CGO_LDFLAGS_ALLOW)" go install -a -v -tags "$(TAG_SQLITE3)" $(DEBUG) ./... - CGO_ENABLED=0 go install -a -v -trimpath -tags netgo ./lxd-migrate - CGO_ENABLED=0 go install -a -v -trimpath -tags agent,netgo ./lxd-agent - @echo "LXD built successfully" - -race: -ifeq "$(TAG_SQLITE3)" "" - @echo "Missing custom libsqlite3, run \"make deps\" to setup." - exit 1 -endif - - CC="$(CC)" CGO_LDFLAGS_ALLOW="$(CGO_LDFLAGS_ALLOW)" go install -race -v -tags "$(TAG_SQLITE3)" $(DEBUG) ./... - CGO_ENABLED=0 go install -v -trimpath -tags netgo ./lxd-migrate - CGO_ENABLED=0 go install -v -trimpath -tags agent,netgo ./lxd-agent - @echo "LXD built successfully" - .PHONY: check check: default check-unit cd test && ./main.sh From 75c8af8c1f2abe2074def6068abecd410a03c880 Mon Sep 17 00:00:00 2001 From: Thomas Parrott Date: Fri, 4 Oct 2024 15:22:00 +0100 Subject: [PATCH 3/4] Makefile: Removes unused staticcheck target Signed-off-by: Thomas Parrott --- Makefile | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/Makefile b/Makefile index 37ea6800b3dd..dc2cac7866fa 100644 --- a/Makefile +++ b/Makefile @@ -282,21 +282,6 @@ endif fi run-parts --verbose --exit-on-error --regex '.sh' test/lint -.PHONY: staticcheck -staticcheck: -ifeq ($(shell command -v staticcheck),) - (cd / ; go install honnef.co/go/tools/cmd/staticcheck@latest) -endif - # To get advance notice of deprecated function usage, consider running: - # sed -i 's/^go 1\.[0-9]\+$/go 1.18/' go.mod - # before 'make staticcheck'. - - # Run staticcheck against all the dirs containing Go files. - staticcheck $$(git ls-files *.go | sed 's|^|./|; s|/[^/]\+\.go$$||' | sort -u) - -tags: */*.go - find . -type f -name '*.go' | gotags -L - -f tags - .PHONY: update-auth update-auth: go generate ./lxd/auth From e25bc219414e04603aee07b33aba89adc830fef6 Mon Sep 17 00:00:00 2001 From: Thomas Parrott Date: Fri, 4 Oct 2024 15:23:19 +0100 Subject: [PATCH 4/4] Makefile: Move lxd-benchmark to be built statically This is just a client tool so should never need to import dqlite/liblxc. Signed-off-by: Thomas Parrott --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index dc2cac7866fa..b10a22b900c4 100644 --- a/Makefile +++ b/Makefile @@ -36,11 +36,11 @@ ifeq "$(TAG_SQLITE3)" "" endif ifeq "$(GOCOVERDIR)" "" - CC="$(CC)" CGO_LDFLAGS_ALLOW="$(CGO_LDFLAGS_ALLOW)" go install -v -tags "$(TAG_SQLITE3)" -trimpath $(DEBUG) ./lxd ./lxc-to-lxd ./lxd-benchmark - CGO_ENABLED=0 go install -v -tags netgo -trimpath $(DEBUG) ./lxd-user + CC="$(CC)" CGO_LDFLAGS_ALLOW="$(CGO_LDFLAGS_ALLOW)" go install -v -tags "$(TAG_SQLITE3)" -trimpath $(DEBUG) ./lxd ./lxc-to-lxd + CGO_ENABLED=0 go install -v -tags netgo -trimpath $(DEBUG) ./lxd-user ./lxd-benchmark else - CC="$(CC)" CGO_LDFLAGS_ALLOW="$(CGO_LDFLAGS_ALLOW)" go install -v -tags "$(TAG_SQLITE3)" -trimpath -cover $(DEBUG) ./lxd ./lxc-to-lxd ./lxd-benchmark - CGO_ENABLED=0 go install -v -tags netgo -trimpath -cover $(DEBUG) ./lxd-user + CC="$(CC)" CGO_LDFLAGS_ALLOW="$(CGO_LDFLAGS_ALLOW)" go install -v -tags "$(TAG_SQLITE3)" -trimpath -cover $(DEBUG) ./lxd ./lxc-to-lxd + CGO_ENABLED=0 go install -v -tags netgo -trimpath -cover $(DEBUG) ./lxd-user ./lxd-benchmark endif @echo "LXD built successfully"