Skip to content

Commit 036db34

Browse files
committed
build: Fix manpage generation
Seems to be that docs/man/ctr.1.md and docs/man/containerd.1.md were removed in #3637 and were not updated correctly in the Makefile, leading to build failures like: + make man make: *** No rule to make target `man/ctr.1', needed by `man'. Stop. Changes the gen-manpages command to be specific on which manpages are to be generated. Signed-off-by: Eli Uriegas <[email protected]>
1 parent 614c085 commit 036db34

3 files changed

Lines changed: 29 additions & 17 deletions

File tree

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ script:
7777
- go build -i .
7878
- make check
7979
- if [ "$GOOS" = "linux" ]; then make check-protos check-api-descriptors; fi
80+
- if [ "$TRAVIS_GOOS" = "linux" ]; then make man ; fi
8081
- make build
8182
- make binaries
8283
- if [ "$TRAVIS_GOOS" = "linux" ]; then sudo make install ; fi

Makefile

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,19 @@ man: mandir $(addprefix man/,$(MANPAGES))
203203
mandir:
204204
@mkdir -p man
205205

206-
genman: FORCE
207-
go run cmd/gen-manpages/main.go man/
206+
# Kept for backwards compatability
207+
genman: man/containerd.1 man/ctr.1
208+
209+
man/containerd.1: FORCE
210+
@echo "$(WHALE) $@"
211+
go run cmd/gen-manpages/main.go containerd man/
212+
213+
man/ctr.1: FORCE
214+
@echo "$(WHALE) $@"
215+
go run cmd/gen-manpages/main.go ctr man/
208216

209217
man/%: docs/man/%.md FORCE
210-
@echo "$(WHALE) $<"
218+
@echo "$(WHALE) $@"
211219
go-md2man -in "$<" -out "$@"
212220

213221
define installmanpage

cmd/gen-manpages/main.go

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,23 @@ func run() error {
4141
"containerd": command.App(),
4242
"ctr": app.New(),
4343
}
44-
dir := flag.Arg(0)
45-
for name, app := range apps {
46-
// clear out the usage as we use banners that do not display in man pages
47-
app.Usage = ""
48-
data, err := app.ToMan()
49-
if err != nil {
50-
return err
51-
}
52-
if _, err := os.Stat(dir); os.IsNotExist(err) {
53-
os.Mkdir(dir, os.ModePerm)
54-
}
55-
if err := ioutil.WriteFile(filepath.Join(dir, fmt.Sprintf("%s.1", name)), []byte(data), 0644); err != nil {
56-
return err
57-
}
44+
name := flag.Arg(0)
45+
dir := flag.Arg(1)
46+
app, ok := apps[name]
47+
if !ok {
48+
return fmt.Errorf("Invalid application '%s'", name)
49+
}
50+
// clear out the usage as we use banners that do not display in man pages
51+
app.Usage = ""
52+
data, err := app.ToMan()
53+
if err != nil {
54+
return err
55+
}
56+
if _, err := os.Stat(dir); os.IsNotExist(err) {
57+
os.Mkdir(dir, os.ModePerm)
58+
}
59+
if err := ioutil.WriteFile(filepath.Join(dir, fmt.Sprintf("%s.1", name)), []byte(data), 0644); err != nil {
60+
return err
5861
}
5962
return nil
6063
}

0 commit comments

Comments
 (0)