@@ -87,14 +87,31 @@ authors: ## generate AUTHORS file from git history
8787 scripts/docs/generate-authors.sh
8888
8989.PHONY : completion
90- completion : binary
91- completion : /etc/bash_completion.d/docker
92- completion : # # generate and install the completion scripts
93-
94- .PHONY : /etc/bash_completion.d/docker
95- /etc/bash_completion.d/docker : # # generate and install the bash-completion script
96- mkdir -p /etc/bash_completion.d
97- docker completion bash > /etc/bash_completion.d/docker
90+ completion : shell-completion
91+ completion : # # generate and install the shell-completion scripts
92+ # Note: this uses system-wide paths, and so may overwrite completion
93+ # scripts installed as part of deb/rpm packages.
94+ #
95+ # Given that this target is intended to debug/test updated versions, we could
96+ # consider installing in per-user (~/.config, XDG_DATA_DIR) paths instead, but
97+ # this will add more complexity.
98+ #
99+ # See https://github.com/docker/cli/pull/5770#discussion_r1927772710
100+ install -D -p -m 0644 ./build/completion/bash/docker /usr/share/bash-completion/completions/docker
101+ install -D -p -m 0644 ./build/completion/fish/docker.fish debian/docker-ce-cli/usr/share/fish/vendor_completions.d/docker.fish
102+ install -D -p -m 0644 ./build/completion/zsh/_docker debian/docker-ce-cli/usr/share/zsh/vendor-completions/_docker
103+
104+
105+ build/docker :
106+ # This target is used by the "shell-completion" target, which requires either
107+ # "binary" or "dynbinary" to have been built. We don't want to trigger those
108+ # to prevent replacing a static binary with a dynamic one, or vice-versa.
109+ @echo "Run 'make binary' or 'make dynbinary' first" && exit 1
110+
111+ .PHONY : shell-completion
112+ shell-completion : build/docker # requires either "binary" or "dynbinary" to be built.
113+ shell-completion : # # generate shell-completion scripts
114+ @ ./scripts/build/shell-completion
98115
99116.PHONY : manpages
100117manpages : # # generate man pages from go source and markdown
0 commit comments