in cli/mfg_cmds.go [664:797]
func AddMfgCommands(cmd *cobra.Command) {
mfgCmd := &cobra.Command{
Use: "mfg",
Short: "Manipulates Mynewt manufacturing images",
Run: func(cmd *cobra.Command, args []string) {
cmd.Usage()
},
}
cmd.AddCommand(mfgCmd)
showCmd := &cobra.Command{
Use: "show <mfgimg.bin> <meta-end-offset>",
Short: "Displays JSON describing a manufacturing image",
Run: runMfgShowCmd,
}
mfgCmd.AddCommand(showCmd)
splitCmd := &cobra.Command{
Use: "split <mfgimage-dir> <out-dir>",
Short: "Splits a Mynewt mfg section into several files",
Run: runSplitCmd,
}
mfgCmd.AddCommand(splitCmd)
joinCmd := &cobra.Command{
Use: "join <split-dir> <out-dir>",
Short: "Joins a split mfg section into a single file",
Run: runJoinCmd,
}
mfgCmd.AddCommand(joinCmd)
swapIskCmd := &cobra.Command{
Use: "swapisk <mfgimg-bin> <cur-key-der> <new-key-der>",
Short: "Replaces an image-signing key in a manufacturing image",
Run: runSwapIskCmd,
}
swapIskCmd.PersistentFlags().StringVarP(&OptOutFilename, "outfile", "o",
"", "File to write to")
swapIskCmd.PersistentFlags().BoolVarP(&OptInPlace, "inplace", "i", false,
"Replace input file")
mfgCmd.AddCommand(swapIskCmd)
swapKekCmd := &cobra.Command{
Use: "swapkek <mfgimg-bin> <cur-key-der> <new-key-der>",
Short: "Replaces a key-encrypting key in a manufacturing image",
Run: runSwapKekCmd,
}
swapKekCmd.PersistentFlags().StringVarP(&OptOutFilename, "outfile", "o",
"", "File to write to")
swapKekCmd.PersistentFlags().BoolVarP(&OptInPlace, "inplace", "i", false,
"Replace input file")
mfgCmd.AddCommand(swapKekCmd)
hashableCmd := &cobra.Command{
Use: "hashable <mfgimage-dir>",
Short: "Extracts the hashable / signable content of an mfgimage",
Run: runMfgHashableCmd,
}
hashableCmd.PersistentFlags().StringVarP(&OptOutFilename, "outfile", "o",
"", "File to write to")
mfgCmd.AddCommand(hashableCmd)
rehashCmd := &cobra.Command{
Use: "rehash <mfgimage-dir>",
Short: "Replaces an outdated mfgimage hash with an accurate one",
Run: runRehashCmd,
}
rehashCmd.PersistentFlags().StringVarP(&OptOutFilename, "outdir", "o",
"", "Directory to write to")
rehashCmd.PersistentFlags().BoolVarP(&OptInPlace, "inplace", "i", false,
"Replace input files")
mfgCmd.AddCommand(rehashCmd)
rmsigsCmd := &cobra.Command{
Use: "rmsigs <mfgimage-dir>",
Short: "Removes all signatures from an mfgimage's manifest",
Run: runRmsigsMfgCmd,
}
rmsigsCmd.PersistentFlags().StringVarP(&OptOutFilename, "outdir", "o",
"", "Directory to write to")
rmsigsCmd.PersistentFlags().BoolVarP(&OptInPlace, "inplace", "i", false,
"Replace input files")
mfgCmd.AddCommand(rmsigsCmd)
addsigCmd := &cobra.Command{
Use: "addsig <mfgimage-dir> <pub-key-der> <sig-der>",
Short: "Adds a signature to an mfgimage's manifest",
Run: runAddsigMfgCmd,
}
addsigCmd.PersistentFlags().StringVarP(&OptOutFilename, "outdir", "o",
"", "Directory to write to")
addsigCmd.PersistentFlags().BoolVarP(&OptInPlace, "inplace", "i", false,
"Replace input files")
mfgCmd.AddCommand(addsigCmd)
rmtlvsCmd := &cobra.Command{
Use: "rmtlvs <mfgimage-dir> <tlv-index> [tlv-index] [...]",
Short: "Removes the specified TLVs from a Mynewt mfgimage",
Run: runRmtlvsMfgCmd,
}
rmtlvsCmd.PersistentFlags().StringVarP(&OptOutFilename, "outfile", "o", "",
"File to write to")
rmtlvsCmd.PersistentFlags().BoolVarP(&OptInPlace, "inplace", "i", false,
"Replace input file")
mfgCmd.AddCommand(rmtlvsCmd)
verifyCmd := &cobra.Command{
Use: "verify <mfgimage-dir>",
Short: "Verifies an Mynewt mfgimage's integrity",
Run: runVerifyMfgCmd,
}
verifyCmd.PersistentFlags().BoolVar(&OptVerifyImages, "images", false,
"Verify embedded images")
verifyCmd.PersistentFlags().StringSliceVar(&OptSignKeys, "signkey",
nil, "Public signing key (.pem) (can be repeated)")
verifyCmd.PersistentFlags().StringSliceVar(&OptEncKeys, "enckey",
nil, "Private encryption key (.der) (can be repeated)")
mfgCmd.AddCommand(verifyCmd)
}