builder

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: 28 Imported by: 0

Documentation

Overview

Package builder provides all the solbuild specific functionality

Index

Constants

View Source
const (
	// MaxChangelogEntries is the absolute maximum number of entries we'll
	// parse and provide changelog entries for.
	MaxChangelogEntries = 10

	// UpdateDateFormat is the time format we emit in the history.xml, i.e.
	// 2016-09-24
	UpdateDateFormat = "2006-01-02"
)
View Source
const (
	// ImagesDir is where we keep the rootfs images for build profiles
	ImagesDir = "/var/lib/solbuild/images"

	// ImageSuffix is the common suffix for all solbuild images
	ImageSuffix = ".img"

	// ImageCompressedSuffix is the common suffix for a fetched evobuild image
	ImageCompressedSuffix = ".img.xz"

	// ImageBaseURI is the storage area for base images
	ImageBaseURI = "https://solus-project.com/image_root"

	// ImageRootsDir is where updates are performed on base images
	ImageRootsDir = "/var/lib/solbuild/roots"
)
View Source
const (
	// PackageCacheDirectory is where we share packages between all builders
	PackageCacheDirectory = "/var/lib/solbuild/packages"

	// CcacheDirectory is the system wide ccache directory
	CcacheDirectory = "/var/lib/solbuild/ccache/ypkg"

	// LegacyCcacheDirectory is the root owned ccache directory for pspec.xml
	LegacyCcacheDirectory = "/var/lib/solbuild/ccache/legacy"
)
View Source
const (
	// BuildUser is the user that builds will run as inside the chroot
	BuildUser = "build"

	// BuildUserID is the build user's numerical ID
	BuildUserID = 1000

	// BuildUserGID is the group to use
	BuildUserGID = 1000

	// BuildUserHome is the build user's home directory
	BuildUserHome = "/home/build"

	// BuildUserGecos is the build user's description
	BuildUserGecos = "solbuild user"

	// BuildUserShell is the system shell for the build user
	BuildUserShell = "/bin/bash"
)
View Source
const (
	// FallbackUserName is what we fallback to if everything else fails
	FallbackUserName = "Automated Package Build"

	// FallbackUserEmail is what we fallback to if everything else fails
	FallbackUserEmail = "no.email.set.in.config"
)
View Source
const (
	// BindRepoDir is where we make repos available from the host side
	BindRepoDir = "/hostRepos"
)
View Source
const (
	// OverlayRootDir is the root in which we form all solbuild cache paths,
	// these are the temp build roots that we happily throw away.
	OverlayRootDir = "/var/cache/solbuild"
)
View Source
const (
	// TransitManifestSuffix is the extension that a valid transit manifest must have
	TransitManifestSuffix = ".tram"
)

Variables

View Source
var (
	// ConfigPaths is a set of locations for valid solbuild configuration files
	ConfigPaths = []string{
		"/etc/solbuild",
		"/usr/share/solbuild",
	}

	// ConfigSuffix is the suffix a file must have to be glob loaded by solbuild
	ConfigSuffix = ".conf"
)
View Source
var (
	// ErrCannotContinue is a stock error return
	ErrCannotContinue = errors.New("Index cannot continue")

	// IndexBindTarget is where we always mount the repo
	IndexBindTarget = "/hostRepo/Index"
)
View Source
var (
	// ErrDeadLockFile is returned when an dead lockfile was encountered
	ErrDeadLockFile = errors.New("Dead lockfile")

	// ErrOwnedLockFile is returned when the lockfile is already owned by
	// another active process.
	ErrOwnedLockFile = errors.New("File is locked")
)
View Source
var (
	// ErrManagerInitialised is returned when the library user attempts to set
	// a core part of the Manager after it's already been initialised
	ErrManagerInitialised = errors.New("The manager has already been initialised")

	// ErrNoPackage is returned when we've got no package
	ErrNoPackage = errors.New("You must first set a package to build it")

	// ErrNotImplemented is returned as a placeholder when developing functionality.
	ErrNotImplemented = errors.New("Function not yet implemented")

	// ErrProfileNotInstalled is returned when a profile is not yet installed
	ErrProfileNotInstalled = errors.New("Profile is not installed")

	// ErrInvalidProfile is returned when there is an invalid profile
	ErrInvalidProfile = errors.New("Invalid profile")

	// ErrInvalidImage is returned when the backing image is unknown
	ErrInvalidImage = errors.New("Invalid image")

	// ErrInterrupted is returned when the build is interrupted
	ErrInterrupted = errors.New("The operation was cancelled by the user")
)
View Source
var (
	// ChrootEnvironment is the env used by ChrootExec calls
	ChrootEnvironment []string
)
View Source
var (
	// CveRegex is used to identify security updates which mention a specific
	// CVE ID.
	CveRegex *regexp.Regexp
)
View Source
var DisableColors bool

DisableColors controls whether or not to use colours in the display. Spelled this way so people don't get confused :P

View Source
var (
	// ErrIllegalUpload is returned when someone is a spanner and tries uploading an unsupported file
	ErrIllegalUpload = errors.New("The manifest file is NOT an eopkg")
)
View Source
var (
	// IndexPackage is used by the index command to make use of the overlayfs
	// system.
	IndexPackage = Package{
		Name:    "index",
		Version: "1.4.2",
		Type:    PackageTypeIndex,
		Release: 1,
		Path:    "",
	}
)
View Source
var (
	// ProfileSuffix is the fixed extension for solbuild profile files
	ProfileSuffix = ".profile"
)
View Source
var (
	// ValidImages is a set of known, Solus-published, base profiles
	ValidImages = []string{
		"main-x86_64",
		"unstable-x86_64",
	}
)

Functions

func AddBuildUser

func AddBuildUser(rootfs string) error

AddBuildUser will attempt to add the solbuild user & group if they've not previously been added Note this should be changed when Solus goes fully stateless for /etc/passwd

func CatGitBlob

func CatGitBlob(repo *git.Repository, entry *git.TreeEntry) ([]byte, error)

CatGitBlob will return the contents of the given entry

func ChrootExec

func ChrootExec(notif PidNotifier, dir, command string) error

ChrootExec is a simple wrapper to return a correctly set up chroot command, so that we can store the PID, for long running tasks

func ChrootExecStdin

func ChrootExecStdin(notif PidNotifier, dir, command string) error

ChrootExecStdin is almost identical to ChrootExec, except it permits a stdin to be associated with the command

func ConfigureNamespace

func ConfigureNamespace() error

ConfigureNamespace will unshare() context, entering a new namespace

func CopyAll

func CopyAll(source, destdir string) error

CopyAll will copy the source asset into the given destdir. If the source is a directory, it will be recursively copied into the directory destdir.

Note that all directories are created as 00755, as solbuild has no interest in the individual folder permissions, just the files themselves.

func DropNetworking

func DropNetworking() error

DropNetworking will unshare() the context networking capabilities

func EmitImageError

func EmitImageError(image string)

EmitImageError emits the stock response to requesting an invalid image

func EmitProfileError

func EmitProfileError(p string)

EmitProfileError emits a stock response for an invalid profile

func EnsureEopkgLayout

func EnsureEopkgLayout(root string) error

EnsureEopkgLayout will enforce changes to the filesystem to make sure that it works as expected.

func FileSha256sum added in v1.4.1

func FileSha256sum(path string) (string, error)

FileSha256sum is a quick wrapper to grab the sha256sum for the given file

func GetAllProfiles

func GetAllProfiles() (map[string]*Profile, error)

GetAllProfiles will locate all available profiles for solbuild

func GetFileContents

func GetFileContents(repo *git.Repository, tag, path string) ([]byte, error)

GetFileContents will attempt to read the entire object at path from the given tag, within that repo.

func IsValidImage

func IsValidImage(profile string) bool

IsValidImage will check if the specified profile is a valid one.

func MurderDeathKill

func MurderDeathKill(root string) error

MurderDeathKill will find all processes with a root matching the given root and set about killing them, to assist in clean closing.

func ParseGroups

func ParseGroups(grps string) (map[string]*Group, error)

ParseGroups will attempt to parse a *NIX style group file

func ParseUsers

func ParseUsers(passwd string) (map[string]*User, error)

ParseUsers will attempt to parse a *NIX style passwd file

func PathExists

func PathExists(path string) bool

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

func SaneEnvironment

func SaneEnvironment(username, home string) []string

SaneEnvironment will generate a clean environment for the chroot'd processes to use

func TouchFile

func TouchFile(path string) error

TouchFile will create the file if it doesn't exist, enabling use of bind mounts.

Types

type BackingImage

type BackingImage struct {
	Name        string // Name of the profile
	ImagePath   string // Absolute path to the .img file
	ImagePathXZ string // Absolute path to the .img.xz file
	ImageURI    string // URI of the image origin
	RootDir     string // Where to mount the backing image for updates
	LockPath    string // Our lock path for update operations
}

A BackingImage is the core of any given profile

func NewBackingImage

func NewBackingImage(name string) *BackingImage

NewBackingImage will return a correctly configured backing image for usage.

func (*BackingImage) IsFetched

func (b *BackingImage) IsFetched() bool

IsFetched will determine whether or not the XZ image itself has been fetched

func (*BackingImage) IsInstalled

func (b *BackingImage) IsInstalled() bool

IsInstalled will determine whether the given backing image has been installed to the global image directory or not.

func (*BackingImage) Update

func (b *BackingImage) Update(notif PidNotifier, pkgManager *EopkgManager) error

Update will attempt to update the backing image to the latest version internally.

type Config

type Config struct {
	DefaultProfile string `toml:"default_profile"` // Name of the default profile to use
	EnableTmpfs    bool   `toml:"enable_tmpfs"`    // Whether to enable tmpfs builds or
	TmpfsSize      string `toml:"tmpfs_size"`      // Bounding size on the tmpfs
}

Config defines the global defaults for solbuild

func NewConfig

func NewConfig() (*Config, error)

NewConfig will read all the system config files and then the vendor config files until it gets somewhere.

type EopkgManager

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

EopkgManager is our own very shorted version of libosdev EopkgManager, to enable very very simple operations

func NewEopkgManager

func NewEopkgManager(notif PidNotifier, root string) *EopkgManager

NewEopkgManager will return a new eopkg manager

func (*EopkgManager) AddRepo

func (e *EopkgManager) AddRepo(id, source string) error

AddRepo will attempt to add a repo to the filesystem

func (*EopkgManager) Cleanup

func (e *EopkgManager) Cleanup()

Cleanup will take care of any work we've already done before

func (*EopkgManager) CopyAssets

func (e *EopkgManager) CopyAssets() error

CopyAssets will copy any required host-side assets into the system. This function has to be reusable simply because performing an eopkg upgrade or installing deps, prior to building, could clobber the files.

func (*EopkgManager) GetRepos

func (e *EopkgManager) GetRepos() ([]*EopkgRepo, error)

GetRepos will attempt to discover all the repos on the target filesystem

func (*EopkgManager) Init

func (e *EopkgManager) Init() error

Init will do some basic preparation of the chroot

func (*EopkgManager) InstallComponent

func (e *EopkgManager) InstallComponent(comp string) error

InstallComponent will install the named component inside the chroot

func (*EopkgManager) RemoveRepo

func (e *EopkgManager) RemoveRepo(id string) error

RemoveRepo will attempt to remove a named repo from the filesystem

func (*EopkgManager) StartDBUS

func (e *EopkgManager) StartDBUS() error

StartDBUS will bring up dbus within the chroot

func (*EopkgManager) StopDBUS

func (e *EopkgManager) StopDBUS() error

StopDBUS will tear down dbus

func (*EopkgManager) Upgrade

func (e *EopkgManager) Upgrade() error

Upgrade will perform an eopkg upgrade inside the chroot

type EopkgRepo

type EopkgRepo struct {
	ID  string
	URI string
}

An EopkgRepo is a simplistic representation of a repo found in any given chroot.

type Group

type Group struct {
	Name    string   // Group Name
	ID      int      // Group ID
	Members []string // Names of users in group
}

A Group is an /etc/group defined user

type LockFile

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

A LockFile encapsulates locking functionality

func NewLockFile

func NewLockFile(path string) (*LockFile, error)

NewLockFile will return a new lockfile for the given path

func (*LockFile) Clean

func (l *LockFile) Clean() error

Clean will dispose of the lock file and hopefully the lockfile itself

func (*LockFile) GetOwnerPID

func (l *LockFile) GetOwnerPID() int

GetOwnerPID will return the owner PID, if it exists

func (*LockFile) GetOwnerProcess

func (l *LockFile) GetOwnerProcess() string

GetOwnerProcess will return the executable name if possible

func (*LockFile) Lock

func (l *LockFile) Lock() error

Lock will attempt to lock the file, or return an error if this fails

func (*LockFile) Unlock

func (l *LockFile) Unlock() error

Unlock will attempt to unlock the file, or return an error if this fails

type Manager

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

A Manager is responsible for cleanly managing the entire session within solbuild, i.e. setup, teardown, cleaning up, etc.

The consumer should create a new manager instance and only use these methods, not bypass and use API methods.

func NewManager

func NewManager() (*Manager, error)

NewManager will return a newly initialised manager instance

func (*Manager) Build

func (m *Manager) Build() error

Build will attempt to build the package associated with this manager, automatically handling any required cleanups.

func (*Manager) Chroot

func (m *Manager) Chroot() error

Chroot will enter the build environment to allow users to introspect it

func (*Manager) Cleanup

func (m *Manager) Cleanup()

Cleanup will take care of any teardown operations. It takes an exclusive lock and ensures all cleaning is handled before anyone else is permitted to continue, at which point error propagation and the IsCancelled() function should be enough logic to go on.

func (*Manager) GetProfile

func (m *Manager) GetProfile() *Profile

GetProfile will return the profile associated with this builder

func (*Manager) Index

func (m *Manager) Index(dir string) error

Index will attempt to index the given directory for eopkgs

func (*Manager) IsCancelled

func (m *Manager) IsCancelled() bool

IsCancelled will determine if the build has been cancelled, this will result in a lot of locking between all operations

func (*Manager) SetActivePID

func (m *Manager) SetActivePID(pid int)

SetActivePID will set the active task PID

func (*Manager) SetCancelled

func (m *Manager) SetCancelled()

SetCancelled will mark the build manager as cancelled, so it should not attempt to start any new operations whatsoever.

func (*Manager) SetManifestTarget added in v1.4.1

func (m *Manager) SetManifestTarget(target string)

SetManifestTarget will set the manifest target to be used An empty target (default) means no manifest

func (*Manager) SetPackage

func (m *Manager) SetPackage(pkg *Package) error

SetPackage will set the package associated with this manager. This package will be used in build & chroot operations only.

func (*Manager) SetProfile

func (m *Manager) SetProfile(profile string) error

SetProfile will attempt to initialise the manager with a given profile Currently this is locked to a backing image specification, but in future will be expanded to support profiles *based* on backing images.

func (*Manager) SetTmpfs

func (m *Manager) SetTmpfs(enable bool, size string)

SetTmpfs sets the manager tmpfs option

func (*Manager) SigIntCleanup

func (m *Manager) SigIntCleanup()

SigIntCleanup will take care of cleaning up the build process.

func (*Manager) Update

func (m *Manager) Update() error

Update will attempt to update the base image

type MmapFile added in v1.4.1

type MmapFile struct {
	Data []byte
	// contains filtered or unexported fields
}

An MmapFile is used to easily wrap the syscall mmap() functions to be readily usable from golang. This helps heaps (pun intended) when it comes to computing the hash sum for very large files, such as the index and eopkg files, in a zero copy fashion.

func MapFile added in v1.4.1

func MapFile(path string) (*MmapFile, error)

MapFile will attempt to mmap() the input file

func (*MmapFile) Close added in v1.4.1

func (m *MmapFile) Close() error

Close will close the previously mmapped filed

type Overlay

type Overlay struct {
	Back    *BackingImage // This will be mounted at $dir/image
	Package *Package      // The package we intend to interact with

	BaseDir    string // BaseDir is the base directory containing the root
	WorkDir    string // WorkDir is the overlayfs workdir lock
	UpperDir   string // UpperDir is where real inode changes happen (tmp)
	ImgDir     string // Where the profile is mounted (ro)
	MountPoint string // The actual mount point for the union'd directories
	LockPath   string // Path to the lockfile for this overlay

	EnableTmpfs bool   // Whether to use tmpfs for the upperdir or not
	TmpfsSize   string // Size of the tmpfs to pass to mount, string form

	ExtraMounts []string // Any extra mounts to take care of when cleaning up
	// contains filtered or unexported fields
}

An Overlay is formed from a backing image & Package combination. Using this Overlay we can bring up new temporary build roots using the overlayfs kernel module.

func NewOverlay

func NewOverlay(profile *Profile, back *BackingImage, pkg *Package) *Overlay

NewOverlay creates a new Overlay for us in builds, etc.

Unlike evobuild, we use fixed names within the more dynamic profile name, as opposed to a single dir with "unstable-x86_64" inside it, etc.

func (*Overlay) CleanExisting

func (o *Overlay) CleanExisting() error

CleanExisting will purge an existing overlayfs configuration if it exists.

func (*Overlay) ConfigureNetworking

func (o *Overlay) ConfigureNetworking() error

ConfigureNetworking will add a loopback interface to the container so that localhost networking will still work

func (*Overlay) EnsureDirs

func (o *Overlay) EnsureDirs() error

EnsureDirs is a helper to make sure we have all directories in place

func (*Overlay) Mount

func (o *Overlay) Mount() error

Mount will set up the overlayfs structure with the lower/upper respected properly.

func (*Overlay) MountVFS

func (o *Overlay) MountVFS() error

MountVFS will bring up virtual filesystems within the chroot

func (*Overlay) Unmount

func (o *Overlay) Unmount() error

Unmount will tear down the overlay mount again

type Package

type Package struct {
	Name       string          // Name of the package
	Version    string          // Version of this package
	Release    int             // Solus upgrades are based entirely on relno
	Type       PackageType     // ypkg or pspec.xml legacy
	Path       string          // Path to the build spec
	Sources    []source.Source // Each package has 0 or more sources that we fetch
	CanNetwork bool            // Only applicable to ypkg builds
}

Package is the main item we deal with, avoiding the internals

func NewPackage

func NewPackage(path string) (*Package, error)

NewPackage will attempt to parse the given path, and return a new Package instance if this succeeds.

func NewXMLPackage

func NewXMLPackage(path string) (*Package, error)

NewXMLPackage will attempt to parse the pspec.xml file @ path

func NewYmlPackage

func NewYmlPackage(path string) (*Package, error)

NewYmlPackage will attempt to parse the ypkg package.yml file @ path

func NewYmlPackageFromBytes

func NewYmlPackageFromBytes(by []byte) (*Package, error)

NewYmlPackageFromBytes will attempt to parse the ypkg package.yml in memory

func (*Package) ActivateRoot

func (p *Package) ActivateRoot(overlay *Overlay) error

ActivateRoot will do the hard work of actually bring up the overlayfs system to allow manipulation of the roots for builds, etc.

func (*Package) BindCcache

func (p *Package) BindCcache(o *Overlay) error

BindCcache will make the ccache directory available to the build

func (*Package) BindSources

func (p *Package) BindSources(o *Overlay) error

BindSources will make the sources available to the chroot by bind mounting them into place.

func (*Package) Build

func (p *Package) Build(notif PidNotifier, history *PackageHistory, profile *Profile, pman *EopkgManager, overlay *Overlay, manifestTarget string) error

Build will attempt to build the package in the overlayfs system

func (*Package) BuildXML

func (p *Package) BuildXML(notif PidNotifier, pman *EopkgManager, overlay *Overlay) error

BuildXML will take care of building the legacy pspec.xml format, and is called only by Build()

func (*Package) BuildYpkg

func (p *Package) BuildYpkg(notif PidNotifier, usr *UserInfo, pman *EopkgManager, overlay *Overlay, h *PackageHistory) error

BuildYpkg will take care of the ypkg specific build process and is called only by Build()

func (*Package) Chroot

func (p *Package) Chroot(notif PidNotifier, pman *EopkgManager, overlay *Overlay) error

Chroot will attempt to spawn a chroot in the overlayfs system

func (*Package) CollectAssets

func (p *Package) CollectAssets(overlay *Overlay, usr *UserInfo, manifestTarget string) error

CollectAssets will search for the build files and copy them back to the users current directory. If solbuild was invoked via sudo, solbuild will then attempt to set the owner as the original user.

func (*Package) ConfigureRepos

func (p *Package) ConfigureRepos(notif PidNotifier, o *Overlay, pkgManager *EopkgManager, profile *Profile) error

ConfigureRepos will attempt to configure the repos according to the configuration of the manager.

func (*Package) CopyAssets

func (p *Package) CopyAssets(h *PackageHistory, o *Overlay) error

CopyAssets will copy all of the required assets into the builder root

func (*Package) CreateDirs

func (p *Package) CreateDirs(o *Overlay) error

CreateDirs creates any directories we may need later on

func (*Package) DeactivateRoot

func (p *Package) DeactivateRoot(overlay *Overlay)

DeactivateRoot will tear down the previously activated root

func (*Package) FetchSources

func (p *Package) FetchSources(o *Overlay) error

FetchSources will attempt to fetch the sources from the network if necessary

func (*Package) GetCcacheDir

func (p *Package) GetCcacheDir(o *Overlay) string

GetCcacheDir will return the externally visible ccache directory

func (*Package) GetCcacheDirInternal

func (p *Package) GetCcacheDirInternal() string

GetCcacheDirInternal will return the chroot-internal ccache directory for the given build type

func (*Package) GetSourceDir

func (p *Package) GetSourceDir(o *Overlay) string

GetSourceDir will return the externally visible work directory

func (*Package) GetSourceDirInternal

func (p *Package) GetSourceDirInternal() string

GetSourceDirInternal will return the chroot-internal source directory for the given build type.

func (*Package) GetWorkDir

func (p *Package) GetWorkDir(o *Overlay) string

GetWorkDir will return the externally visible work directory for the given build type.

func (*Package) GetWorkDirInternal

func (p *Package) GetWorkDirInternal() string

GetWorkDirInternal returns the internal chroot path for the work directory

func (*Package) Index

func (p *Package) Index(notif PidNotifier, dir string, overlay *Overlay) error

Index will attempt to index the given directory

func (*Package) PrepYpkg added in v1.2.0

func (p *Package) PrepYpkg(notif PidNotifier, usr *UserInfo, pman *EopkgManager, overlay *Overlay, h *PackageHistory) error

PrepYpkg will do the initial leg work of preparing us for a ypkg build.

type PackageHistory

type PackageHistory struct {
	Updates []*PackageUpdate
	// contains filtered or unexported fields
}

PackageHistory is an automatic changelog generated from the changes to the package.yml file during the history of the package.

Through this system, we provide a `history.xml` file to `ypkg-build` inside the container, which allows it to export the changelog back to the user.

This provides a much more natural system than having dedicated changelog files in package gits, as it reduces any and all duplication. We also have the opportunity to parse natural elements from the git history to make determinations as to the update *type*, such as a security update, or an update that requires a reboot to the users system.

Currently we're only scoping for security update notification, though more features will come in time.

func NewPackageHistory

func NewPackageHistory(pkgfile string) (*PackageHistory, error)

NewPackageHistory will attempt to analyze the git history at the given repository path, and return a usable instance of PackageHistory for writing to the container history.xml file.

The repository path will be taken as the directory name of the pkgfile that is given to this function.

func (*PackageHistory) GetLastVersionTimestamp added in v1.4.2

func (p *PackageHistory) GetLastVersionTimestamp() int64

GetLastVersionTimestamp will return a timestamp appropriate for us within reproducible builds.

This is calculated by using the timestamp from the last explicit version change, and not from simple bumps. The idea here is to only increment the timestamp if we've actually upgraded to a major version, and in general attempt to reduce the noise, and thus, produce better delta packages between minor package alterations

func (*PackageHistory) WriteXML

func (p *PackageHistory) WriteXML(path string) error

WriteXML will attempt to dump the update history to an XML file in order for ypkg to merge it into the package build.

type PackageType

type PackageType string

PackageType is simply the type of package we're building, i.e. xml / pspec

const (
	// PackageTypeXML is the legacy package format, to be removed with sol introduction.
	PackageTypeXML PackageType = "legacy"

	// PackageTypeYpkg is the native build format of Solus, the package.yml format
	PackageTypeYpkg PackageType = "ypkg"

	// PackageTypeIndex is a faux type to enable indexing
	PackageTypeIndex PackageType = "index"
)

type PackageUpdate

type PackageUpdate struct {
	Tag         string    // The associated git tag
	Author      string    // The author name of the change
	AuthorEmail string    // The author email of the change
	Body        string    // The associated message of the commit
	Time        time.Time // When the update took place
	ObjectID    string    // OID stored in string form
	Package     *Package  // Associated parsed package
	IsSecurity  bool      // Whether this is a security update
}

A PackageUpdate is a point in history in the git changes, which is parsed from a git.Commit

func NewPackageUpdate

func NewPackageUpdate(tag string, commit *git.Commit, objectID string) *PackageUpdate

NewPackageUpdate will attempt to parse the given commit and provide a usable entry for the PackageHistory

type Passwd

type Passwd struct {
	Users  map[string]*User
	Groups map[string]*Group
}

Passwd is a simple helper to parse passwd files from a chroot

func NewPasswd

func NewPasswd(path string) (*Passwd, error)

NewPasswd will parse the given path and return a friendly representation of those files

type PidNotifier

type PidNotifier interface {
	SetActivePID(int)
}

PidNotifier provides a simple way to set the PID on a blocking process

type Profile

type Profile struct {
	Name        string           `toml:"-"`            // Name of this profile, set by file name not toml
	Image       string           `toml:"image"`        // The backing image for this profile
	RemoveRepos []string         `toml:"remove_repos"` // A set of repos to remove. ["*"] is valid here.
	Repos       map[string]*Repo `toml:"repo"`         // Allow defining custom repos
	AddRepos    []string         `toml:"add_repos"`    // Allow locking to a single set of repos
}

A Profile is a configuration defining what backing image to use, what repos to add, etc.

func NewProfile

func NewProfile(name string) (*Profile, error)

NewProfile will attempt to load the named profile from the system paths

func NewProfileFromPath

func NewProfileFromPath(path string) (*Profile, error)

NewProfileFromPath will attempt to load a profile from the given file name

type Repo

type Repo struct {
	Name      string `toml:"-"`         // Name of the repo, set by implementation not yoml
	URI       string `toml:"uri"`       // URI of the repository
	Local     bool   `toml:"local"`     // Local repository for bindmounting
	AutoIndex bool   `toml:"autoindex"` // Enable automatic indexing of the repo
}

A Repo is a definition of a repository to add to the eopkg root during the build process.

type SortUpdatesByRelease added in v1.3.3

type SortUpdatesByRelease []*PackageUpdate

SortUpdatesByRelease is a simple wrapper to allowing sorting history

func (SortUpdatesByRelease) Len added in v1.3.3

func (a SortUpdatesByRelease) Len() int

func (SortUpdatesByRelease) Less added in v1.3.3

func (a SortUpdatesByRelease) Less(i, j int) bool

func (SortUpdatesByRelease) Swap added in v1.3.3

func (a SortUpdatesByRelease) Swap(i, j int)

type TransitManifest added in v1.4.1

type TransitManifest struct {

	// Every .tram file has a [manifest] header - this will never change and is
	// version agnostic.
	Manifest TransitManifestHeader `toml:"manifest"`

	// A list of files that accompanied this .tram upload
	File []TransitManifestFile `toml:"file"`
}

A TransitManifest is provided by build servers to validate the upload of packages into the incoming directory.

This is to ensure all uploads are intentional, complete and verifiable.

func NewTransitManifest added in v1.4.1

func NewTransitManifest(target string) *TransitManifest

NewTransitManifest will attempt to load the transit manifest from the named path and perform *basic* validation.

func (*TransitManifest) AddFile added in v1.4.1

func (t *TransitManifest) AddFile(path string) error

AddFile will attempt to add a file to the payload for this package

func (*TransitManifest) Write added in v1.4.1

func (t *TransitManifest) Write(path string) error

Write will dump the manifest to the given file path

type TransitManifestFile added in v1.4.1

type TransitManifestFile struct {

	// Relative filename, i.e. nano-2.7.5-68-1-x86_64.eopkg
	Path string `toml:"path"`

	// Cryptographic checksum to allow integrity checks post-upload/pre-merge
	Sha256 string `toml:"sha256"`
}

TransitManifestFile provides simple verification data for each file in the uploaded payload.

type TransitManifestHeader added in v1.4.1

type TransitManifestHeader struct {
	// Versioning to protect against future format changes
	Version string `toml:"version"`

	// The repo that the uploader is intending to upload *to*
	Target string `toml:"target"`
}

A TransitManifestHeader is required in all .tram uploads to ensure that both the sender and recipient are talking in the same fashion.

type User

type User struct {
	Name  string // User Name
	UID   int    // User ID
	GID   int    // User primary Group ID
	Gecos string // User Gecos (Pretty name)
	Home  string // User home directory
	Shell string // User shell program
}

A User is an /etc/passwd defined user

type UserInfo

type UserInfo struct {
	Name     string // Actual name
	Email    string // Actual email
	UID      int    // Unix User Id
	GID      int    // Unix Group ID
	HomeDir  string // Home directory of the user
	Username string // Textual username
}

UserInfo is required for ypkg builds, to set the .solus/package internally and propagate the author details.

func GetUserInfo

func GetUserInfo() *UserInfo

GetUserInfo will always succeed, as it will use a fallback policy until it finally comes up with a valid combination of name/email to use.

func (*UserInfo) SetFromCurrent

func (u *UserInfo) SetFromCurrent()

SetFromCurrent will set the UserInfo details from the current user

func (*UserInfo) SetFromGit

func (u *UserInfo) SetFromGit() bool

SetFromGit will set the username/email fields from the git config file

func (*UserInfo) SetFromPackager

func (u *UserInfo) SetFromPackager() bool

SetFromPackager will set the username/email fields from the legacy solus packager file.

func (*UserInfo) SetFromSudo

func (u *UserInfo) SetFromSudo() bool

SetFromSudo will attempt to set our details from sudo user environment

func (*UserInfo) WritePackager

func (u *UserInfo) WritePackager(path string) error

WritePackager will attempt to write the packager file to given path

type XMLArchive

type XMLArchive struct {
	Type    string `xml:"type,attr"`
	SHA1Sum string `xml:"sha1sum,attr"`
	URI     string `xml:",chardata"`
}

XMLArchive is an <Archive> line in Source section

type XMLPackage

type XMLPackage struct {
	Name    string
	Source  XMLSource
	History []XMLUpdate `xml:"History>Update"`
}

XMLPackage contains all of the pspec.xml metadata

type XMLSource

type XMLSource struct {
	Homepage string
	Name     string
	Archive  []XMLArchive
}

XMLSource is the actual source info for each pspec.xml

type XMLUpdate

type XMLUpdate struct {
	Release int `xml:"release,attr"`
	Date    string
	Version string
	Comment string
	Name    string
	Email   string
}

XMLUpdate represents an update in the package history

type YPKG

type YPKG struct {
	History []*YPKGUpdate `xml:">Update"`
}

YPKG provides ypkg-gen-history history.xml compatibility

type YPKGUpdate

type YPKGUpdate struct {
	Release int    `xml:"release,attr"`
	Type    string `xml:"type,attr,omitempty"`
	Date    string
	Version string
	Comment struct {
		Value string `xml:",cdata"`
	}
	Name struct {
		Value string `xml:",cdata"`
	}
	Email string
}

YPKGUpdate represents an update in the package history

type YmlPackage

type YmlPackage struct {
	Name       string
	Version    string
	Release    int
	Networking bool // If set to false (default) we disable networking in the build
	Source     []map[string]string
}

YmlPackage is a parsed ypkg build file

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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