16306: Command usage help.
authorTom Clegg <tom@curii.com>
Thu, 7 Jan 2021 22:24:29 +0000 (17:24 -0500)
committerTom Clegg <tom@curii.com>
Thu, 7 Jan 2021 22:24:29 +0000 (17:24 -0500)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@curii.com>

cmd/arvados-package/build.go
cmd/arvados-package/cmd.go

index c859792686db25af5f2e262c39c38aa4b84f5614..cf9cbfa6c322fc6b3730e1d3c078605288f94fe5 100644 (file)
@@ -108,7 +108,7 @@ func build(ctx context.Context, opts opts, stdin io.Reader, stdout, stderr io.Wr
                "-v", selfbin+":/arvados-package:ro",
                "-v", opts.SourceDir+":/arvados:ro",
                buildImageName,
-               "eatmydata", "/arvados-package", "fpm",
+               "eatmydata", "/arvados-package", "_fpm",
                "-source", "/arvados",
                "-package-version", opts.PackageVersion,
                "-package-dir", "/pkg",
index 9b9971e92c5ae6e0eeb6e4fb09684296ebba8574..6cf3ba3c0abeda9f4b7d6fb86da29a7f9311f1e1 100644 (file)
@@ -11,6 +11,7 @@ import (
        "io"
        "os"
        "path/filepath"
+       "strings"
 
        "git.arvados.org/arvados.git/lib/cmd"
        "git.arvados.org/arvados.git/lib/install"
@@ -24,13 +25,17 @@ var (
                "--version": cmd.Version,
 
                "build":       cmdFunc(build),
-               "fpm":         cmdFunc(fpm),
                "testinstall": cmdFunc(testinstall),
+               "_fpm":        cmdFunc(fpm),    // internal use
                "_install":    install.Command, // internal use
        })
 )
 
 func main() {
+       if len(os.Args) < 2 || strings.HasPrefix(os.Args[1], "-") {
+               parseFlags([]string{"-help"})
+               os.Exit(2)
+       }
        os.Exit(handler.RunCommand(os.Args[0], os.Args[1:], os.Stdin, os.Stdout, os.Stderr))
 }
 
@@ -72,6 +77,37 @@ func parseFlags(args []string) (opts, error) {
        flags.StringVar(&opts.PackageChown, "package-chown", opts.PackageChown, "desired uid:gid for new package (default is current user:group)")
        flags.StringVar(&opts.TargetOS, "target-os", opts.TargetOS, "target operating system vendor:version")
        flags.BoolVar(&opts.RebuildImage, "rebuild-image", opts.RebuildImage, "rebuild docker image(s) instead of using existing")
+       flags.Usage = func() {
+               fmt.Fprint(flags.Output(), `Usage: arvados-package <subcommand> [options]
+
+Subcommands:
+       build
+               use a docker container to build a package from a checked
+               out version of the arvados source tree
+       testinstall
+               use a docker container to install a package and confirm
+               the resulting installation is functional
+       version
+               show program version
+
+Internally used subcommands:
+       _fpm
+               build a package
+       _install
+               equivalent to "arvados-server install"
+
+Automation/integration notes:
+       The first time a given machine runs "build" or "testinstall" (and
+       any time the -rebuild-image is used), new docker images are built,
+       which is quite slow. If you use on-demand VMs to run automated builds,
+       run "build" and "testinstall" once when setting up your initial VM
+       image, and be prepared to rebuild that VM image when package-building
+       slows down (this will happen when new dependencies are introduced).
+
+Options:
+`)
+               flags.PrintDefaults()
+       }
        err := flags.Parse(args)
        if err != nil {
                return opts, err