installer

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 18, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddPack

func AddPack(packPath string, checkEula, extractEula bool) error

AddPack adds a pack to the pack installation directory structure

func AddPdsc

func AddPdsc(pdscPath string) error

AddPdsc adds a pack via PDSC file

func FindPackURL added in v0.3.0

func FindPackURL(pack *PackType) (string, error)

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 ListInstalledPacks added in v0.3.0

func ListInstalledPacks(listCached, listPublic bool) error

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 os.RemoveAll(localTestingDir)

log.SetOutput(os.Stdout)
defer log.SetOutput(ioutil.Discard)

_ = installer.ListInstalledPacks(!ListCached, !ListPublic)
Output:
I: Listing installed packs
I: (no packs installed)
Example (EmptyCache)
localTestingDir := "test-list-empty-cache"
_ = installer.SetPackRoot(localTestingDir, CreatePackRoot)
defer os.RemoveAll(localTestingDir)

log.SetOutput(os.Stdout)
defer log.SetOutput(ioutil.Discard)

_ = installer.ListInstalledPacks(ListCached, !ListPublic)
Output:
I: Listing cached packs
I: (no packs cached)
Example (EmptyPublicIndex)
localTestingDir := "test-list-empty-index"
_ = installer.SetPackRoot(localTestingDir, CreatePackRoot)
defer os.RemoveAll(localTestingDir)

log.SetOutput(os.Stdout)
defer log.SetOutput(ioutil.Discard)

_ = installer.ListInstalledPacks(ListCached, ListPublic)
Output:
I: Listing packs from the public index
I: (no packs in public index)
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)
defer os.RemoveAll(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)
_ = installer.AddPack(publicLocalPack124, !CheckEula, !ExtractEula)
_ = installer.RemovePack("TheVendor.PublicLocalPack.1.2.3", false /*no purge*/)

log.SetOutput(os.Stdout)
defer log.SetOutput(ioutil.Discard)
_ = installer.ListInstalledPacks(ListCached, ListPublic)
Output:
I: Listing packs from the public index
I: TheVendor.PublicLocalPack.1.2.3 (cached)
I: TheVendor.PublicLocalPack.1.2.4 (installed)
I: TheVendor.PublicLocalPack.1.2.5
Example (ListCached)
localTestingDir := "test-list-cached-packs"
_ = installer.SetPackRoot(localTestingDir, CreatePackRoot)
defer os.RemoveAll(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)
_ = installer.AddPack(publicLocalPack124, !CheckEula, !ExtractEula)
_ = installer.RemovePack("TheVendor.PublicLocalPack.1.2.3", false /*no purge*/)

log.SetOutput(os.Stdout)
defer log.SetOutput(ioutil.Discard)
_ = installer.ListInstalledPacks(ListCached, !ListPublic)
Output:
I: Listing cached packs
I: TheVendor.PublicLocalPack.1.2.3
I: TheVendor.PublicLocalPack.1.2.4 (installed)
Example (ListInstalled)
localTestingDir := "test-list-installed-packs"
_ = installer.SetPackRoot(localTestingDir, CreatePackRoot)
defer os.RemoveAll(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)
_ = installer.AddPack(publicLocalPack124, !CheckEula, !ExtractEula)
_ = installer.RemovePack("TheVendor.PublicLocalPack.1.2.3", false /*no purge*/)

log.SetOutput(os.Stdout)
defer log.SetOutput(ioutil.Discard)
_ = installer.ListInstalledPacks(!ListCached, !ListPublic)
Output:
I: Listing installed packs
I: TheVendor.PublicLocalPack.1.2.4

func RemovePack

func RemovePack(packPath string, purge bool) error

RemovePack removes a pack given a pack path

func RemovePdsc

func RemovePdsc(pdscPath string) error

RemovePdsc removes a pack given a pdsc path

func SetPackRoot

func SetPackRoot(packRoot string, create bool) error

SetPackRoot sets the working directory of the packs installation if create == true, cpackget will try to create needed resources

func UpdatePublicIndex added in v0.2.0

func UpdatePublicIndex(indexPath string, overwrite bool) error

UpdatePublicIndex receives a index path and place it under .Web/index.pidx.

Types

type PackType

type PackType struct {
	xml.PdscTag

	// 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
	// contains filtered or unexported fields
}

PackType is the struct that represents the installation of a single pack

func (*PackType) PackFileName added in v0.3.0

func (p *PackType) PackFileName() string

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

func (p *PackType) PackID() string

PackID retuns the most generic name of a pack: Vendor.PackName

func (*PackType) PackIDWithVersion added in v0.3.0

func (p *PackType) PackIDWithVersion() string

PackIDWithVersion returns the packID with version: Vendor.PackName.x.y.z

func (*PackType) PdscFileName added in v0.3.0

func (p *PackType) PdscFileName() string

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

func (p *PackType) PdscFileNameWithVersion() string

PdscFileNameWithVersion returns a string with how the pack's pdsc file name would be: Vendor.PackName.x.y.z.pdsc

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

type PdscType

type PdscType struct {
	xml.PdscTag
	// contains filtered or unexported fields
}

PdscType is the struct that represents the installation of a pack via PDSC file

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL