Documentation
¶
Overview ¶
Package profiles and its subdirectoris implement support for managing external sofware dependencies. They offer a balance between providing no support at all and a full blown package manager. A profile is a named collection of software required for a given system component or application. The name of the profile refers to all of the required software, which may a single library or a collection of libraries or SDKs. Profiles thus refer to uncompiled source code that needs to be compiled for a specific "target". Targets represent compiled code and consist of:
1. An 'architecture' that refers to the CPU to be generate code for.
2. An 'operating system' that refers to the operating system to generate code for.
3. An 'environment' which is a set of environment variables to use when compiling and using the profile.
Targets provide the essential support for cross compilation.
The profiles package provides the data types to support its sub-packages, including a database format (in XML) that is used to store the state of the currently installed profiles.
The profilesmanager sub-package provides a registry for profile implementations to register themselves (by calling manager.Register from an init function for example).
The profilesreader sub-package provides support for reading the profiles database and performing common operations on it. profiles/commandline provides an easy to use command line environment for tools that need to read and/or write profiles.
The profilescmdline sub-package provides support for implementing command line clients that implement profile installation and for reading profile information. It also provides support for invoking sub-commands to manage families of profiles which uses the notion of a 'qualified' profile name where the profile name includes a prefix (separated by InstallSeparator) which identifies the sub-command responsible for managing that profile.
The profilesutil sub-package provides some utility routines intended for use by profile implementers.
Profiles may be installed, updated or removed. When doing so, the name of the profile is required, but the other components of the target are optional and will default to the values of the system that the commands are run on (so-called native builds). These operations are defined by the profiles/manager.Manager interface.
Index ¶
- Constants
- func QualifiedProfileName(installer, name string) string
- func RegisterTargetAndEnvFlags(flags *flag.FlagSet, target *Target)
- func RegisterTargetFlag(flags *flag.FlagSet, target *Target)
- func SplitProfileName(name string) (string, string)
- type Action
- type DB
- func (pdb *DB) AddProfileTarget(installer, name string, target Target) error
- func (pdb *DB) EnvFromProfile(installer, name string, target Target) []string
- func (pdb *DB) InstallProfile(installer, name, root string) *Profile
- func (pdb *DB) LookupProfile(installer, name string) *Profile
- func (pdb *DB) LookupProfileTarget(installer, name string, target Target) *Target
- func (pdb *DB) Names() []string
- func (pdb *DB) Path() string
- func (pdb *DB) Profiles() []*Profile
- func (pdb *DB) Read(jirix *jiri.X, path string) error
- func (pdb *DB) RemoveProfileTarget(installer, name string, target Target) bool
- func (pdb *DB) SchemaVersion() Version
- func (pdb *DB) UpdateProfileTarget(installer, name string, target Target) error
- func (pdb *DB) Write(jirix *jiri.X, installer, path string) error
- type Environment
- type Manager
- type Profile
- type Target
- func (pt *Target) Arch() string
- func (pt Target) CommandLineEnv() Environment
- func (pt Target) CrossCompiling() bool
- func (pt Target) DebugString() string
- func (t Target) Get() interface{}
- func (pt Target) IsSet() bool
- func (pt *Target) Less(pt2 *Target) bool
- func (pt Target) Match(pt2 *Target) bool
- func (pt *Target) OS() string
- func (t *Target) Set(val string) error
- func (pt *Target) SetVersion(v string)
- func (pt Target) String() string
- func (pt *Target) TargetSpecificDirname() string
- func (pt *Target) Usage() string
- func (pt *Target) UseCommandLineEnv()
- func (pt *Target) Version() string
- type Targets
- type Version
- type VersionInfo
- func (vi *VersionInfo) Default() string
- func (vi *VersionInfo) IsTargetNewerThanDefault(version string) bool
- func (vi *VersionInfo) IsTargetOlderThanDefault(version string) bool
- func (vi *VersionInfo) Lookup(version string, to interface{}) error
- func (vi *VersionInfo) Select(requested string) (string, error)
- func (vi *VersionInfo) String() string
- func (vi *VersionInfo) Supported() []string
Constants ¶
const InstallerSeparator = ":"
InstallerSeparator is the string used to separate the installer and profile name for qualified profile names.
Variables ¶
This section is empty.
Functions ¶
func QualifiedProfileName ¶
QualifiedProfileName returns the name of a profile qualified by the name of its installer, if any. If the installer is "myproject" and the profile name is "bar" then then returned string is "myproject" + InstallerSeparator + "bar". If the installer is not specified then the unqualified name, without InstallerSeparator is returned. If the supplied name is already qualified then the existing qualifier will be removed and the supplied one used instead. Any leading colons in name will be stripped.
func RegisterTargetAndEnvFlags ¶
RegisterTargetAndEnvFlags registers the commonly used --target and --env flags with the supplied FlagSet
func RegisterTargetFlag ¶
RegisterTargetFlag registers the commonly used --target flag with the supplied FlagSet.
func SplitProfileName ¶
SplitProfileName returns the installer and profile name in the case where the name is qualified (see QualifiedProfileName) or just the profile name if it is not so qualified.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
func (*DB) AddProfileTarget ¶
AddProfileTarget adds the specified target to the named profile. The UpdateTime of the newly installed target will be set to time.Now()
func (*DB) EnvFromProfile ¶
EnvFromProfile obtains the environment variable settings from the specified profile and target. It returns nil if the target and/or profile could not be found.
func (*DB) InstallProfile ¶
InstallProfile will create a new profile to the profiles database, it has no effect if the profile already exists. It returns the profile that was either newly created or already installed.
func (*DB) LookupProfile ¶
LookupProfile returns the profile for the supplied installer and profile name or nil if one is not found.
func (*DB) LookupProfileTarget ¶
LookupProfileTarget returns the target information stored for the supplied installer, profile name and target.
func (*DB) Names ¶
Names returns the names, in lexicographic order, of all of the currently available profiles.
func (*DB) Profiles ¶
Profiles returns all currently installed the profiles, in lexicographic order.
func (*DB) Read ¶
Read reads the specified database directory or file to obtain the current set of installed profiles into the receiver database. It is not an error if the database does not exist, instead, an empty database is returned.
func (*DB) RemoveProfileTarget ¶
RemoveProfileTarget removes the specified target from the named profile. If this is the last target for the profile then the profile will be deleted from the database. It returns true if the profile was so deleted or did not originally exist.
func (*DB) SchemaVersion ¶
SchemaVersion returns the version of the xml schema used to implement the database.
func (*DB) UpdateProfileTarget ¶
UpdateProfileTarget updates the specified target from the named profile. The UpdateTime of the updated target will be set to time.Now()
type Environment ¶
type Environment struct {
Vars []string `xml:"var"`
}
func (Environment) Usage ¶
func (e Environment) Usage() string
Usage returns the usage string for Environment.
type Manager ¶
type Manager interface { // Name returns the unqualified name of this profile. Name() string // Installer returns the installer for this profile. Installer() string // Info returns an informative description of the profile. Info() string // VersionInfo returns the VersionInfo instance for this profile. VersionInfo() *VersionInfo // String returns a string representation of the profile, conventionally // this is its qualified name and version. String() string // AddFlags allows the profile manager to add profile specific flags // to the supplied FlagSet for the specified Action. // They should be named <profile-name>.<flag>. AddFlags(*flag.FlagSet, Action) // OSPackages returns the set of operating system packages required by the // specified profile and target. OSPackages(jirix *jiri.X, pdb *DB, root jiri.RelPath, target Target) ([]string, error) // Install installs the profile for the specified build target. Install(jirix *jiri.X, pdb *DB, root jiri.RelPath, target Target) error // Uninstall uninstalls the profile for the specified build target. Uninstall(jirix *jiri.X, pdb *DB, root jiri.RelPath, target Target) error }
Manager is the interface that must be implemented in order to manage (i.e. install/uninstall) and describe a profile.
type Profile ¶
type Profile struct {
// contains filtered or unexported fields
}
Profile represents an installed profile and its associated targets.
type Target ¶
type Target struct { // The environment as modified by a profile implementation Env Environment InstallationDir string // where this target is installed. UpdateTime time.Time // contains filtered or unexported fields }
Target represents specification for the environment that the profile is to be built for. Targets include a version string to allow for upgrades and for the simultaneous existence of incompatible versions.
Target and Environment implement flag.Getter so that they may be used with the flag package. Two flags are required, one to specify the target in <arch>-<os>@<version> format and a second to specify environment variables either as comma separated values or as repeated arguments.
func DefaultTarget ¶
func DefaultTarget() Target
DefaultTarget returns a default value for a Target. Use this function to initialize Targets that are expected to set from the command line via the flags package.
func FindTarget ¶
FindTarget returns the first target that matches the requested target from the slice of Targets. If target has not been explicitly set and there is only a single target available in targets then that one target is considered as matching.
func FindTargetWithDefault ¶
FindTargetWithDefault is like FindTarget except that if there is only one target in the slice and the requested target has not been explicitly set (IsSet is false) then that one target is returned by default.
func NativeTarget ¶
func NativeTarget() Target
NativeTarget returns a value for Target for the host on which it is running. Use this function for Target values that are passed into other functions and libraries where a native target is specifically required.
func NewTarget ¶
NewTarget creates a new target using the supplied target and environment parameters specified in command line format.
func (Target) CommandLineEnv ¶
func (pt Target) CommandLineEnv() Environment
CommandLineEnv returns the environment variables set on the command line for this target.
func (Target) CrossCompiling ¶
CrossCompiling returns true if the target differs from that of the runtime.
func (Target) DebugString ¶
DebugString returns a pretty-printed representation of pt.
func (*Target) Less ¶
Less returns true if pt2 is considered less than pt. The ordering takes into account only the architecture, operating system and version of the target. The architecture and operating system are ordered lexicographically in ascending order, then the version is ordered but in descending lexicographic order except that the empty string is considered the 'highest' value. Thus, (targets in <arch>-<os>[@<version>] format), are all true: b-c < c-c b-c@3 < b-c@2
func (Target) Match ¶
Match returns true if pt and pt2 meet the following criteria in the order they are listed:
- if the Arch and OS fields are exactly the same
- if pt has a non-zero length Version field, then it must be the same as that in pt2
Match is used by the various methods and functions in this package when looking up Targets unless otherwise specified.
func (*Target) SetVersion ¶
SetVersion sets the version for the target.
func (*Target) TargetSpecificDirname ¶
TargetSpecificDirname returns a directory name that is specific to that target taking account the architecture, operating system and command line environment variables, if relevant, into account (e.g GOARM={5,6,7}).
func (*Target) UseCommandLineEnv ¶
func (pt *Target) UseCommandLineEnv()
UseCommandLineEnv copies the command line supplied environment variables into the mutable environment of the Target. It should be called as soon as all command line parsing has been completed and before the target is otherwise used.
type Targets ¶
type Targets []*Target
Targets is a list of *Target's ordered by architecture, operating system and descending versions.
func InsertTarget ¶
InsertTarget inserts the given target into Targets if it's not already there and returns a new slice.
func RemoveTarget ¶
RemoveTarget removes the given target from a slice of Target and returns a slice.
type Version ¶
type Version int
const ( // Original, old-style profiles without a version # Original Version = 0 // First version of new-style profiles. V2 Version = 2 // V3 added support for recording the options that were used to install profiles. V3 Version = 3 // V4 adds support for relative path names in profiles and environment variable. V4 Version = 4 // V5 adds support for multiple profile installers. V5 Version = 5 )
type VersionInfo ¶
type VersionInfo struct {
// contains filtered or unexported fields
}
VersionInfo represents the supported and default versions offered by a profile and a map of versions to arbitrary metadata used internally by the profile implementation.
func NewVersionInfo ¶
func NewVersionInfo(name string, supported map[string]interface{}, defaultVersion string) *VersionInfo
NewVersionInfo creates a new instance of VersionInfo from the supplied map of supported versions and their associated metadata. The keys for this map are the supported version strings. The supplied defaultVersion will be used whenever a specific version is not requested.
func (*VersionInfo) Default ¶
func (vi *VersionInfo) Default() string
Default returns the default version.
func (*VersionInfo) IsTargetNewerThanDefault ¶
func (vi *VersionInfo) IsTargetNewerThanDefault(version string) bool
IsTargetNewerThanDefault returns true if the supplied version is newer than the default.
func (*VersionInfo) IsTargetOlderThanDefault ¶
func (vi *VersionInfo) IsTargetOlderThanDefault(version string) bool
IsTargetOlderThanDefault returns true if the supplied version is older than the default.
func (*VersionInfo) Lookup ¶
func (vi *VersionInfo) Lookup(version string, to interface{}) error
Lookup returns the metadata associated with the requested version.
func (*VersionInfo) Select ¶
func (vi *VersionInfo) Select(requested string) (string, error)
Select selects a version from the available ones that best matches the requested one. If requested is the emtpy string then the default version is returned, otherwise an exact match is required.
func (*VersionInfo) String ¶
func (vi *VersionInfo) String() string
String returns a string representation of the VersionInfo, in particular it lists all of the supported versions with an asterisk next to the default.
func (*VersionInfo) Supported ¶
func (vi *VersionInfo) Supported() []string
Supported returns the set of supported versions.
Directories
¶
Path | Synopsis |
---|---|
Package profilescmdline provides a command line driver (for v.io/x/lib/cmdline) for implementing jiri 'profile' subcommands.
|
Package profilescmdline provides a command line driver (for v.io/x/lib/cmdline) for implementing jiri 'profile' subcommands. |
internal/i1
Profiles are used to manage external sofware dependencies and offer a balance between providing no support at all and a full blown package manager.
|
Profiles are used to manage external sofware dependencies and offer a balance between providing no support at all and a full blown package manager. |
internal/i2
Profiles are used to manage external sofware dependencies and offer a balance between providing no support at all and a full blown package manager.
|
Profiles are used to manage external sofware dependencies and offer a balance between providing no support at all and a full blown package manager. |
Package profilesmanager provides support for managing jiri profiles.
|
Package profilesmanager provides support for managing jiri profiles. |
Package profilesreader provides support for reading and processing jiri profiles.
|
Package profilesreader provides support for reading and processing jiri profiles. |
package profilesutil provides utility routines for implementing profiles.
|
package profilesutil provides utility routines for implementing profiles. |