Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var AddCmd = &cobra.Command{ Use: "add [<pack> | -f <packs list>]", Short: "Add Open-CMSIS-Pack packages", Long: ` Add a pack using the following "<pack>" specification or using packs provided by "-f <packs list>": $ cpackget add Vendor.Pack.1.2.3 $ cpackget add Vendor::Pack@1.2.3 Use the syntax above to let cpackget determine the location of pack files prior to installing it locally. $ cpackget add Vendor.Pack.1.2.3.pack Use this syntax if you already have a pack at hand and simply want to install it under pack-root folder. $ cpackget add path/to/Vendor.Pack.pdsc Use this syntax if you are installing a pack that has not been released yet. This will install it as a local pack and keep a reference in ".Local/local_repository.pidx". The file can be a local file or a file hosted somewhere else on the Internet. If it's hosted somewhere, cpackget will first download it then extract all pack files into "CMSIS_PACK_ROOT/<vendor>/<packName>/<x.y.z>/" If "-f" is used, cpackget will call "cpackget pack add" on each URL specified in the <packs list> file.`, Args: cobra.MinimumNArgs(0), PersistentPreRunE: configureInstaller, RunE: func(cmd *cobra.Command, args []string) error { if addCmdFlags.packsListFileName != "" { log.Infof("Parsing packs urls via file %v", addCmdFlags.packsListFileName) file, err := os.Open(addCmdFlags.packsListFileName) if err != nil { return err } defer file.Close() scanner := bufio.NewScanner(file) for scanner.Scan() { args = append(args, scanner.Text()) } if err := scanner.Err(); err != nil { return err } } if len(args) == 0 { log.Error("Missing a pack-path or list with pack urls specified via -f/--packs-list-filename") return errs.ErrIncorrectCmdArgs } log.Debugf("Specified packs %v", args) var lastErr error installer.UnlockPackRoot() for _, packPath := range args { var err error if filepath.Ext(packPath) == ".pdsc" { err = installer.AddPdsc(packPath) } else { err = installer.AddPack(packPath, !addCmdFlags.skipEula, addCmdFlags.extractEula, addCmdFlags.forceReinstall, viper.GetInt("timeout")) } if err != nil { lastErr = err if !errs.AlreadyLogged(err) { log.Error(err) } } } installer.LockPackRoot() return lastErr }, }
View Source
var AllCommands = []*cobra.Command{ PackCmd, PdscCmd, IndexCmd, InitCmd, AddCmd, RmCmd, ListCmd, UpdateIndexCmd, ChecksumCreateCmd, ChecksumVerifyCmd, SignatureCreateCmd, SignatureVerifyCmd, }
AllCommands contains all available commands for cpackget
View Source
var ChecksumCreateCmd = &cobra.Command{ Use: "checksum-create [<local .path pack>]", Short: "Generates a .checksum file containing the digests of a pack", Long: ` Creates a .checksum file of a local pack. This file contains the digests of the contents of the pack. Example <Vendor.Pack.1.2.3.sha256.checksum> file: "6f95628e4e0824b0ff4a9f49dad1c3eb073b27c2dd84de3b985f0ef3405ca9ca Vendor.Pack.1.2.3.pdsc 435fsdf..." The referenced pack must be in its original/compressed form (.pack), and be present locally: $ cpackget checksum-create Vendor.Pack.1.2.3.pack The default Cryptographic Hash Function used is "` + cryptography.Hashes[0] + `". In the future other hash functions might be supported. The used function will be prefixed to the ".checksum" extension. By default the checksum file will be created in the same directory as the provided pack.`, Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { return cryptography.GenerateChecksum(args[0], checksumCreateCmdFlags.outputDir, checksumCreateCmdFlags.hashAlgorithm) }, }
View Source
var ChecksumVerifyCmd = &cobra.Command{ Use: "checksum-verify [<local .path pack>]", Short: "Verifies the integrity of a pack using its .checksum file", Long: ` Verifies the contents of a pack, checking its integrity against its .checksum file (created with "checksum-create"), present in the same directory: $ cpackget checksum-verify Vendor.Pack.1.2.3.pack The used hash function is inferred from the checksum filename, and if any of the digests computed doesn't match the one provided in the checksum file an error will be thrown. If the .checksum file is in another directory, specify it with the -p/--path flag`, Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { if checksumVerifyCmdFlags.checksumPath != "" { return cryptography.VerifyChecksum(args[0], checksumVerifyCmdFlags.checksumPath) } return cryptography.VerifyChecksum(args[0], "") }, }
View Source
var CopyRight string
View Source
var IndexCmd = &cobra.Command{ Deprecated: "Consider running `cpackget update-index` instead", Use: "index <index url>", Short: "Updates public index", Long: getLongIndexDescription(), PersistentPreRunE: configureInstaller, Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { log.Infof("Updating index %v", args) indexPath := args[0] installer.UnlockPackRoot() err := installer.UpdatePublicIndex(indexPath, overwrite, true, false, viper.GetInt("concurrent-downloads"), viper.GetInt("timeout")) installer.LockPackRoot() return err }, }
View Source
var InitCmd = &cobra.Command{ Use: "init [--pack-root <pack root>] <index-url>", Short: "Initializes a pack root folder", Long: `Initializes a pack root folder specified by -R/--pack-root command line or via the CMSIS_PACK_ROOT environment variable with the following contents: - .Download/ - .Local/ - .Web/ - .Web/index.pidx (downloaded from <index-url>) The index-url is mandatory. Ex "cpackget init --pack-root path/to/mypackroot https://www.keil.com/pack/index.pidx"`, Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { packRoot := viper.GetString("pack-root") indexPath := args[0] log.Debugf("Initializing a new pack root in \"%v\" using index url \"%v\"", packRoot, indexPath) createPackRoot = true err := configureInstaller(cmd, args) if err != nil { return err } installer.UnlockPackRoot() err = installer.UpdatePublicIndex(indexPath, true, true, initCmdFlags.downloadPdscFiles, viper.GetInt("concurrent-downloads"), viper.GetInt("timeout")) installer.LockPackRoot() return err }, }
View Source
var ListCmd = &cobra.Command{ Use: "list [--cached|--public]", Short: "List installed packs", Long: `List all installed packs and optionally cached pack files`, Args: cobra.MaximumNArgs(0), PersistentPreRunE: configureInstaller, RunE: func(cmd *cobra.Command, args []string) error { return installer.ListInstalledPacks(listCmdFlags.listCached, listCmdFlags.listPublic, listCmdFlags.listFilter) }, }
View Source
var PackCmd = &cobra.Command{
Deprecated: "Consider running `cpackget add|rm|list` instead",
Use: "pack",
Short: "Adds/Removes Open-CMSIS-Pack packages",
Long: "Adds/Removes Open-CMSIS-Pack packages from a local file or a file hosted somewhere else on the Internet.",
PersistentPreRunE: configureInstaller,
}
View Source
var PdscCmd = &cobra.Command{
Deprecated: "Consider running `cpackget add|rm|list` instead",
Use: "pdsc",
Short: "Adds or removes Open-CMSIS-Pack packages in the local file system via PDSC files.",
PersistentPreRunE: configureInstaller,
}
View Source
var RmCmd = &cobra.Command{ Use: "rm <pack reference>", Short: "Remove Open-CMSIS-Pack packages", Long: ` Remove a pack using the reference "Vendor.Pack[.x.y.z]", "Vendor::Pack[@x.y.z]" or "[path/to/]Vendor.Pack.pdsc". $ cpackget rm Vendor.Pack.1.2.3 $ cpackget rm Vendor::Pack@1.2.3 Use the syntax above to let cpackget determine the location of pack files prior to removing them. $ cpackget rm Vendor.LocalPackInstalledViaPdsc.pdsc $ cpackget rm path/to/Vendor.LocalPackInstalledViaPdsc.pdsc cpackget also identifies if the pack was installed via PDSC file. In this case, cpackget will remove its reference from ".Local/local_repository.pidx". In the first example, since just the basename of the PDSC file path was specified, cpackget will remove *ALL* references of the PDSC file it might find. Since it is possible to have many versions of the same pack installed via different PDSC file paths, one may wish to remove a specific one by specifying a more complete PDSC file path, as shown in the second example. The version "x.y.z" is optional. Cache files (i.e. under CMSIS_PACK_ROOT/.Download/) are *NOT* removed. If cache files need to be actually removed, please use "--purge".`, Args: cobra.MinimumNArgs(1), PersistentPreRunE: configureInstaller, RunE: func(cmd *cobra.Command, args []string) error { log.Infof("Removing %v", args) var lastErr error installer.UnlockPackRoot() for _, packPath := range args { var err error if filepath.Ext(packPath) == ".pdsc" { err = installer.RemovePdsc(packPath) if err == errs.ErrPdscEntryNotFound { err = errs.ErrPackNotInstalled } } else { err = installer.RemovePack(packPath, rmCmdFlags.purge, viper.GetInt("timeout")) } if err != nil { if err != errs.ErrAlreadyLogged { log.Error(err) err = errs.ErrAlreadyLogged } lastErr = err } } installer.LockPackRoot() return lastErr }, }
View Source
var SignatureCreateCmd = &cobra.Command{ Use: "signature-create [<local .path pack>]", Short: "Create a digest list of a pack and signs it", Long: ` Generates a digest list of a pack, and signs it, creating a detached PGP signature. This creates a ".checksum" file, containing hashes of the contents of the provided pack. It then gets processed and signed with a private key, producing a PGP signature, stored in the equivalent ".signature". If a .checksum file already exists in the target path, it will fail as to guarantee hash freshness. Currently Curve25519 and RSA (2048, 3072, 4096 bits) key types are supported. If no private key (it MUST be in GPG PEM format) is provided with the -k/--key-path, one will be created using the builtin GopenPGP module. The contents of the generated ".checksum" file are the same as the one created by "cpackget checksum-create": "6f95628e4e0824b0ff4a9f49dad1c3eb073b27c2dd84de3b985f0ef3405ca9ca Vendor.Pack.1.2.3.pdsc 435fsdf..." The referenced pack must be in its original/compressed form (.pack), and be present locally: $ cpackget signature-create Vendor.Pack.1.2.3.pack By default the signature file will be created in the same directory as the provided pack.`, Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { if signatureCreateCmdFlags.keyPath == "" && signatureCreateCmdFlags.passphrase != "" { log.Error("-p/--passphrase is only specified when providing a key") return errs.ErrIncorrectCmdArgs } return cryptography.GenerateSignedChecksum(args[0], signatureCreateCmdFlags.keyPath, signatureCreateCmdFlags.outputDir, signatureCreateCmdFlags.passphrase, signatureCreateCmdFlags.outputB64) }, }
View Source
var SignatureVerifyCmd = &cobra.Command{ Use: "signature-verify [<local .checksum pack>] [<local private gpg key>]", Short: "Verifies the integrity of a .checksum against its signature", Long: ` Verifies the integrity and authenticity of a .checksum file, by checking it against a provided .signature file (a detached PGP signature) and a private GPG key (either RSA or Curve25519). The .signature and key files should have been created with the "signature-create" command, as they need to be in the PEM format. If not specified by the -s/--sig-path flag, the .signature path will be read from the same directory as the .checksum file: $ cpackget checksum-verify Vendor.Pack.1.2.3.sha256.checksum signature_curve25519.key The passphrase prompt can be skipped with -p/--passphrase, which is useful for CI and automation but should be used carefully as it exposes the passphrase.`, Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { return cryptography.VerifySignature(args[0], args[1], signatureVerifyCmdFlags.signaturePath, signatureVerifyCmdFlags.passphrase) }, }
View Source
var UpdateIndexCmd = &cobra.Command{ Use: "update-index", Short: "Update the public index", Long: getLongUpdateDescription(), PersistentPreRunE: configureInstaller, Args: cobra.ExactArgs(0), RunE: func(cmd *cobra.Command, args []string) error { log.Infof("Updating public index") installer.UnlockPackRoot() err := installer.UpdatePublicIndex("", true, updateIndexCmdFlags.sparse, false, viper.GetInt("concurrent-downloads"), viper.GetInt("timeout")) installer.LockPackRoot() return err }, }
View Source
var Version string
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.