Merge pull request #140 from Katenary/develop

Develop
This commit is contained in:
2025-07-15 13:45:38 +02:00
committed by GitHub

View File

@@ -3,7 +3,7 @@ SHELL := bash
.SHELLFLAGS := -eu -o pipefail -c
.ONESHELL:
.DELETE_ON_ERROR:
.PHONY: help dist-clean dist package build install test doc nsis
.PHONY: all binaries build check-dist-all check-dist-archlinux check-dist-debian check-dist-fedora check-dist-rocky check-dist-ubuntu check-sign clean-all clean-dist clean-go-cache clean-package-signer cover deb dist dist-full doc freebsd gpg-sign help install install-gomarkdoc katenary manpage packager-oci-image packages pacman prepare pull rpm rpm-sign sast serve-doc show-cover tar test uninstall upx warn-docker
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
@@ -21,13 +21,12 @@ GOARCH=amd64
CGO_ENABLED=0
PREFIX=~/.local
warn-docker:
@echo -e "\033[1;31mWarning: Docker is not recommended, use Podman instead.\033[0m"
sleep 5
# Get the container (Podman is preferred, but docker can be used too. It may failed with Docker.)
# TODO: prpose nerdctl
# TODO: propose nerdctl
CTN:=$(shell which podman 2>&1 1>/dev/null && echo "podman" || echo "docker")
ifeq ($(CTN),podman)
CTN_USERMAP=--userns=keep-id
@@ -120,7 +119,7 @@ help:
This will build the binary for darwin amd64.
Or you can build all versions:
$$ make build-all
$$ make binaries
EOF
@@ -147,7 +146,7 @@ else
-e GOARCH=$(GOARCH) \
--rm -v $(PWD):/go/src/katenary:z \
-w /go/src/katenary \
-v ./.cache:/go/pkg/mod:z \
-v go-cache:/go/pkg/mod:z \
$(CTN_USERMAP) \
$(BUILD_IMAGE) $(GO_BUILD)
endif
@@ -155,8 +154,9 @@ endif
# Make dist, build executables for all platforms, sign them, and compress them with upx if possible.
# Also generate the windows installer.
dist: prepare $(BINARIES) upx packages
dist-full: dist-clean dist gpg-sign check-sign rpm-sign check-dist-all
binaries: prepare $(BINARIES)
dist: binaries upx packages
dist-full: clean-dist dist gpg-sign check-sign rpm-sign check-dist-all
prepare: pull packager-oci-image
mkdir -p dist
@@ -206,12 +206,16 @@ nsis/EnVar.dll:
mv Plugins/x86-unicode/EnVar.dll EnVar.dll
rm -rf EnVar_plugin.zip Plugins
upx: dist/katenary-linux-amd64 dist/katenary-linux-arm64 dist/katenary-darwin-amd64
$(UPX) dist/katenary-linux-amd64
$(UPX) dist/katenary-linux-arm64
$(UPX) dist/katenary-darwin-amd64 --force-macos
# UPX compression
upx: upx-linux upx-darwin
## Linux / FreeBSD packages
upx-linux: dist/katenary-linux-amd64 dist/katenary-linux-arm64
$(UPX) $^
upx-darwin: dist/katenary-darwin-amd64
$(UPX) --force-macos $^
## Linux / FreeBSD packages with fpm
DESCRIPTION := $(shell cat packaging/description | sed ':a;N;$$!ba;s/\n/\\n/g')
@@ -321,6 +325,20 @@ check-sign:
exit 1; \
fi; \
done
@echo "=> checking in blank environment..."
keyid=$(shell gpg -k --with-colons $(SIGNER)| grep '^pub' | cut -d: -f5);
$(CTN) run --rm -it -e GPGKEY=$${keyid} -v ./dist:/opt/dist:z \
packaging:fedora \
bash -c '
gpg --recv-key $$GPGKEY || exit 1;
echo "Trusting $(SIGNER) key...";
echo "trusted-key 483493B2DD0845DA8F21A26DF3702E3FAD8F76DC" >> ~/.gnupg/gpg.conf;
gpg --update-trustdb;
rm -f ~/.gnupg/gpg.conf;
for f in /opt/dist/*.asc; do echo "==> $${f}"; gpg --verify $${f}; done;
echo "=> Listing imported keys...";
gpg -k
'
dist/%.asc: dist/%
gpg --armor --detach-sign --default-key $(SIGNER) $< &>/dev/null || exit 1
@@ -457,17 +475,28 @@ test:
$(MAKE) cover
cover:
go tool cover -func=cover.out | grep "total:"
@go tool cover -func=cover.out | grep "total:"
go tool cover -html=cover.out -o cover.html
show-cover:
@[ -f cover.html ] || (echo "cover.html is not present, run make test before"; exit 1)
if [ "$(BROWSER)" = "xdg-open" ]; then
xdg-open cover.html
else
$(BROWSER) -i --new-window cover.html
fi
## Miscellaneous
dist-clean:
clean-all: clean-dist clean-package-signer clean-go-cache
clean-dist:
rm -rf dist
rm -f katenary
clean-package-signer:
rm -f .secret.gpg .rpmmacros
clean-go-cache:
$(CTN) volume rm -f go-cache