Shutdown Tool to shutdown Raspberry Pi remotely.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

38 lines
1.3 KiB

PKGS := $(shell go list ./... | grep -v /vendor)
GO_FILES := $(shell find . -iname '*.go' -type f | grep -v /vendor/) # All the .go files, excluding vendor/
BINARY := shutdown-tool
PLATFORM := linux
ARCHS := amd64 arm arm64
VERSION ?= latest
arch = $(word 1, $@)
bootstrap:
@mkdir -p release
go get golang.org/x/lint # Linter
go get honnef.co/go/tools/cmd/staticcheck # Badass static analyzer/linter
go get github.com/fzipp/gocyclo # Cyclomatic complexity check
test:
go test -v -race $(PKGS) # Normal Test
go vet ./... # go vet is the official Go static analyzer
staticcheck ./... # "go vet on steroids" + linter
gocyclo -over 19 $(GO_FILES) # forbid code with huge functions
golint -set_exit_status $(PKGS) # one last linter
$(ARCHS):
GOARCH=$(arch) GOOS=$(PLATFORM) go build -ldflags '-s -w -X main.version=$(VERSION)' -o release/$(BINARY) ./cmd/$(BINARY)
tar -cf release/$(BINARY)-$(VERSION)-linux-$(arch).tar README.md -C release $(BINARY)
tar -uf release/$(BINARY)-$(VERSION)-linux-$(arch).tar -C scripts install.sh
tar -uf release/$(BINARY)-$(VERSION)-linux-$(arch).tar -C init/systemd shutdown-tool.service
gzip -f release/$(BINARY)-$(VERSION)-linux-$(arch).tar
rm release/$(BINARY)
.PHONY: release
release: arm arm64 amd64
clean:
rm -rf release/*
all: bootstrap test release