ipkg

package module
v0.0.0-...-f4dccd7 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2023 License: GPL-3.0 Imports: 18 Imported by: 0

README

IRA PKG

IRA Package Manager's basic instrument for working with .ipkg files

Documentation

Index

Constants

View Source
const DefaultPath = "/ira/ipkg"

DefaultPath is a default path for root

Variables

This section is empty.

Functions

func UnserializeDependencies

func UnserializeDependencies(serialized string) map[string]bool

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

func ParseConfig(path string) (*PkgConfig, error)

ParseConfig parse config file set in path and return PkgConfig

func (*PkgConfig) CheckDependencies

func (cfg *PkgConfig) CheckDependencies(root *Root) (bool, error)

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

func (cfg *PkgConfig) ForEachDependency(inner func(string, string, bool) error) error

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

func (cfg *PkgConfig) SerializeDependencies() string

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

type PkgSortMethod func(first, second *PkgConfig) bool

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

func CreateRoot(path string) (*Root, error)

CreateRoot creates package root on specified path. If directory path not exists, it will be created.

func OpenRoot

func OpenRoot(path string) (*Root, error)

func (*Root) ActivatePackage

func (r *Root) ActivatePackage(name, version string) error

func (*Root) CanBeRemoved

func (r *Root) CanBeRemoved(name, version string) (bool, error)

func (*Root) FindPackage

func (r *Root) FindPackage(name string, version string) (*PkgConfig, error)

FindPackage gets package by name and version. If there is no package, returns sql.ErrNoRows

func (*Root) FindPackagesByName

func (r *Root) FindPackagesByName(name string) ([]PkgConfig, error)

FindPackagesByName returns all packages with the same name

func (*Root) InstallPackage

func (r *Root) InstallPackage(path string, asDependency bool) error

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) IsActive

func (r *Root) IsActive(name, version string) bool

func (*Root) IsDependency

func (r *Root) IsDependency(name, version string) (bool, error)

IsDependency checks is package installed by user (false) or as dependency (true).

func (*Root) MarkAsUserInstalled

func (r *Root) MarkAsUserInstalled(name, version string) error

MarkAsUserInstalled tries to mark package as installed by user

func (*Root) RemovePackage

func (r *Root) RemovePackage(name, version string, removeDependencies bool) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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