sw

package module
v0.0.0-...-32b2658 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: BSD-3-Clause Imports: 23 Imported by: 0

README

sw is very much inspired by HP-UX's SD-UX (the swlist, swinstall, swcopy, etc. series of commands). It is a reimplementation of these commands on top of a more basic package management system: the RedHat Package Manager (RPM). Ultimately, sw could be seen as yum or apt-get on steroids.

One of the main motivations behind that is the incredible versatility of SD-UX's filters and predicates.

Documentation

Index

Constants

View Source
const (
	ARCH_i386   = "i386"
	ARCH_i486   = "i486"
	ARCH_i586   = "i586"
	ARCH_i686   = "i686"
	ARCH_x86_64 = "x86_64"
	ARCH_none   = "noarch"
	ARCH_source = "source"
	ARCH_ppc    = "ppc"
	ARCH_ppc64  = "ppc64"
)
View Source
const (
	RPMSENSE_ANY     = 0
	RPMSENSE_LESS    = (1 << 1)
	RPMSENSE_GREATER = (1 << 2)
	RPMSENSE_EQUAL   = (1 << 3)
	/* bit 4 unused */
	RPMSENSE_POSTTRANS     = (1 << 5)  /*!< %posttrans dependency */
	RPMSENSE_PREREQ        = (1 << 6)  /* legacy prereq dependency */
	RPMSENSE_PRETRANS      = (1 << 7)  /*!< Pre-transaction dependency. */
	RPMSENSE_INTERP        = (1 << 8)  /*!< Interpreter used by scriptlet. */
	RPMSENSE_SCRIPT_PRE    = (1 << 9)  /*!< %pre dependency. */
	RPMSENSE_SCRIPT_POST   = (1 << 10) /*!< %post dependency. */
	RPMSENSE_SCRIPT_PREUN  = (1 << 11) /*!< %preun dependency. */
	RPMSENSE_SCRIPT_POSTUN = (1 << 12) /*!< %postun dependency. */
	RPMSENSE_SCRIPT_VERIFY = (1 << 13) /*!< %verify dependency. */
	RPMSENSE_FIND_REQUIRES = (1 << 14) /*!< find-requires generated dependency. */
	RPMSENSE_FIND_PROVIDES = (1 << 15) /*!< find-provides generated dependency. */

	RPMSENSE_TRIGGERIN     = (1 << 16) /*!< %triggerin dependency. */
	RPMSENSE_TRIGGERUN     = (1 << 17) /*!< %triggerun dependency. */
	RPMSENSE_TRIGGERPOSTUN = (1 << 18) /*!< %triggerpostun dependency. */
	RPMSENSE_MISSINGOK     = (1 << 19) /*!< suggests/enhances hint. */
	/* bits 20-23 unused */
	RPMSENSE_RPMLIB       = (1 << 24) /*!< rpmlib(feature) dependency. */
	RPMSENSE_TRIGGERPREIN = (1 << 25) /*!< %triggerprein dependency. */
	RPMSENSE_KEYRING      = (1 << 26)
	/* bit 27 unused */
	RPMSENSE_CONFIG = (1 << 28)
)
View Source
const (
	Name Details = 1 << iota
	Version
	Status
	Description
	Dependencies
	Files
	Changelog
	AllDetails = (1 << iota) - 1

	Summary      = Name | Version | Status | Description
	Quick        = Summary
	Detailed     = Summary | Dependencies
	MoreDetailed = Detailed | Files
)
View Source
const (
	Any = 0

	Less = (1 << iota)
	Greater
	Eq

	AtMost  = Less | Eq
	AtLeast = Greater | Eq
	Not     = Less | Greater
)

Variables

View Source
var (
	ErrNotRPM     = errors.New("invalid RPM file")
	ErrRPMVersion = errors.New("unsupported RPM version")
)
View Source
var EOF = errors.New("EOF")
View Source
var (
	ErrNotYUM = errors.New("invalid YUM repository")
)
View Source
var Forward struct {
	Local, Remote net.Addr
}

Functions

func Cmp

func Cmp(v1, v2 Revision) int

func Compatible

func Compatible(a, b Architecture) bool

func FilePath

func FilePath(u url.URL) string

func URL

func URL(src string) *url.URL

Types

type Architecture

type Architecture string

func (Architecture) Accept

func (target Architecture) Accept(arch Architecture) bool

true if arch can be installed on target

func (Architecture) Canon

func (arch Architecture) Canon() Architecture

type ChangelogEntry

type ChangelogEntry struct {
	Time time.Time
	Name string
	Text string
}

type Constraint

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

type Details

type Details int

type Operator

type Operator int

func NewOperator

func NewOperator(s string) Operator

func (Operator) String

func (op Operator) String() (s string)

type Package

type Package struct {
	Name         string       `json:",omitempty" xml:"name,attr,omitempty"`
	Title        string       `json:",omitempty" xml:",omitempty"`
	Description  string       `json:",omitempty" xml:",omitempty"`
	Revision     Revision     `json:",omitempty" xml:"revision,attr,omitempty"`
	Arch         Architecture `json:",omitempty" xml:"arch,attr,omitempty"`
	OS           string       `json:",omitempty" xml:",omitempty"`
	Vendor       string       `json:",omitempty" xml:",omitempty"`
	License      string       `json:",omitempty" xml:",omitempty"`
	Packager     string       `json:",omitempty" xml:",omitempty"`
	Source       string       `json:",omitempty" xml:",omitempty"`
	Category     string       `json:",omitempty" xml:",omitempty"`
	Website      string       `json:",omitempty" xml:",omitempty"`
	Installation time.Time    `json:",omitempty" xml:",omitempty"`
	Location     string       `json:",omitempty" xml:",omitempty"`
	Size         int64

	Require,
	Provide,
	Conflict,
	Obsolete,
	Enhance,
	Suggest Specifications `json:",omitempty" xml:",omitempty"`

	Changelog []ChangelogEntry `json:",omitempty" xml:",omitempty"`

	Selected bool
	Masked   bool
	Required bool
	// contains filtered or unexported fields
}

func (*Package) Contains

func (pkg *Package) Contains(name string) bool

func (*Package) Deselect

func (pkg *Package) Deselect()

func (*Package) Files

func (pkg *Package) Files() (files []string)

func (*Package) Installed

func (pkg *Package) Installed() bool

func (*Package) Mask

func (pkg *Package) Mask()

func (*Package) Obsoletes

func (pkg *Package) Obsoletes(s *Specification) bool

func (*Package) Satisfies

func (pkg *Package) Satisfies(s *Specification) bool

func (*Package) Select

func (pkg *Package) Select()

func (*Package) ShortSpec

func (pkg *Package) ShortSpec() *Specification

func (*Package) Specification

func (pkg *Package) Specification() *Specification

func (*Package) String

func (pkg *Package) String() string

func (*Package) Trim

func (pkg *Package) Trim(details Details)

func (*Package) URL

func (pkg *Package) URL() *url.URL

func (*Package) Unmask

func (pkg *Package) Unmask()

type RPMDatabase

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

func (RPMDatabase) Close

func (rpm RPMDatabase) Close()

func (RPMDatabase) Erase

func (rpm RPMDatabase) Erase(spec []Specification) error

func (RPMDatabase) ForEach

func (rpm RPMDatabase) ForEach(details Details, f func(*Package) error) error

func (RPMDatabase) Host

func (rpm RPMDatabase) Host() string

func (RPMDatabase) Install

func (rpm RPMDatabase) Install(urls []url.URL) error

func (*RPMDatabase) Open

func (rpm *RPMDatabase) Open(src string) error

func (*RPMDatabase) SetProxy

func (rpm *RPMDatabase) SetProxy(p net.Addr)

func (*RPMDatabase) SetVerbose

func (rpm *RPMDatabase) SetVerbose(v bool)

func (RPMDatabase) String

func (rpm RPMDatabase) String() string

type RPMFile

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

func (RPMFile) Close

func (rpm RPMFile) Close()

func (RPMFile) ForEach

func (rpm RPMFile) ForEach(details Details, f func(*Package) error) error

func (RPMFile) Host

func (rpm RPMFile) Host() string

func (*RPMFile) Open

func (rpm *RPMFile) Open(src string) error

func (RPMFile) String

func (rpm RPMFile) String() string

type Repository

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

func (Repository) Close

func (repo Repository) Close()

func (Repository) ForEach

func (repo Repository) ForEach(details Details, f func(*Package) error) error

func (Repository) Host

func (repo Repository) Host() string

func (*Repository) Open

func (repo *Repository) Open(src string) error

func (Repository) String

func (repo Repository) String() string

type Revision

type Revision string

func NewRevision

func NewRevision(parts ...Revision) (revision Revision)

func (Revision) Cmp

func (v1 Revision) Cmp(v2 Revision) int

Cmp compares v1 and v2 and returns:

-1 if v1 <  v2
 0 if v1 == v2
+1 if v1 >  v2

func (Revision) Epoch

func (v Revision) Epoch() Revision

func (Revision) Match

func (v1 Revision) Match(v2 Revision) (bool, error)

func (Revision) Release

func (v Revision) Release() Revision

func (Revision) Short

func (v Revision) Short() Revision

func (Revision) String

func (revision Revision) String() string

type RpmHeader

type RpmHeader struct {
	RpmTag []struct {
		Name    string   `xml:"name,attr"`
		String  []string `xml:"string"`
		Integer []int64  `xml:"integer"`
		Base64  []string `xml:"base64"`
	} `xml:"rpmTag"`
}

type Source

type Source interface {
	ForEach(Details, func(*Package) error) error
	Close()
	String() string
	Host() string
}

type Specification

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

func NewSpecification

func NewSpecification(name string, op Operator, ver Revision) *Specification

func ParseSpecification

func ParseSpecification(s string) (*Specification, error)

func (*Specification) AddFilter

func (a *Specification) AddFilter(attr string, op Operator, filter string) *Specification

func (*Specification) AddRevision

func (a *Specification) AddRevision(op Operator, ver Revision) *Specification

func (*Specification) Equal

func (p *Specification) Equal(q *Specification) bool

func (*Specification) GetFilter

func (a *Specification) GetFilter(attr string) []Constraint

func (*Specification) IsSimple

func (p *Specification) IsSimple() bool

func (*Specification) MarshalText

func (s *Specification) MarshalText() ([]byte, error)

func (*Specification) SatisfiedBy

func (a *Specification) SatisfiedBy(b *Specification) (result bool)

func (*Specification) Satisfies

func (p *Specification) Satisfies(q *Specification) bool

func (Specification) String

func (a Specification) String() (result string)

func (*Specification) UnmarshalText

func (s *Specification) UnmarshalText(text []byte) error

type Specifications

type Specifications map[string]*Specification

func (Specifications) Append

func (specs Specifications) Append(s *Specification)

type Target

type Target interface {
	Source // a target is also a source

	Install(urls []url.URL) error
	Erase([]Specification) error
	SetProxy(net.Addr)
	SetVerbose(bool)
}

type YUMRepository

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

func (*YUMRepository) Close

func (repo *YUMRepository) Close()

func (YUMRepository) ForEach

func (repo YUMRepository) ForEach(details Details, f func(*Package) error) error

func (*YUMRepository) Open

func (repo *YUMRepository) Open(src string) error

Directories

Path Synopsis
cmd
sw
internal

Jump to

Keyboard shortcuts

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