Skip to content

Commit

Permalink
Generate manpage and completion on release (gopasspw#1860)
Browse files Browse the repository at this point in the history
Shipping pre-generated manpage and completion files simplifies
packaging gopass.

RELEASE_NOTES=n/a

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
  • Loading branch information
dominikschulz authored Mar 20, 2021
1 parent 39c4c31 commit 2fdeb0f
Show file tree
Hide file tree
Showing 8 changed files with 1,165 additions and 73 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
gopass
gopass.1
gopass-*-amd64
gopass-full
dev.sh
Expand Down Expand Up @@ -49,8 +48,6 @@ _testmain.go
releases/
dist/

*.completion
gopass_wrapper.sh
manifest-*.json

# go-fuzz
Expand Down
91 changes: 22 additions & 69 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ FIRST_GOPATH := $(firstword $(subst :, ,$(GOPATH)))
PKGS := $(shell go list ./... | grep -v /tests | grep -v /xcpb | grep -v /gpb)
GOFILES_NOVENDOR := $(shell find . -name vendor -prune -o -type f -name '*.go' -not -name '*.pb.go' -print)
GOFILES_BUILD := $(shell find . -type f -name '*.go' -not -name '*_test.go')
PROTOFILES := $(shell find . -name vendor -prune -o -type f -name '*.proto' -print)
GOPASS_VERSION ?= $(shell cat VERSION)
GOPASS_OUTPUT ?= gopass
GOPASS_REVISION := $(shell cat COMMIT 2>/dev/null || git rev-parse --short=8 HEAD)
Expand All @@ -26,30 +25,28 @@ export GO111MODULE=on

OK := $(shell tput setaf 6; echo ' [OK]'; tput sgr0;)

all: sysinfo build completion man
all: sysinfo build
build: $(GOPASS_OUTPUT)
completion: $(BASH_COMPLETION_OUTPUT) $(FISH_COMPLETION_OUTPUT) $(ZSH_COMPLETION_OUTPUT)
travis: sysinfo crosscompile build fulltest codequality completion full
travis-osx: sysinfo build test completion full
travis: sysinfo crosscompile build fulltest codequality completion
travis-osx: sysinfo build test completion
travis-windows: sysinfo build test-win completion

sysinfo:
@echo ">> SYSTEM INFORMATION"
@echo -n " PLATFORM: $(shell uname -a)"
@echo -n " PLATFORM : $(shell uname -a)"
@printf '%s\n' '$(OK)'
@echo -n " PWD: : $(shell pwd)"
@echo -n " PWD: : $(shell pwd)"
@printf '%s\n' '$(OK)'
@echo -n " GO : $(shell go version)"
@echo -n " GO : $(shell go version)"
@printf '%s\n' '$(OK)'
@echo -n " BUILDFLAGS: $(BUILDFLAGS)"
@echo -n " BUILDFLAGS : $(BUILDFLAGS)"
@printf '%s\n' '$(OK)'
@echo -n " GIT : $(shell git version)"
@echo -n " GIT : $(shell git version)"
@printf '%s\n' '$(OK)'
@echo -n " GPG1 : $(shell which gpg) $(shell gpg --version | head -1)"
@echo -n " GPG : $(shell which gpg) $(shell gpg --version | head -1)"
@printf '%s\n' '$(OK)'
@echo -n " GPG2 : $(shell which gpg2) $(shell gpg2 --version | head -1)"
@printf '%s\n' '$(OK)'
@echo -n " GPG-Agent : $(shell which gpg-agent) $(shell gpg-agent --version | head -1)"
@echo -n " GPGAgent : $(shell which gpg-agent) $(shell gpg-agent --version | head -1)"
@printf '%s\n' '$(OK)'

clean:
Expand Down Expand Up @@ -82,28 +79,23 @@ install: all install-completion install-man
@install -m 0755 $(GOPASS_OUTPUT) $(DESTDIR)$(BINDIR)/gopass
@printf '%s\n' '$(OK)'

fulltest: $(GOPASS_OUTPUT)
@echo ">> TEST, \"full-mode\": race detector off, build tags: xc"
@echo "mode: atomic" > coverage-all.out
@$(foreach pkg, $(PKGS),\
echo -n " ";\
go test -run '(Test|Example)' $(BUILDFLAGS) $(TESTFLAGS) -coverprofile=coverage.out -covermode=atomic $(pkg) || exit 1;\
tail -n +2 coverage.out >> coverage-all.out;)
@$(GO) tool cover -html=coverage-all.out -o coverage-all.html
install-completion:
@install -d $(DESTDIR)$(PREFIX)/share/zsh/site-functions $(DESTDIR)$(PREFIX)/share/bash-completion/completions $(DESTDIR)$(PREFIX)/share/fish/vendor_completions.d
@install -m 0755 $(ZSH_COMPLETION_OUTPUT) $(DESTDIR)$(PREFIX)/share/zsh/site-functions/_gopass
@install -m 0755 $(BASH_COMPLETION_OUTPUT) $(DESTDIR)$(PREFIX)/share/bash-completion/completions/gopass
@install -m 0755 $(FISH_COMPLETION_OUTPUT) $(DESTDIR)$(PREFIX)/share/fish/vendor_completions.d/gopass.fish
@printf '%s\n' '$(OK)'

fulltest-nocover: $(GOPASS_OUTPUT)
@echo ">> TEST, \"full-mode-no-coverage\": race detector off, build tags: xc"
@echo "mode: atomic" > coverage-all.out
@$(foreach pkg, $(PKGS),\
echo -n " ";\
go test -run '(Test|Example)' $(TESTFLAGS) $(pkg) || exit 1;)
install-man: gopass.1
@install -d -m 0755 $(DESTDIR)$(PREFIX)/share/man/man1
@install -m 0644 gopass.1 $(DESTDIR)$(PREFIX)/share/man/man1/gopass.1

racetest: $(GOPASS_OUTPUT)
@echo ">> TEST, \"full-mode\": race detector on"
fulltest: $(GOPASS_OUTPUT)
@echo ">> TEST, \"full-mode\": race detector off"
@echo "mode: atomic" > coverage-all.out
@$(foreach pkg, $(PKGS),\
echo -n " ";\
go test -run '(Test|Example)' $(BUILDFLAGS) $(TESTFLAGS) -race -coverprofile=coverage.out -covermode=atomic $(pkg) || exit 1;\
go test -run '(Test|Example)' $(BUILDFLAGS) $(TESTFLAGS) -coverprofile=coverage.out -covermode=atomic $(pkg) || exit 1;\
tail -n +2 coverage.out >> coverage-all.out;)
@$(GO) tool cover -html=coverage-all.out -o coverage-all.html

Expand Down Expand Up @@ -132,22 +124,11 @@ crosscompile:
@GOOS=windows GOARCH=amd64 $(GO) build -o $(GOPASS_OUTPUT)-windows-amd64
@printf '%s\n' '$(OK)'

full:
@echo -n ">> COMPILE linux/amd64 xc"
$(GO) build -o $(GOPASS_OUTPUT)-full

%.completion: $(GOPASS_OUTPUT)
@printf ">> $* completion, output = $@"
@./gopass completion $* > $@
@printf "%s\n" "$(OK)"

install-completion: completion
@install -d $(DESTDIR)$(PREFIX)/share/zsh/site-functions $(DESTDIR)$(PREFIX)/share/bash-completion/completions $(DESTDIR)$(PREFIX)/share/fish/vendor_completions.d
@install -m 0755 $(ZSH_COMPLETION_OUTPUT) $(DESTDIR)$(PREFIX)/share/zsh/site-functions/_gopass
@install -m 0755 $(BASH_COMPLETION_OUTPUT) $(DESTDIR)$(PREFIX)/share/bash-completion/completions/gopass
@install -m 0755 $(FISH_COMPLETION_OUTPUT) $(DESTDIR)$(PREFIX)/share/fish/vendor_completions.d/gopass.fish
@printf '%s\n' '$(OK)'

codequality:
@echo ">> CODE QUALITY"

Expand All @@ -163,11 +144,6 @@ codequality:
out=$$(gofmt -s -l -d -e $(gofile) | tee /dev/stderr); if [ -n "$$out" ]; then exit 1; fi;)
@printf '%s\n' '$(OK)'

@echo -n " CLANGFMT "
@$(foreach pbfile, $(PROTOFILES),\
if [ $$(clang-format -output-replacements-xml $(pbfile) | wc -l) -gt 3 ]; then exit 1; fi;)
@printf '%s\n' '$(OK)'

@echo -n " VET "
@$(GO) vet ./...
@printf '%s\n' '$(OK)'
Expand Down Expand Up @@ -223,27 +199,8 @@ gen:
fmt:
@gofmt -s -l -w $(GOFILES_NOVENDOR)
@goimports -l -w $(GOFILES_NOVENDOR)
@which clang-format > /dev/null; if [ $$? -eq 0 ]; then \
clang-format -i $(PROTOFILES); \
fi
@go mod tidy

fuzz-gpg:
mkdir -p workdir/gpg-cli/corpus
go-fuzz-build github.com/gopasspw/gopass/backend/gpg/cli
go-fuzz -bin=cli-fuzz.zip -workdir=workdir/gpg-cli

check-release-env:
ifndef GITHUB_TOKEN
$(error GITHUB_TOKEN is undefined)
endif

release: goreleaser

goreleaser: check-release-env travis clean
@echo ">> RELEASE, goreleaser"
@goreleaser

deps:
@go build -v ./...

Expand All @@ -253,8 +210,4 @@ upgrade: gen fmt
man:
@go run helpers/man/main.go > gopass.1

install-man: man
@install -d -m 0755 $(DESTDIR)$(PREFIX)/share/man/man1
@install -m 0644 gopass.1 $(DESTDIR)$(PREFIX)/share/man/man1/gopass.1

.PHONY: clean build completion install sysinfo crosscompile test codequality release goreleaser debsign man
11 changes: 11 additions & 0 deletions bash.completion
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
_gopass_bash_autocomplete() {
local cur opts base
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion )
local IFS=$'\n'
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
}

complete -F _gopass_bash_autocomplete gopass
2 changes: 1 addition & 1 deletion docs/usecases/secure-otp/sign-in.puml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ User -> Website: enter (otp-code)
Website -> Website: validate (otp-code,website-time,otp-token)
User <-- Website: success

@enduml
@enduml
Loading

0 comments on commit 2fdeb0f

Please sign in to comment.