Documentation ¶
Index ¶
- Constants
- func UnserializeDependencies(serialized string) map[string]bool
- type PkgConfig
- type PkgSortMethod
- type Root
- func (r *Root) ActivatePackage(name, version string) error
- func (r *Root) CanBeRemoved(name, version string) (bool, error)
- func (r *Root) FindPackage(name string, version string) (*PkgConfig, error)
- func (r *Root) FindPackagesByName(name string) ([]PkgConfig, error)
- func (r *Root) InstallPackage(path string, asDependency bool) error
- func (r *Root) IsActive(name, version string) bool
- func (r *Root) IsDependency(name, version string) (bool, error)
- func (r *Root) MarkAsUserInstalled(name, version string) error
- func (r *Root) RemovePackage(name, version string, removeDependencies bool) error
Constants ¶
const DefaultPath = "/ira/ipkg"
DefaultPath is a default path for root
Variables ¶
This section is empty.
Functions ¶
func UnserializeDependencies ¶
UnserializeDependencies get serialized by *PkgConfig.SerializeDependencies() string and returns source map (keys are IDs, values are boolean means dependency is required or not)
Types ¶
type PkgConfig ¶
type PkgConfig struct { Name string Version string Dependencies map[string]bool SupportWindows bool SupportLinux bool Build bool // true when package needs to be built }
PkgConfig presents file $SRCDIR/.ira/config.json as Go structure
func ParseConfig ¶
ParseConfig parse config file set in path and return PkgConfig
func (*PkgConfig) CheckDependencies ¶
CheckDependencies checks if all dependencies are statisfied or not. root is a package root used to package installation. Returns boolean means success of check or fail and error if there were some errors
func (*PkgConfig) ForEachDependency ¶
ForEachDependency runs function func for each dependency Inner function gets name, version and status (required or not) of current dependency If inner function returns error, loop stops and function returns this error
func (*PkgConfig) SerializeDependencies ¶
SerializeDependencies prepares package dependencies for saving in database by saving them in one string. Format: dependencyID1(flag1);dependencyID2(flag2);...;dependencyIDN(flagN) Flag specifies is package required (!) or not (?)
type PkgSortMethod ¶
PkgSortMethod is analog of Less() in sort.Interface: gets two PkgConfig and returns should second be earlier than firsy
var ( SortByName PkgSortMethod = func(first, second *PkgConfig) bool { return sort.StringsAreSorted([]string{second.Name, first.Name}) } SortByVersion PkgSortMethod = func(first, second *PkgConfig) bool { return semver.Compare(first.Version, second.Version) == -1 } )
Sort methods
func (PkgSortMethod) Sort ¶
func (method PkgSortMethod) Sort(pkgs []PkgConfig, reverse bool)
Sort sorts pkgs by PkgSortMethod function (uses sort.Interface internally) If reverse was specified, that would be reversed sort
type Root ¶
type Root struct {
// contains filtered or unexported fields
}
Root is a place where all packages install
func CreateRoot ¶
CreateRoot creates package root on specified path. If directory path not exists, it will be created.
func (*Root) ActivatePackage ¶
func (*Root) FindPackage ¶
FindPackage gets package by name and version. If there is no package, returns sql.ErrNoRows
func (*Root) FindPackagesByName ¶
FindPackagesByName returns all packages with the same name
func (*Root) InstallPackage ¶
InstallPackage installs package which should be set in path. If package is installed by user, asDependency must be false If package must be installed for another program (as dependency), you should set it as true
func (*Root) IsDependency ¶
IsDependency checks is package installed by user (false) or as dependency (true).
func (*Root) MarkAsUserInstalled ¶
MarkAsUserInstalled tries to mark package as installed by user