Documentation ¶
Index ¶
- Constants
- func AddPack(packPath string, checkEula, extractEula, forceReinstall, noRequirements bool, ...) error
- func AddPdsc(pdscPath string) error
- func CheckConcurrency(concurrency int) int
- func DownloadPDSCFiles(skipInstalledPdscFiles bool, concurrency int, timeout int) error
- func FindPackURL(pack *PackType) (string, error)
- func GetDefaultCmsisPackRoot() string
- func GetIndexPath(indexPath string) (string, error)
- func ListInstalledPacks(listCached, listPublic, listRequirements bool, listFilter string) error
- func LockPackRoot()
- func RemovePack(packPath string, purge bool, timeout int) error
- func RemovePdsc(pdscPath string) error
- func SetPackRoot(packRoot string, create bool) error
- func UnlockPackRoot()
- func UpdateInstalledPDSCFiles(pidxXML *xml.PidxXML, concurrency int, timeout int) error
- func UpdatePublicIndex(indexPath string, overwrite bool, sparse bool, downloadPdsc bool, ...) error
- type PackType
- func (p *PackType) GetVersion() string
- func (p *PackType) Lock()
- func (p *PackType) PackFileName() string
- func (p *PackType) PackID() string
- func (p *PackType) PackIDWithVersion() string
- func (p *PackType) PdscFileName() string
- func (p *PackType) PdscFileNameWithVersion() string
- func (p *PackType) RequirementsSatisfied() bool
- func (p *PackType) Unlock()
- type PacksInstallationType
- type PdscType
Examples ¶
- ListInstalledPacks
- ListInstalledPacks (EmptyCache)
- ListInstalledPacks (EmptyPublicIndex)
- ListInstalledPacks (Filter)
- ListInstalledPacks (FilterErrorPackages)
- ListInstalledPacks (FilterInvalidChars)
- ListInstalledPacks (FilteradditionalMessages)
- ListInstalledPacks (List)
- ListInstalledPacks (ListCached)
- ListInstalledPacks (ListMalformedInstalledPacks)
Constants ¶
const KeilDefaultPackRoot = "https://www.keil.com/pack/"
Variables ¶
This section is empty.
Functions ¶
func AddPack ¶
func AddPack(packPath string, checkEula, extractEula, forceReinstall, noRequirements bool, timeout int) error
AddPack adds a pack to the pack installation directory structure
func CheckConcurrency ¶ added in v1.0.1
func DownloadPDSCFiles ¶ added in v1.0.0
func FindPackURL ¶ added in v0.3.0
FindPackURL uses pack.path as packID and try to find the pack URL Finding step are as follows: 1. Find pack.Vendor, pack.Name, pack.Version in Installation.PublicIndex 1.1. if pack.IsPublic == true 1.1.1. read .Web/PDSC file into pdscXML 1.1.2. releastTag = pdscXML.FindReleaseTagByVersion(pack.Version) 1.1.3. if releaseTag.URL != "", return releaseTag.URL 1.1.4. return pdscTag.URL + pack.Vendor + "." + pack.Name + "." + pack.Version + ".pack" 1.2. if pack.IsPublic == false 1.2.1. if pack's pdsc file not found in Installation.LocalDir then raise errs.ErrPackURLCannotBeFound 1.2.2. read .Local/PDSC file into pdscXML 1.2.3. releastTag = pdscXML.FindReleaseTagByVersion(pack.Version) 1.2.3. if releaseTag == nil then raise ErrPackVersionNotFoundInPdsc 1.2.4. if releaseTag.URL != "", return releaseTag.URL 1.2.5. return pdscTag.URL + pack.Vendor + "." + pack.Name + "." + pack.Version + ".pack"
func GetDefaultCmsisPackRoot ¶ added in v0.8.3
func GetDefaultCmsisPackRoot() string
GetDefaultCmsisPackRoot provides a default location for the pack root if not provided. This is to enable a "default mode", where the public index will be automatically initiated if not ready yet.
func GetIndexPath ¶ added in v1.1.0
func ListInstalledPacks ¶ added in v0.3.0
ListInstalledPacks generates a list of all packs present in the pack root folder
Example ¶
Listing on empty
localTestingDir := "test-list-empty-pack-root" _ = installer.SetPackRoot(localTestingDir, CreatePackRoot) defer removePackRoot(localTestingDir) log.SetOutput(os.Stdout) defer log.SetOutput(io.Discard) _ = installer.ListInstalledPacks(!ListCached, !ListPublic, !ListRequirements, ListFilter)
Output: I: Listing installed packs I: (no packs installed)
Example (EmptyCache) ¶
localTestingDir := "test-list-empty-cache" _ = installer.SetPackRoot(localTestingDir, CreatePackRoot) defer removePackRoot(localTestingDir) log.SetOutput(os.Stdout) defer log.SetOutput(io.Discard) _ = installer.ListInstalledPacks(ListCached, !ListPublic, !ListRequirements, ListFilter)
Output: I: Listing cached packs I: (no packs cached)
Example (EmptyPublicIndex) ¶
localTestingDir := "test-list-empty-index" _ = installer.SetPackRoot(localTestingDir, CreatePackRoot) defer removePackRoot(localTestingDir) log.SetOutput(os.Stdout) defer log.SetOutput(io.Discard) _ = installer.ListInstalledPacks(ListCached, ListPublic, !ListRequirements, ListFilter)
Output: I: Listing packs from the public index I: (no packs in public index)
Example (Filter) ¶
localTestingDir := "test-list-packs-filter" _ = installer.SetPackRoot(localTestingDir, CreatePackRoot) installer.UnlockPackRoot() defer removePackRoot(localTestingDir) pdscFilePath := strings.Replace(publicLocalPack123, ".1.2.3.pack", ".pdsc", -1) _ = utils.CopyFile(pdscFilePath, filepath.Join(installer.Installation.WebDir, "TheVendor.PublicLocalPack.pdsc")) _ = installer.Installation.PublicIndexXML.AddPdsc(xml.PdscTag{ Vendor: "TheVendor", Name: "PublicLocalPack", Version: "1.2.3", }) _ = installer.Installation.PublicIndexXML.AddPdsc(xml.PdscTag{ Vendor: "TheVendor", Name: "PublicLocalPack", Version: "1.2.4", }) _ = installer.Installation.PublicIndexXML.AddPdsc(xml.PdscTag{ Vendor: "TheVendor", Name: "PublicLocalPack", Version: "1.2.5", }) _ = installer.AddPack(publicLocalPack123, !CheckEula, !ExtractEula, !ForceReinstall, !NoRequirements, Timeout) _ = installer.AddPack(publicLocalPack124, !CheckEula, !ExtractEula, !ForceReinstall, !NoRequirements, Timeout) _ = installer.RemovePack("TheVendor.PublicLocalPack.1.2.3", false /*no purge*/, Timeout) log.SetOutput(os.Stdout) defer log.SetOutput(io.Discard) _ = installer.ListInstalledPacks(ListCached, ListPublic, !ListRequirements, "1.2.4")
Output: I: Listing packs from the public index, filtering by "1.2.4" I: TheVendor::[email protected] (installed)
Example (FilterErrorPackages) ¶
localTestingDir := "test-list-filter-error-message" _ = installer.SetPackRoot(localTestingDir, CreatePackRoot) installer.UnlockPackRoot() defer removePackRoot(localTestingDir) pdscFilePath := strings.Replace(publicLocalPack123, ".1.2.3.pack", ".pdsc", -1) _ = utils.CopyFile(pdscFilePath, filepath.Join(installer.Installation.WebDir, "TheVendor.PublicLocalPack.pdsc")) _ = installer.Installation.PublicIndexXML.AddPdsc(xml.PdscTag{ Vendor: "TheVendor", Name: "PublicLocalPack", Version: "1.2.3", }) _ = installer.AddPack(publicLocalPack123, !CheckEula, !ExtractEula, !ForceReinstall, !NoRequirements, Timeout) // Temper with the installation folder currVendorFolder := filepath.Join(localTestingDir, "TheVendor") currPackNameFolder := filepath.Join(localTestingDir, "TheVendor", "PublicLocalPack") currVersionFolder := filepath.Join(localTestingDir, "TheVendor", "PublicLocalPack", "1.2.3") temperedVendorFolder := filepath.Join(localTestingDir, "_TheVendor") temperedPackNameFolder := filepath.Join(localTestingDir, "TheVendor", "_PublicLocalPack") temperedVersionFolder := filepath.Join(localTestingDir, "TheVendor", "PublicLocalPack", "1.2.3.4") // Order matters _ = utils.MoveFile(currVersionFolder, temperedVersionFolder) _ = utils.MoveFile(currPackNameFolder, temperedPackNameFolder) _ = utils.MoveFile(currVendorFolder, temperedVendorFolder) log.SetOutput(os.Stdout) defer log.SetOutput(io.Discard) _ = installer.ListInstalledPacks(!ListCached, !ListPublic, !ListRequirements, "TheVendor")
Output: I: Listing installed packs, filtering by "TheVendor" E: _TheVendor::[email protected] - error: pack version incorrect format
Example (FilterInvalidChars) ¶
localTestingDir := "test-list-filter-invalid-chars" _ = installer.SetPackRoot(localTestingDir, CreatePackRoot) installer.UnlockPackRoot() defer removePackRoot(localTestingDir) pdscFilePath := strings.Replace(publicLocalPack123, ".1.2.3.pack", ".pdsc", -1) _ = utils.CopyFile(pdscFilePath, filepath.Join(installer.Installation.WebDir, "TheVendor.PublicLocalPack.pdsc")) _ = installer.Installation.PublicIndexXML.AddPdsc(xml.PdscTag{ Vendor: "TheVendor", Name: "PublicLocalPack", Version: "1.2.3", }) _ = installer.Installation.PublicIndexXML.AddPdsc(xml.PdscTag{ Vendor: "TheVendor", Name: "PublicLocalPack", Version: "1.2.4", }) _ = installer.Installation.PublicIndexXML.AddPdsc(xml.PdscTag{ Vendor: "TheVendor", Name: "PublicLocalPack", Version: "1.2.5", }) _ = installer.AddPack(publicLocalPack123, !CheckEula, !ExtractEula, !ForceReinstall, !NoRequirements, Timeout) _ = installer.AddPack(publicLocalPack124, !CheckEula, !ExtractEula, !ForceReinstall, !NoRequirements, Timeout) _ = installer.RemovePack("TheVendor.PublicLocalPack.1.2.3", false /*no purge*/, Timeout) log.SetOutput(os.Stdout) defer log.SetOutput(io.Discard) _ = installer.ListInstalledPacks(ListCached, ListPublic, !ListRequirements, "@ :")
Output: I: Listing packs from the public index, filtering by "@ :"
Example (FilteradditionalMessages) ¶
localTestingDir := "test-list-filter-additional-messages" _ = installer.SetPackRoot(localTestingDir, CreatePackRoot) installer.UnlockPackRoot() defer removePackRoot(localTestingDir) pdscFilePath := strings.Replace(publicLocalPack123, ".1.2.3.pack", ".pdsc", -1) _ = utils.CopyFile(pdscFilePath, filepath.Join(installer.Installation.WebDir, "TheVendor.PublicLocalPack.pdsc")) _ = installer.Installation.PublicIndexXML.AddPdsc(xml.PdscTag{ Vendor: "TheVendor", Name: "PublicLocalPack", Version: "1.2.3", }) _ = installer.Installation.PublicIndexXML.AddPdsc(xml.PdscTag{ Vendor: "TheVendor", Name: "PublicLocalPack", Version: "1.2.4", }) _ = installer.Installation.PublicIndexXML.AddPdsc(xml.PdscTag{ Vendor: "TheVendor", Name: "PublicLocalPack", Version: "1.2.5", }) _ = installer.AddPack(publicLocalPack123, !CheckEula, !ExtractEula, !ForceReinstall, !NoRequirements, Timeout) _ = installer.AddPack(publicLocalPack124, !CheckEula, !ExtractEula, !ForceReinstall, !NoRequirements, Timeout) _ = installer.RemovePack("TheVendor.PublicLocalPack.1.2.3", false /*no purge*/, Timeout) log.SetOutput(os.Stdout) defer log.SetOutput(io.Discard) _ = installer.ListInstalledPacks(ListCached, !ListPublic, !ListRequirements, "(installed)")
Output: I: Listing cached packs, filtering by "(installed)"
Example (List) ¶
Now list 3 packs from the public index, where * 1 is cached only * 1 is installed * 1 is neither installer or cached, it's just available in the public index
localTestingDir := "test-list-packs" _ = installer.SetPackRoot(localTestingDir, CreatePackRoot) installer.UnlockPackRoot() defer removePackRoot(localTestingDir) pdscFilePath := strings.Replace(publicLocalPack123, ".1.2.3.pack", ".pdsc", -1) _ = utils.CopyFile(pdscFilePath, filepath.Join(installer.Installation.WebDir, "TheVendor.PublicLocalPack.pdsc")) _ = installer.Installation.PublicIndexXML.AddPdsc(xml.PdscTag{ Vendor: "TheVendor", Name: "PublicLocalPack", Version: "1.2.3", }) _ = installer.Installation.PublicIndexXML.AddPdsc(xml.PdscTag{ Vendor: "TheVendor", Name: "PublicLocalPack", Version: "1.2.4", }) _ = installer.Installation.PublicIndexXML.AddPdsc(xml.PdscTag{ Vendor: "TheVendor", Name: "PublicLocalPack", Version: "1.2.5", }) _ = installer.AddPack(publicLocalPack123, !CheckEula, !ExtractEula, !ForceReinstall, !NoRequirements, Timeout) _ = installer.AddPack(publicLocalPack124, !CheckEula, !ExtractEula, !ForceReinstall, !NoRequirements, Timeout) _ = installer.RemovePack("TheVendor.PublicLocalPack.1.2.3", false /*no purge*/, Timeout) log.SetOutput(os.Stdout) defer log.SetOutput(io.Discard) _ = installer.ListInstalledPacks(ListCached, ListPublic, !ListRequirements, ListFilter)
Output: I: Listing packs from the public index I: TheVendor::[email protected] (cached) I: TheVendor::[email protected] (installed) I: TheVendor::[email protected]
Example (ListCached) ¶
localTestingDir := "test-list-cached-packs" _ = installer.SetPackRoot(localTestingDir, CreatePackRoot) installer.UnlockPackRoot() defer removePackRoot(localTestingDir) pdscFilePath := strings.Replace(publicLocalPack123, ".1.2.3.pack", ".pdsc", -1) _ = utils.CopyFile(pdscFilePath, filepath.Join(installer.Installation.WebDir, "TheVendor.PublicLocalPack.pdsc")) _ = installer.Installation.PublicIndexXML.AddPdsc(xml.PdscTag{ Vendor: "TheVendor", Name: "PublicLocalPack", Version: "1.2.3", }) _ = installer.Installation.PublicIndexXML.AddPdsc(xml.PdscTag{ Vendor: "TheVendor", Name: "PublicLocalPack", Version: "1.2.4", }) _ = installer.Installation.PublicIndexXML.AddPdsc(xml.PdscTag{ Vendor: "TheVendor", Name: "PublicLocalPack", Version: "1.2.5", }) _ = installer.AddPack(publicLocalPack123, !CheckEula, !ExtractEula, !ForceReinstall, !NoRequirements, Timeout) _ = installer.AddPack(publicLocalPack124, !CheckEula, !ExtractEula, !ForceReinstall, !NoRequirements, Timeout) _ = installer.RemovePack("TheVendor.PublicLocalPack.1.2.3", false /*no purge*/, Timeout) log.SetOutput(os.Stdout) defer log.SetOutput(io.Discard) _ = installer.ListInstalledPacks(ListCached, !ListPublic, !ListRequirements, ListFilter)
Output: I: Listing cached packs I: TheVendor::[email protected] I: TheVendor::[email protected] (installed)
Example (ListMalformedInstalledPacks) ¶
localTestingDir := "test-list-malformed-installed-packs" _ = installer.SetPackRoot(localTestingDir, CreatePackRoot) installer.UnlockPackRoot() defer removePackRoot(localTestingDir) pdscFilePath := strings.Replace(publicLocalPack123, ".1.2.3.pack", ".pdsc", -1) _ = utils.CopyFile(pdscFilePath, filepath.Join(installer.Installation.WebDir, "TheVendor.PublicLocalPack.pdsc")) _ = installer.Installation.PublicIndexXML.AddPdsc(xml.PdscTag{ Vendor: "TheVendor", Name: "PublicLocalPack", Version: "1.2.3", }) _ = installer.AddPack(publicLocalPack123, !CheckEula, !ExtractEula, !ForceReinstall, !NoRequirements, Timeout) // Temper with the installation folder currVendorFolder := filepath.Join(localTestingDir, "TheVendor") currPackNameFolder := filepath.Join(localTestingDir, "TheVendor", "PublicLocalPack") currVersionFolder := filepath.Join(localTestingDir, "TheVendor", "PublicLocalPack", "1.2.3") temperedVendorFolder := filepath.Join(localTestingDir, "_TheVendor") temperedPackNameFolder := filepath.Join(localTestingDir, "TheVendor", "_PublicLocalPack") temperedVersionFolder := filepath.Join(localTestingDir, "TheVendor", "PublicLocalPack", "1.2.3.4") // Order matters _ = utils.MoveFile(currVersionFolder, temperedVersionFolder) _ = utils.MoveFile(currPackNameFolder, temperedPackNameFolder) _ = utils.MoveFile(currVendorFolder, temperedVendorFolder) log.SetOutput(os.Stdout) defer log.SetOutput(io.Discard) _ = installer.ListInstalledPacks(!ListCached, !ListPublic, !ListRequirements, ListFilter)
Output: I: Listing installed packs E: _TheVendor::[email protected] - error: pack version incorrect format W: 1 error(s) detected
func LockPackRoot ¶ added in v0.7.0
func LockPackRoot()
LockPackRoot enable the read-only flag for the pack-root directory
func RemovePack ¶
RemovePack removes a pack given a pack path
func RemovePdsc ¶
RemovePdsc removes a pack given a pdsc path
func SetPackRoot ¶
SetPackRoot sets the working directory of the packs installation if create == true, cpackget will try to create needed resources
func UnlockPackRoot ¶ added in v0.7.0
func UnlockPackRoot()
UnlockPackRoot disable the read-only flag for the pack-root directory
func UpdateInstalledPDSCFiles ¶ added in v1.0.0
Types ¶
type PackType ¶
type PackType struct { xml.PdscTag //IsLocallySourced tells whether the pack's source is local or an HTTP URL IsLocallySourced bool // IsPublic tells whether the pack exists in the public index or not IsPublic bool // Subfolder stores the subfolder this pack is in the compressed file. Subfolder string // Pdsc holds a pointer to the PDSC file already parsed as XML Pdsc *xml.PdscXML // Requirements represents a packs' dependencies Requirements struct { // contains filtered or unexported fields } // contains filtered or unexported fields }
PackType is the struct that represents the installation of a single pack
func (*PackType) GetVersion ¶ added in v0.4.0
GetVersion makes sure to get the latest version for the pack after parsing possible version modifiers (@~, >=)
func (*PackType) Lock ¶ added in v0.7.0
func (p *PackType) Lock()
Lock sets all files and directories for this pack to Read-Only
func (*PackType) PackFileName ¶ added in v0.3.0
PackFileName returns a string with how the pack file name would be: Vendor.PackName.x.y.z.pack
func (*PackType) PackID ¶ added in v0.3.0
PackID returns the most generic name of a pack: Vendor.PackName
func (*PackType) PackIDWithVersion ¶ added in v0.3.0
PackIDWithVersion returns the packID with version: Vendor.PackName.x.y.z
func (*PackType) PdscFileName ¶ added in v0.3.0
PdscFileName returns a string with how the pack's pdsc file name would be: Vendor.PackName.pdsc
func (*PackType) PdscFileNameWithVersion ¶ added in v0.3.0
PdscFileNameWithVersion returns a string with how the pack's pdsc file name would be: Vendor.PackName.x.y.z.pdsc
func (*PackType) RequirementsSatisfied ¶ added in v0.9.1
type PacksInstallationType ¶
type PacksInstallationType struct { // PackRoot is the working directory if the packs installation PackRoot string // DownloadDir stores copies of all packs that were installed via pack files // from external servers. DownloadDir string // LocalDir stores "local_repository.pidx" containing a list of all packs // installed via PDSC files. LocalDir string // WebDir stores "index.pidx" containing a list of PDSC tags with all // publicly available packs. WebDir string // PublicIndex stores the path PackRoot/WebDir/index.pidx PublicIndex string // PublicIndexXML stores a xml.PidxXML reference for PackRoot/WebDir/index.pidx PublicIndexXML *xml.PidxXML // LocalPidx is a reference to "local_repository.pidx" that contains a flat // list of PDSC tags representing all packs installed via PDSC files. LocalPidx *xml.PidxXML // PackIdx is the "pack.idx" file used by other tools to be notified that // the pack installation had changed. PackIdx string // contains filtered or unexported fields }
PacksInstallationType is the scruct tha manages Open-CMSIS-Pack installation/deletion.
var Installation *PacksInstallationType
Installation is a singleton variable that keeps the only reference to PacksInstallationType
func (*PacksInstallationType) PackIsInstalled ¶
func (p *PacksInstallationType) PackIsInstalled(pack *PackType) bool
PackIsInstalled checks whether a given pack is already installed or not