From 29bd82ba14f40034b5ef55ad52a33150a2c7f3f6 Mon Sep 17 00:00:00 2001 From: Morten Linderud Date: Wed, 9 Dec 2020 23:06:18 +0100 Subject: [PATCH] generate-man.sh: Only build md2man if it's not installed Distributions uses generate-man.sh to create man pages, however it only assumes a container environment and attempts to build binaries towards `/go` which might be an illegal path in `fakeroot`. This patch ensures we only build `md2man` from the vendored sources if the command is not present. This allows distributions to supply thier packaged `md2man`. Signed-off-by: Morten Linderud --- scripts/docs/generate-man.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/docs/generate-man.sh b/scripts/docs/generate-man.sh index 299c422321..136ed1e000 100755 --- a/scripts/docs/generate-man.sh +++ b/scripts/docs/generate-man.sh @@ -4,8 +4,10 @@ set -eu -o pipefail mkdir -p ./man/man1 -# yay, go install creates a binary named "v2" ¯\_(ツ)_/¯ -go build -o "/go/bin/md2man" ./vendor/github.com/cpuguy83/go-md2man/v2 +if ! command -v md2man &> /dev/null; then + # yay, go install creates a binary named "v2" ¯\_(ツ)_/¯ + go build -o "/go/bin/md2man" ./vendor/github.com/cpuguy83/go-md2man/v2 +fi # Generate man pages from cobra commands go build -o /tmp/gen-manpages github.com/docker/cli/man