via

package
v0.0.0-...-a634bc8 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2022 License: BSD-2-Clause Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DockerEnv is the docker environment file
	DockerEnv = "/.dockerenv"
	// DockerAPI is the internal docker address used for ipfs API calls
	DockerAPI = "172.17.0.1:5001"
)
View Source
const (
	// DirMask is the default mask for new directories
	DirMask = 0755
)
View Source
const (
	//SocketFile is full path to socket file
	SocketFile = "/tmp/via/socket"
)

Variables

This section is empty.

Functions

func Branch

func Branch(path Path) (string, error)

Branch returns the currently checked out branch for a git directory FIXME: this will probably fail with a detached head

func BuildDeps

func BuildDeps(config *Config, plan *Plan) (err error)

BuildDeps build's all of a packages dependency's are build if they are not built already

func Clean

func Clean(config *Config, plan *Plan) error

Clean the Plans build directory

func Clone

func Clone(dir Path, url string) error

Clone remote URL into directory.

func CloneBranch

func CloneBranch(dir Path, url, branch string) error

CloneBranch clone remove URL with branch to directory

func Connect

func Connect() (*rpc.Client, error)

Connect dials the rpc daemon

func Create

func Create(config *Config, url, group string) (err error)

Create a new plan from a given Url

func CreateManifest

func CreateManifest(config *Config, plan *Plan, dir string) (err error)

CreateManifest walks the plans PKGDIR and creates a gzipped manifest file.

func Debug

func Debug(b bool)

Debug sets the global debugging level

func Depends

func Depends(config *Config, plan *Plan, dir string) ([]string, error)

Depends return the plan names, that each elf file depends on.

func Download

func Download(config *Config, plan *Plan) error

Download gets the plans binary tarball package from ipfs http gateway. If run in a docker instance it will use a local docker ip.

FIXME: now that we have have contain namespaces we probably don't need docker logic here. And this will probably produce corner cases down the road.

func FmtPlans

func FmtPlans(config *Config) (err error)

FmtPlans walks all plans and formats it sorting fields

FIXME: this should be renamed to Format and a new Lint function created. Lint function should have no side effects just look for known style isses. For example we can check that each upstream URL is using https and not http

func GNUUntar

func GNUUntar(dest Path, file string) error

GNUUntar uses tar program to decompress an extract source files

FIXME: this is temporary used to handle some corner cases with long file names which could now be resolved with go upstream. Revisit this when we rework our untar functions

func HashOnly

func HashOnly(config *Config, path string) (string, error)

HashOnly returns the ipfs multihash for a file at path

func IpfsAdd

func IpfsAdd(config *Config, path string) (string, error)

IpfsAdd add a file to ipfs and returns the ipfs multihash

func IsInstalled

func IsInstalled(config *Config, name string) bool

IsInstalled returns true if a plan is installed

func MakeStat

func MakeStat(path string) error

MakeStat walks path and creates a stat.json file with each files permissions

func PackageFile

func PackageFile(config *Config, plan *Plan) string

PackageFile returns the plans tarball name

func PackageFileExists

func PackageFileExists(config *Config, plan *Plan) bool

PackageFileExists return true if a plan's package file exists

func PackagePath

func PackagePath(config *Config, plan *Plan) string

PackagePath returns the full path of the plans package file

func PlanFiles

func PlanFiles(config *Config) ([]string, error)

PlanFiles returns a string slice with the full path of all of all plans

func PostInstall

func PostInstall(config *Config, plan *Plan) (err error)

PostInstall calls each of the Plans PostInstall commands

func Readelf

func Readelf(p string) error

Readelf prints the dynamic libs and interop sections for the elf binary specified by path name

func Remove

func Remove(config *Config, name string) (err error)

Remove a plan from the system

func RepoCreate

func RepoCreate(config *Config) error

RepoCreate reads each plan's files creating a repo.json file that contains all plan's and groups. And also creating a files.json that contains a hash map of each plans files

FIXME: this is pretty expensive and probably won't scale well. Also repo.json and files.json should probably not be kept in version control.

func SetStat

func SetStat(path string) error

SetStat each files Mode in path to mode contained in the paths stat.json file

func Sign

func Sign(config *Config, plan *Plan) (err error)

Sign produces a detached signature for a plans package file

FIXME: currently this is not used at all. And may be redundant considering we are using ipfs multihash. Will revist this later.

func StartDaemon

func StartDaemon(config *Config) error

StartDaemon starts the RPC daemon

func TarGzReader

func TarGzReader(p string) (*tar.Reader, error)

TarGzReader returns opens and returns a tar.Reader for give path

func Untar

func Untar(dest Path, r io.Reader) error

Untar decompress reader to destination directory. This is mainly used for install via packages

FIXME: rewrite this hackfest

func Update

func Update(b bool)

Update set if a plan should update after building

FIXME: document what this actually does

func Verbose

func Verbose(b bool)

Verbose sets the global verbosity level

FIXME: this should be set via Builder or Installer

func VerifiySig

func VerifiySig(path string) (err error)

VerifiySig verifiy's that the plans signature matches a trusted signature.

FIXME: currently this is not used right now. instead ipfs's multihash is used. Revisit this later

func WritePlan

func WritePlan(config *Config, plan *Plan) error

WritePlan writes the serialized go struct to it's json file. The json file is pretty formatted so to keep consistency

Types

type Batch

type Batch struct {
	// contains filtered or unexported fields
}

Batch Plan type

func NewBatch

func NewBatch(conf *Config) Batch

NewBatch returns a new Batch that has been initialized

func (*Batch) Add

func (b *Batch) Add(plan *Plan)

Add a 'Plan to the Batch

func (Batch) Download

func (b Batch) Download(plan *Plan) error

Download plan's binary tarball for configured ipfs gateway

func (*Batch) DownloadInstall

func (b *Batch) DownloadInstall(plan *Plan) error

DownloadInstall provides a Plan function that downloads and installs a Plan

func (Batch) ForEach

func (b Batch) ForEach(fn PlanFunc, plans PlanSlice) (errors []error)

ForEach run PlanFunc on each plan in Plans.

func (*Batch) Install

func (b *Batch) Install() (errors []error)

Install does the final download and installing of the batch plans

func (Batch) Plans

func (b Batch) Plans() PlanSlice

Plans returns the Batch's plans

func (Batch) PromptInstall

func (b Batch) PromptInstall() []error

PromptInstall prompts user before installing

func (*Batch) PruneInstalled

func (b *Batch) PruneInstalled()

PruneInstalled Plans within the Batch

FIXME: this is not implemented and is not currently being used

func (Batch) String

func (b Batch) String() string

Provides stringer interface

func (*Batch) ToDownload

func (b *Batch) ToDownload() []string

ToDownload returns a string slice of Plans to download

func (*Batch) ToInstall

func (b *Batch) ToInstall() PlanSlice

ToInstall Returns a string slice of 'Plans to install

func (*Batch) Walk

func (b *Batch) Walk(plan *Plan) error

Walk the plan's dependency tree and add each dependency to the batch if it does not already exist

type Builder

type Builder struct {
	Config *Config
	Plan   *Plan
	Cache  Cache
}

Builder provides type for building a Plan

func NewBuilder

func NewBuilder(config *Config, plan *Plan) Builder

NewBuilder returns new Builder that has been initialized

func NewBuilderByName

func NewBuilderByName(config *Config, name string) (Builder, error)

NewBuilderByName returns a new builder looking Plan by name

func (Builder) Build

func (b Builder) Build() error

Build runs the Plans Build section

func (Builder) BuildDir

func (b Builder) BuildDir() Path

BuildDir returns the path for the Builder's build directory

func (Builder) BuildSteps

func (b Builder) BuildSteps() error

BuildSteps calls all of the methods required to build a Plan

func (Builder) CreatePackage

func (b Builder) CreatePackage() error

CreatePackage create Tarball package

func (Builder) Download

func (b Builder) Download() error

Download Plans sources to Cache

func (Builder) Package

func (b Builder) Package() error

Package the Plan

func (Builder) PackageDir

func (b Builder) PackageDir() Path

PackageDir return the full path for Builder's package directory

func (Builder) SourcePath

func (b Builder) SourcePath() Path

SourcePath returns the full path of the Plans source file

func (Builder) SourceURL

func (b Builder) SourceURL() string

SourceURL returns the Plans expanded Url

func (Builder) Stage

func (b Builder) Stage() error

Stage the Plans source files into it's staging directory

func (Builder) StageDir

func (b Builder) StageDir() Path

StageDir returns the Builders stage directory

func (Builder) Tarball

func (b Builder) Tarball(wr io.Writer) (err error)

Tarball creates manifest and walks PackageDir taring and compressing package files

type Cache

type Cache struct {
	Path
}

Cache provides a type for working with build caching

func NewCache

func NewCache(path string) Cache

NewCache returns a new initialized Cache

func (Cache) Builds

func (c Cache) Builds() Path

Builds returns the directory cache that contains plan builds. This is where out of source tree builds are built. Not all build systems support plans support out of source tree builds

func (Cache) Init

func (c Cache) Init()

Init creates each cache directory ensuring it exists

func (Cache) Packages

func (c Cache) Packages() Path

Packages returns the cache directory containing build packages. This directory is used to install the built package before they are packaged into tarballs

func (Cache) Root

func (c Cache) Root() Path

Root returns the namespace root. This is used to build packages in isolation

func (Cache) Sources

func (c Cache) Sources() Path

Sources returns the directory cache that contains the source tarballs downloaded from upstream. This can also contain git repositories though only portions of git support currently exists

func (Cache) Stages

func (c Cache) Stages() Path

Stages returns the stages directory cache. This directory is used to cache decompressed source trees.

type Config

type Config struct {
	Branch    string
	Identity  string
	Arch      string
	OS        string
	Root      Path
	PlansRepo string
	Threads   int
	IpfsAPI   string
	// Paths
	Cache  Cache
	DB     DB
	Plans  Plans
	Repo   Repo
	Binary string
	Prefix Path

	// Toolchain
	Flags Flags

	Env         Env
	Remove      []string
	PostInstall []string
	// contains filtered or unexported fields
}

Config represents via configuration type

func NewConfig

func NewConfig(path Path) (*Config, error)

NewConfig reads config path and returns a new initialized Config

func (*Config) Expand

func (c *Config) Expand() *Config

Expand returns a Config that have had its fields parsed through go's template engine. Basically this allows for self referencing json. For example we use this to reduce repetition for things like the Prefix field. We can then reuse {{.Prefix}} to represent that field in other parts of the config file

func (Config) SanitizeEnv

func (c Config) SanitizeEnv() []string

SanitizeEnv returns an os.Environ() environment string slice that keeps only white listed environment variables. This ensures when we exec command calls nothing leaks from system environment

type ConfigJSON

type ConfigJSON Config

ConfigJSON provides json Marshal and Unmarshal interface for Config

func (*ConfigJSON) MarshalJSON

func (j *ConfigJSON) MarshalJSON() ([]byte, error)

MarshalJSON provides Marshal interface

func (ConfigJSON) ToConfig

func (j ConfigJSON) ToConfig() *Config

ToConfig returns Config type

func (*ConfigJSON) UnmarshalJSON

func (j *ConfigJSON) UnmarshalJSON(data []byte) error

UnmarshalJSON provides Unmarshal interface

type DB

type DB struct {
	Path
}

DB provides string type for working with DB installed path

func (DB) Installed

func (d DB) Installed(config *Config) Path

Installed returns the path string of the installed directory

func (DB) InstalledFiles

func (d DB) InstalledFiles(config *Config) ([]string, error)

InstalledFiles returns all of the json manifests for each install package

func (DB) InstalledPlans

func (d DB) InstalledPlans(config *Config) ([]string, error)

InstalledPlans returns a slice of installed Plan names

type DaemonBuilder

type DaemonBuilder struct {
	// contains filtered or unexported fields
}

DaemonBuilder provides RPC server type

FIXME: this is not complete and not as important since we are using namespaces. could be useful at a later point

type Env

type Env map[string]string

Env provides a hash map for environment variables

func (Env) KeyValue

func (env Env) KeyValue() (kv []string)

KeyValue return Env as key=value sorted alphabetically by key

func (Env) Value

func (env Env) Value(key string) string

Value returns key=value for maps key

type Flags

type Flags []string

Flags provides a string slice type for working with flags

func (Flags) Join

func (f Flags) Join() string

Join joins flags into a string separated with a space

type Installer

type Installer struct {
	// contains filtered or unexported fields
}

Installer provides Installer type

func NewInstaller

func NewInstaller(config *Config, plan *Plan) *Installer

NewInstaller returns a new Installer that has been initialized

func (Installer) Install

func (i Installer) Install() error

Install method does the final installation of decompressing and extracting the tarball. The manifest which is essentially the plan's json file is then stored in the DB installed directory. It also updates the manifest's Cid resulting in byte to byte parity with the manifest.json and plan.json files.

func (Installer) VerifyCid

func (i Installer) VerifyCid() error

VerifyCid verifies that the download tarball matches the plans Cid

type IpfsStat

type IpfsStat struct {
	Path    string
	Mode    os.FileMode
	ModTime time.Time
}

IpfsStat provides type that contains file stat information

type Path

type Path string

Path provides type for working with directory paths

func FindPlanPath

func FindPlanPath(config *Config, name string) (Path, error)

FindPlanPath returns the fullpath for a plan by it's given name

func NewPath

func NewPath(paths ...string) Path

NewPath returns a new Path with paths joined. If the new path does not exist panic

func PlanFilePath

func PlanFilePath(config *Config, plan *Plan) Path

PlanFilePath returns the full path of the Plan's json file

func (Path) Base

func (p Path) Base() Path

Base returns the Path's base

func (Path) Clone

func (p Path) Clone(url string) error

Clone url to this Path

func (Path) Dir

func (p Path) Dir() Path

Dir returns the Path's parent directory

func (Path) Ensure

func (p Path) Ensure()

Ensure that the Path directory path is created

func (Path) Exists

func (p Path) Exists() bool

Exists return true if the Path path exists

func (Path) Expand

func (p Path) Expand() Path

Expand returns the Path as a string that has had its environment variables expanded

func (Path) ExpandToPath

func (p Path) ExpandToPath() Path

ExpandToPath is like Expand but returns a Path type

func (Path) Ext

func (p Path) Ext() string

Ext returns the Path's file extension

func (Path) Glob

func (p Path) Glob() ([]Path, error)

Glob returns all of the entries in the Path

func (Path) IsDir

func (p Path) IsDir() (bool, error)

IsDir returns true if Path is a directory

func (Path) Join

func (p Path) Join(s ...string) Path

Join path arguments with the Path as parent. This is like filepath.Join but with this Path type as the parent

func (Path) MarshalJSON

func (p Path) MarshalJSON() ([]byte, error)

MarshalJSON provide marshal interface

func (Path) MkdirAll

func (p Path) MkdirAll() error

MkdirAll recursively makes Path directory

func (Path) RemoveAll

func (p Path) RemoveAll() error

RemoveAll remove this Path recursively

func (Path) Stat

func (p Path) Stat() (os.FileInfo, error)

Stat Path

func (Path) String

func (p Path) String() string

String provides stringer interface

func (Path) ToCache

func (p Path) ToCache() Cache

ToCache Convert Path to Cache

func (Path) ToDB

func (p Path) ToDB() DB

ToDB Convert Path to DB

func (Path) ToPath

func (p Path) ToPath() Path

ToPath Converts to Path

func (Path) ToRepo

func (p Path) ToRepo() Repo

ToRepo Convert Path to Repo

func (Path) Touch

func (p Path) Touch() error

Touch Path

func (*Path) UnmarshalJSON

func (p *Path) UnmarshalJSON(b []byte) error

UnmarshalJSON provide unmarshal interface

type Plan

type Plan struct {
	Name          string
	Version       string
	Url           string
	Group         string
	StageDir      string
	Inherit       string
	Cid           string
	BuildInStage  bool
	IsRebuilt     bool
	BuildTime     time.Duration
	Date          time.Time
	Size          int64
	SubPackages   []string
	AutoDepends   []string
	ManualDepends []string
	BuildDepends  []string
	Flags         Flags
	Patch         []string
	Build         []string
	Package       []string
	PostInstall   []string
	Remove        []string
	Files         []string
}

revive:disable Plan is the plan type used to define plan meta data and build instructions

func NewPlan

func NewPlan(config *Config, name string) (plan *Plan, err error)

NewPlan returns a new Plan that has been initialized

func ReadManifest

func ReadManifest(config *Config, name string) (*Plan, error)

ReadManifest returns an installed Plan's manifest by name

func ReadPackManifest

func ReadPackManifest(p string) (*Plan, error)

ReadPackManifest open and package tarball path and returns a plans package manifest

func ReadPath

func ReadPath(path string) (plan *Plan, err error)

ReadPath reads a plan by path and return a Plan

func (*Plan) Depends

func (p *Plan) Depends() []string

Depends returns the PlanSlice Autodepends and ManualDepends as one string slice

func (*Plan) Expand

func (p *Plan) Expand() *Plan

Expand returns a Plan that has been parsed by go's template engine. This provides a form of self referencing json. Where field names can be reference from other filed names

func (*Plan) NameVersion

func (p *Plan) NameVersion() string

NameVersion returns a plans name and version separated by a hyphen

func (*Plan) SourceFile

func (p *Plan) SourceFile() string

SourceFile return the base name of the plans upstream source file/directory

type PlanFunc

type PlanFunc func(*Plan) error

PlanFunc provides a func that takes a Plan

type PlanJSON

type PlanJSON Plan

PlanJSON provides json Marshal interface for Plan

func (PlanJSON) MarshalJSON

func (j PlanJSON) MarshalJSON() ([]byte, error)

MarshalJSON provides Marshal interface

type PlanSlice

type PlanSlice []*Plan

PlanSlice provides a slice of plans

func GetPlans

func GetPlans(config *Config) (PlanSlice, error)

GetPlans returns a Plan slice of all Plan in config.Plans

func (PlanSlice) Contains

func (ps PlanSlice) Contains(plan *Plan) bool

Contains return true if plan already exists in this PlanSlice slice

func (PlanSlice) Print

func (ps PlanSlice) Print()

Print each plans name and size to console

TODO: use template

func (PlanSlice) Slice

func (ps PlanSlice) Slice() []string

Slice returns a slice of plan names

func (PlanSlice) SortSize

func (ps PlanSlice) SortSize() PlanSlice

SortSize returns a copy of this PlanSlice sorted by field Size.

type Plans

type Plans struct {
	Path
}

Plans proved type for Plan directory type

func (Plans) ConfigFile

func (p Plans) ConfigFile() Path

ConfigFile returns config.json Path

type ProgressWriter

type ProgressWriter struct {
	// contains filtered or unexported fields
}

ProgressWriter provides a writer interface that updates speed and progress information for ProgMeter

func NewProgressWriter

func NewProgressWriter(pm *progmeter.ProgMeter, key string, t int64, w io.Writer) *ProgressWriter

NewProgressWriter returns a new ProgressWriter that has been initialized

func (*ProgressWriter) Write

func (pw *ProgressWriter) Write(b []byte) (int, error)

Write provides writer interface write method

type Repo

type Repo struct {
	Path
}

Repo provides repo path string. This is the path that binary tarballs are downloaded and built too

func NewRepo

func NewRepo(path string) Repo

NewRepo returns a new initialized Repo

func (Repo) File

func (r Repo) File(config *Config) Path

File returns the full path for repo.json file

func (Repo) FilesFile

func (r Repo) FilesFile(config *Config) Path

FilesFile returns the full path for files.json

type RepoFiles

type RepoFiles map[string][]string

RepoFiles provides plan files map hash

func ReadRepoFiles

func ReadRepoFiles(config *Config) (RepoFiles, error)

ReadRepoFiles reads files.json and returns a RepoFiles map hash

func (RepoFiles) Owners

func (rf RepoFiles) Owners(file string) []string

Owners like owns but returns a slice of plan names instead of the first occurrence. The returned slice is sorted alphabetically

func (RepoFiles) Owns

func (rf RepoFiles) Owns(file string) string

Owns returns the first alphabetical plan Name of plan that contains file

type Request

type Request struct {
	Plan Plan
}

Request provide RPC request type

type Response

type Response struct {
}

Response is RPC response type

type Size

type Size PlanSlice

Size provides sorter interface for Plans slice type

func (Size) Len

func (s Size) Len() int

func (Size) Less

func (s Size) Less(i, j int) bool

func (Size) Swap

func (s Size) Swap(i, j int)

type Upgrader

type Upgrader struct {
	// contains filtered or unexported fields
}

Upgrader provides a type for upgrading installed plans

func NewUpgrader

func NewUpgrader(config *Config) *Upgrader

NewUpgrader creates and initializes a new Upgrader

func (*Upgrader) Check

func (u *Upgrader) Check() ([]string, error)

Check compares all installed plans against the git repository of plans. And returns a slice of plan names that can be upgraded

func (Upgrader) Upgrade

func (u Upgrader) Upgrade() []error

Upgrade finally downloads and installs plan upgrades it returns a slice of errors if any occur.

FIXME: we should make this transnational.

func (Upgrader) Upgrades

func (u Upgrader) Upgrades() []string

Upgrades returns a slice of plan names that are candidates for upgrading

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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