ports

package
v0.0.0-...-d2748b6 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2020 License: GPL-3.0 Imports: 13 Imported by: 2

Documentation

Overview

Package ports implements various handy functions to interact with CRUX ports.

This package is a work in progress and EXPERIMENTAL.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Prtdir defines The root directory of the ports tree.
	PrtDir = "/usr/ports"

	// PkgDir defines the directory where created packages get stored.
	PkgDir = "."

	// SrcDir defines the directory where downloaded sources get stored.
	SrcDir = "."

	// WrkDir defines the root directory where packages get build..
	WrkDir = "."

	// Order gets used to determine how to order multiple ports with the same
	// name, but residing in a different repository. The repository found first
	// in the Order variable being ordered firt.
	Order []string

	// Alias gets used used to alias one port location to another port location.
	Aliases [][]Location
)

Functions

func Contains

func Contains(ports []Port, location Location) bool

Contains tests if a location is in a list of Ports.

Types

type Database

type Database struct {
	Packages []Package
}

Database is a type describing the package database file. This file lists all installed packages, the version of these packages, and the files these packages installed.

func (*Database) Parse

func (f *Database) Parse() error

Parse parses the `db` file and populates the various fields in the given `*Database`.

type Footprint

type Footprint struct {
	*Port

	Files []struct {
		Path       string
		Permission Permission
	}
}

A Footprint describes the `.footprint` file of a port. This file is used for regression testing and contains a list of files a package is expected to contain once it is built. TODO: Handle symlinks (`->`).

func (*Footprint) Parse

func (f *Footprint) Parse() error

Parse parses the `.footprint` file of a port and populates the various fields in the given `*Footprint`.

type Location

type Location struct {
	Root string
	Repo string
	Port string
}

A Location describes the location of a port. A port location consist of a ports-tree directory, a repo and a port. An example of a valid location would be `usr/ports/opt/firefox`.

func (Location) Base

func (l Location) Base() string

Base returns the repo and port name. An example of this would be `opt/firefox`.

func (Location) Full

func (l Location) Full() string

Full returns the ports-tree directory, the repo and port name. An example of this would be `/usr/ports/opt/firefox`.

type Md5sum

type Md5sum struct {
	*Port

	Files []struct {
		File string
		Hash string
	}
}

An Md5sum is a type describing the `.md5sum` file of a port. This file is used to validate the sources of a port.

func (*Md5sum) Create

func (f *Md5sum) Create() error

Create creates an `.md5sum` file for a Port. This function requires `Pkgfile.Parse(true)` to be run prior.

func (*Md5sum) Parse

func (f *Md5sum) Parse() error

Parse parses the `.md5sum` file of a port and populates the various fields in the given `*Md5sum`.

func (*Md5sum) Validate

func (f *Md5sum) Validate() error

Validate compares the Ports `.md5sum` file to the hashed source files. This function requires `Pkgfile.Parse(true)` and `Md5sum.Parse()` to be run prior. TODO: This required some download function to be run.

type Package

type Package struct {
	Name    string
	Version string
	Release string

	Files []string
}

Package is a type describing a package.

type Permission

type Permission struct {
	FileMode os.FileMode
	// TODO: Create a custom type for this.
	Owner string
}

An Permission is a type describing the permission bits found in the `.md5sum` file of a port.

type Pkgfile

type Pkgfile struct {
	*Port

	// Comments with various information that isn't strictly needed in order to
	// build a package.
	Description string
	URL         string
	Maintainer  string

	// Comments with information about dependencies. These need some more
	// parsing because some `Pkgfile`s use commas to separate dependencies, and
	// others use spaces.
	Depends  []string
	Optional []string

	// BASH variables with various information that is required in order to
	// build a package.
	Name    string
	Version string
	Release string

	// A BASH array with the sources needed to build a package. We probably need
	// to parse this by actually using `source(1)` because `Pkgfile`s often use
	// BASH variables (such as `$name` or `$version`) and bashisms in the source
	// variable.
	Source []string
}

A Pkgfile is a type describing the `Pkgfile` file of a port. This file contains information about the package (such as `name`, `version`, et cetera) and the commands that should be executed in order to compile the package in question.

func (*Pkgfile) Parse

func (f *Pkgfile) Parse(strict ...bool) error

Parse parses the `Pkgfile` file of a port and populates the various fields in the given `*Pkgfile`. Keep in mind that this does not expand BASH ariables by default. so `$version` will just be a literal string. Nor does this parse the `source` field of a `Pkgfile` because it often uses variables in the string and because it's simply too hard too parse.

If you want to expand BASH variables pass a bool as a parameter. This will force the use of a bash interpreter to get the variables in `Pkgfile`, this is relatively slow.

func (*Pkgfile) Validate

func (f *Pkgfile) Validate() error

Validate checks if all required variables and functions are in a `Pkgfile` file. TODO: Check for `build()` function

type Port

type Port struct {
	// Location specifies the location of the port, this is used as the "primary
	// key" of a port type.
	Location Location

	// TODO: Add signature, .nostrip, et cetera.
	Footprint Footprint
	Md5sum    Md5sum
	Pkgfile   Pkgfile

	// Depends is a "recursive variable" that list all dependencies recursively.
	// This
	Depends []*Port
}

A Port describes a port. A port is a directory containing the files needed for building a package.

func All

func All() ([]Port, error)

All lists all ports found in the PrtDir.

func Locate

func Locate(ports []Port, port string) ([]Port, error)

Locate tries to locate a port using a given list of Ports. It returns a list with possible ports, sorted according to the order parameter.

func New

func New(location string) Port

New returns a Port with the Location field populated. Use the various `Parse` functions to populate the other fields.

func (*Port) Alias

func (p *Port) Alias()

Alias aliases ports by using the `Aliases` variable. An example of this would be aliasing `core/openssl` to `6c37/libressl`.

func (Port) CreateWrk

func (p Port) CreateWrk() error

CreateWrk creates the necessary WrkDir directories.

func (*Port) ParseDepends

func (p *Port) ParseDepends(ports []Port, alias bool) error

ParseDepends is a function that calculates dependencies recursively and populates `Depends`. This function requires `Pkgfile.Parse()` to be run prior.

Jump to

Keyboard shortcuts

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