blob: 6474d9f7da5ac95b9898b54d205c53b8800ef7cb [file] [log] [blame]
package actions
import (
"context"
"strings"
"cos.googlesource.com/cos/tools.git/src/pkg/dkms"
"github.com/spf13/cobra"
)
var addCmd = &cobra.Command{
Use: "add",
Short: "Adds a package to the DKMS source tree",
Long: strings.TrimSpace(`
Adds a package to the DKMS source tree.
This checks the user source tree (by default, /usr/src/)
for the package source files. If the sources don't exist there,
this will check the local ${package-name}-${package-version} path
and try to copy sources from there to the user source tree, then
add the copied sources to the DKMS tree.
If a --gcs-bucket is provided, this will check the bucket for
sources if they are not present locally. If --upload is also
specified, this will upload the sources to the DKMS tree in the
bucket after they have been added to the local DKMS tree.
If the DKMS tree does not already exist, this will create it.
If the package has already been added, this does nothing.
`),
Args: ParseArgs,
RunE: func(cmd *cobra.Command, args []string) error {
if RootGCSBucket == nil {
return dkms.Add(RootPackage, RootOptions)
} else {
return dkms.CachedAdd(context.Background(), RootPackage, RootGCSBucket, RootOptions)
}
},
}
func init() {
rootCmd.AddCommand(addCmd)
}