man: move ctr.1, containerd-config to section 8, and fix generation

I missed this in my previous change: the ctr man page is also
in Section 8, because it's considered an administrative tool,
and containerd-config is related to containerd so updating these
as well.

This commit also fixes naming of the generated files, which was
hard-coded to .1.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2020-04-02 17:30:54 +02:00
parent 9ba5ea232c
commit ad090e67e9
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
4 changed files with 25 additions and 18 deletions

View File

@ -88,7 +88,7 @@ endif
# Project binaries. # Project binaries.
COMMANDS=ctr containerd containerd-stress COMMANDS=ctr containerd containerd-stress
MANPAGES=ctr.1 containerd.8 containerd-config.1 containerd-config.toml.5 MANPAGES=ctr.8 containerd.8 containerd-config.8 containerd-config.toml.5
ifdef BUILDTAGS ifdef BUILDTAGS
GO_BUILDTAGS = ${BUILDTAGS} GO_BUILDTAGS = ${BUILDTAGS}
@ -214,15 +214,15 @@ mandir:
@mkdir -p man @mkdir -p man
# Kept for backwards compatability # Kept for backwards compatability
genman: man/containerd.8 man/ctr.1 genman: man/containerd.8 man/ctr.8
man/containerd.8: FORCE man/containerd.8: FORCE
@echo "$(WHALE) $@" @echo "$(WHALE) $@"
go run cmd/gen-manpages/main.go containerd man/ go run cmd/gen-manpages/main.go $(@F) $(@D)
man/ctr.1: FORCE man/ctr.8: FORCE
@echo "$(WHALE) $@" @echo "$(WHALE) $@"
go run cmd/gen-manpages/main.go ctr man/ go run cmd/gen-manpages/main.go $(@F) $(@D)
man/%: docs/man/%.md FORCE man/%: docs/man/%.md FORCE
@echo "$(WHALE) $@" @echo "$(WHALE) $@"

View File

@ -22,6 +22,7 @@ import (
"io/ioutil" "io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"strings"
"github.com/containerd/containerd/cmd/containerd/command" "github.com/containerd/containerd/cmd/containerd/command"
"github.com/containerd/containerd/cmd/ctr/app" "github.com/containerd/containerd/cmd/ctr/app"
@ -41,22 +42,28 @@ func run() error {
"containerd": command.App(), "containerd": command.App(),
"ctr": app.New(), "ctr": app.New(),
} }
name := flag.Arg(0)
dir := flag.Arg(1) dir := flag.Arg(1)
app, ok := apps[name]
if !ok { parts := strings.SplitN(flag.Arg(0), ".", 2)
return fmt.Errorf("Invalid application '%s'", name) if len(parts) != 2 {
return fmt.Errorf("invalid name '%s': name does not contain man page section", flag.Arg(0))
} }
name, section := parts[0], parts[1]
appName, 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 // clear out the usage as we use banners that do not display in man pages
app.Usage = "" appName.Usage = ""
data, err := app.ToMan() appName.ToMan()
data, err := appName.ToMan()
if err != nil { if err != nil {
return err return err
} }
if _, err := os.Stat(dir); os.IsNotExist(err) { _ = os.MkdirAll(dir, os.ModePerm)
os.Mkdir(dir, os.ModePerm) if err := ioutil.WriteFile(filepath.Join(dir, fmt.Sprintf("%s.%s", name, section)), []byte(data), 0644); err != nil {
}
if err := ioutil.WriteFile(filepath.Join(dir, fmt.Sprintf("%s.1", name)), []byte(data), 0644); err != nil {
return err return err
} }
return nil return nil

View File

@ -1,4 +1,4 @@
# containerd-config 1 01/30/2018 # containerd-config 8 01/30/2018
## NAME ## NAME
@ -38,4 +38,4 @@ Phil Estes <estesp@gmail.com>
## SEE ALSO ## SEE ALSO
ctr(1), containerd(8), containerd-config.toml(5) ctr(8), containerd(8), containerd-config.toml(5)

View File

@ -142,4 +142,4 @@ Phil Estes <estesp@gmail.com>
## SEE ALSO ## SEE ALSO
ctr(1), containerd-config(1), containerd(8) ctr(8), containerd-config(8), containerd(8)