summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorPaul Holzinger <paul.holzinger@web.de>2020-11-08 21:50:51 +0100
committerPaul Holzinger <paul.holzinger@web.de>2020-11-12 11:40:29 +0100
commitae3816614de1c2a0c9ab9cd05afebc5b1dda6429 (patch)
tree11deb2f5b2bb87d1869f7258b8f2e9cc46b57e00 /Makefile
parentb5d1d89a377e38762a75c2042dcc50a370ba6707 (diff)
downloadpodman-ae3816614de1c2a0c9ab9cd05afebc5b1dda6429.tar.gz
podman-ae3816614de1c2a0c9ab9cd05afebc5b1dda6429.tar.bz2
podman-ae3816614de1c2a0c9ab9cd05afebc5b1dda6429.zip
Install the new shell completion logic
Add a new make target (completion) to generate the shell completion scripts. This will generate the scripts for bash, zsh and fish for both podman and podman-remote with `podman completion`. The scripts are put into the completions directory and can be installed system wide with `sudo make install.completions`. This commit replaces the current handwritten scripts for bash and zsh. The `validate.completion` target has been adjusted to make sure nobody edits these scripts directly. Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile28
1 files changed, 27 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 726020cba..5eeb3b2f7 100644
--- a/Makefile
+++ b/Makefile
@@ -48,6 +48,7 @@ OCI_RUNTIME ?= ""
BASHINSTALLDIR=${PREFIX}/share/bash-completion/completions
ZSHINSTALLDIR=${PREFIX}/share/zsh/site-functions
+FISHINSTALLDIR=${PREFIX}/share/fish/vendor_completions.d
SELINUXOPT ?= $(shell test -x /usr/sbin/selinuxenabled && selinuxenabled && echo -Z)
@@ -474,6 +475,15 @@ changelog: ## Generate changelog
$(shell cat $(TMPFILE) >> changelog.txt)
$(shell rm $(TMPFILE))
+completions: binaries
+ install ${SELINUXOPT} -d -m 755 completions/{bash,zsh,fish}
+ ./bin/podman completion bash --no-desc -f completions/bash/podman
+ ./bin/podman-remote completion bash --no-desc -f completions/bash/podman-remote
+ ./bin/podman completion zsh -f completions/zsh/_podman
+ ./bin/podman-remote completion zsh -f completions/zsh/_podman-remote
+ ./bin/podman completion fish -f completions/fish/podman.fish
+ ./bin/podman-remote completion fish -f completions/fish/podman-remote.fish
+
.PHONY: install
install: .gopathok install.bin install.remote install.man install.cni install.systemd ## Install binaries to system locations
@@ -512,8 +522,13 @@ install.man: docs install.man-nobuild
install.completions:
install ${SELINUXOPT} -d -m 755 ${DESTDIR}${BASHINSTALLDIR}
install ${SELINUXOPT} -m 644 completions/bash/podman ${DESTDIR}${BASHINSTALLDIR}
+ install ${SELINUXOPT} -m 644 completions/bash/podman-remote ${DESTDIR}${BASHINSTALLDIR}
install ${SELINUXOPT} -d -m 755 ${DESTDIR}${ZSHINSTALLDIR}
install ${SELINUXOPT} -m 644 completions/zsh/_podman ${DESTDIR}${ZSHINSTALLDIR}
+ install ${SELINUXOPT} -m 644 completions/zsh/_podman-remote ${DESTDIR}${ZSHINSTALLDIR}
+ install ${SELINUXOPT} -d -m 755 ${DESTDIR}${FISHINSTALLDIR}
+ install ${SELINUXOPT} -m 644 completions/fish/podman.fish ${DESTDIR}${FISHINSTALLDIR}
+ install ${SELINUXOPT} -m 644 completions/fish/podman-remote.fish ${DESTDIR}${FISHINSTALLDIR}
.PHONY: install.cni
install.cni:
@@ -656,9 +671,20 @@ API.md: pkg/varlink/io.podman.varlink
$(GO) generate ./docs/...
.PHONY: validate.completions
-validate.completions: completions/bash/podman
+validate.completions: SHELL:=/usr/bin/env bash # Set shell to bash for this target
+validate.completions:
+ # Check that nobody has manually edited the completion scripts
+ # If this check fails run make completions to restore the correct scripts
+ diff completions/bash/podman <(./bin/podman completion --no-desc bash)
+ diff completions/zsh/_podman <(./bin/podman completion zsh)
+ diff completions/fish/podman.fish <(./bin/podman completion fish)
+ diff completions/bash/podman-remote <(./bin/podman-remote completion --no-desc bash)
+ diff completions/zsh/_podman-remote <(./bin/podman-remote completion zsh)
+ diff completions/fish/podman-remote.fish <(./bin/podman-remote completion fish)
+ # Check if the files can be loaded by the shell
. completions/bash/podman
if [ -x /bin/zsh ]; then /bin/zsh completions/zsh/_podman; fi
+ if [ -x /bin/fish ]; then /bin/fish completions/fish/podman.fish; fi
.PHONY: validate
validate: gofmt lint .gitvalidation validate.completions man-page-check swagger-check