source

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2017 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SourceDir is where we store all tarballs
	SourceDir = "/var/lib/solbuild/sources"

	// SourceStagingDir is where we initially fetch downloads
	SourceStagingDir = "/var/lib/solbuild/sources/staging"
)
View Source
const (
	// GitSourceDir is the base directory for all cached git sources
	GitSourceDir = "/var/lib/solbuild/sources/git"
)

Variables

View Source
var (
	// ErrGitNoContinue is returned when git processing cannot continue
	ErrGitNoContinue = errors.New("Fatal errors in git fetch")
)

Functions

func PathExists

func PathExists(path string) bool

PathExists is a helper function to determine the existence of a file path

Types

type BindConfiguration

type BindConfiguration struct {
	BindSource string // The localy cached source
	BindTarget string // Target within the filesystem
}

A BindConfiguration is used by a source as a way to express bind mounts required for a given source.

In solbuild, *all* sources are bind mounted to the target cache, regardless of their type.

Special care is taken to ensure that they will be bound in a way compatible with the target system.

type GitSource

type GitSource struct {
	URI       string
	Ref       string
	BaseName  string
	ClonePath string // This is where we will have cloned into
}

A GitSource as referenced by `ypkg` build spec. A git source must have a valid ref to check out to.

func NewGit

func NewGit(uri, ref string) (*GitSource, error)

NewGit will create a new GitSource for the given URI & ref combination.

func (*GitSource) Clone

func (g *GitSource) Clone() error

Clone will set do a bare mirror clone of the remote repo to the local cache.

func (*GitSource) CreateCallbacks

func (g *GitSource) CreateCallbacks() git.RemoteCallbacks

CreateCallbacks will create the default git callbacks

func (*GitSource) Fetch

func (g *GitSource) Fetch() error

Fetch will attempt to download the git tree locally. If it already exists then we'll make an attempt to update it.

func (*GitSource) GetBindConfiguration

func (g *GitSource) GetBindConfiguration(sourcedir string) BindConfiguration

GetBindConfiguration will return a config that enables bind mounting the bare git clone from the host side into the container, at which point ypkg can git clone from the bare git into a new tree and check out, make changes, etc.

func (*GitSource) GetCommitID

func (g *GitSource) GetCommitID(repo *git.Repository) string

GetCommitID will attempt to find the oid of the selected ref type

func (*GitSource) GetHead

func (g *GitSource) GetHead(repo *git.Repository) (string, error)

GetHead will attempt to gain the OID for head

func (*GitSource) GetIdentifier

func (g *GitSource) GetIdentifier() string

GetIdentifier will return a human readable string to represent this git source in the event of errors.

func (*GitSource) HasTag

func (g *GitSource) HasTag(repo *git.Repository, tagName string) bool

HasTag will attempt to find the tag, if possible

func (*GitSource) IsFetched

func (g *GitSource) IsFetched() bool

IsFetched will check if we have the ref available, if not it will return false so that Fetch() can do the hard work.

type SimpleSource

type SimpleSource struct {
	URI  string
	File string // Basename of the file
	// contains filtered or unexported fields
}

A SimpleSource is a tarball or other source for a package

func NewSimple

func NewSimple(uri, validator string, legacy bool) (*SimpleSource, error)

NewSimple will create a new source instance

func (*SimpleSource) Fetch

func (s *SimpleSource) Fetch() error

Fetch will download the given source and cache it locally

func (*SimpleSource) GetBindConfiguration

func (s *SimpleSource) GetBindConfiguration(rootfs string) BindConfiguration

GetBindConfiguration will return the pair for binding our tarballs.

func (*SimpleSource) GetIdentifier

func (s *SimpleSource) GetIdentifier() string

GetIdentifier will return the URI associated with this source.

func (*SimpleSource) GetPath

func (s *SimpleSource) GetPath(hash string) string

GetPath gets the path on the filesystem of the source

func (*SimpleSource) GetSHA1Sum

func (s *SimpleSource) GetSHA1Sum(path string) (string, error)

GetSHA1Sum will return the sha1sum for the given path

func (*SimpleSource) GetSHA256Sum

func (s *SimpleSource) GetSHA256Sum(path string) (string, error)

GetSHA256Sum will return the sha1sum for the given path

func (*SimpleSource) IsFetched

func (s *SimpleSource) IsFetched() bool

IsFetched will determine if the source is already present

type Source

type Source interface {

	// IsFetched is called during the early build process to determine
	// whether this source is available for use.
	IsFetched() bool

	// Fetch will attempt to fetch the this source locally and cache it.
	Fetch() error

	// GetBindConfiguration should return a valid configuration specifying
	// the origin on our local filesystem, and the target within the container.
	// The target should include the full source dir.
	GetBindConfiguration(rootfs string) BindConfiguration

	// GetIdentifier will return the appropriate representation for a given
	// source URL.
	GetIdentifier() string
}

A Source is a general representation of source listed in a package spec file.

Source's may be of multiple types, but all are abstracted and dealt with by the interfaces.

func New

func New(uri, validator string, legacy bool) (Source, error)

New will return a new source for the specified URL.

Validator is the value by which the source will be validated, depending on implementation. For example, the SimpleSource backend will expect a hashsum: sha256sum for package.yml, and sha1sum for legacy.

The legacy argument will determine whether special care should be taken for legacy packages (i.e. sha1sum vs sha256sum).

In all cases, New will fallback to the SimpleSource implementation

Jump to

Keyboard shortcuts

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