Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Fix manpage generation #3729

Merged
merged 1 commit into from Oct 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -77,6 +77,7 @@ script:
- go build -i .
- make check
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this needs to be skipped for Darwin

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to do lower on, and with a check for TRAVIS_GOOS=linux

- if [ "$GOOS" = "linux" ]; then make check-protos check-api-descriptors; fi
- if [ "$TRAVIS_GOOS" = "linux" ]; then make man ; fi
- make build
- make binaries
- if [ "$TRAVIS_GOOS" = "linux" ]; then sudo make install ; fi
Expand Down
14 changes: 11 additions & 3 deletions Makefile
Expand Up @@ -203,11 +203,19 @@ man: mandir $(addprefix man/,$(MANPAGES))
mandir:
@mkdir -p man

genman: FORCE
go run cmd/gen-manpages/main.go man/
# Kept for backwards compatability
genman: man/containerd.1 man/ctr.1

man/containerd.1: FORCE
@echo "$(WHALE) $@"
go run cmd/gen-manpages/main.go containerd man/

man/ctr.1: FORCE
@echo "$(WHALE) $@"
go run cmd/gen-manpages/main.go ctr man/

man/%: docs/man/%.md FORCE
@echo "$(WHALE) $<"
@echo "$(WHALE) $@"
go-md2man -in "$<" -out "$@"

define installmanpage
Expand Down
31 changes: 17 additions & 14 deletions cmd/gen-manpages/main.go
Expand Up @@ -41,20 +41,23 @@ func run() error {
"containerd": command.App(),
"ctr": app.New(),
}
dir := flag.Arg(0)
for name, app := range apps {
// clear out the usage as we use banners that do not display in man pages
app.Usage = ""
data, err := app.ToMan()
if err != nil {
return err
}
if _, err := os.Stat(dir); os.IsNotExist(err) {
os.Mkdir(dir, os.ModePerm)
}
if err := ioutil.WriteFile(filepath.Join(dir, fmt.Sprintf("%s.1", name)), []byte(data), 0644); err != nil {
return err
}
name := flag.Arg(0)
dir := flag.Arg(1)
app, ok := apps[name]
if !ok {
return fmt.Errorf("Invalid application '%s'", name)
}
// clear out the usage as we use banners that do not display in man pages
app.Usage = ""
data, err := app.ToMan()
if err != nil {
return err
}
if _, err := os.Stat(dir); os.IsNotExist(err) {
os.Mkdir(dir, os.ModePerm)
}
if err := ioutil.WriteFile(filepath.Join(dir, fmt.Sprintf("%s.1", name)), []byte(data), 0644); err != nil {
return err
}
return nil
}