repo

package
v0.22.2 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package repoctl provides functions for managing Arch repositories.

Index

Constants

This section is empty.

Variables

View Source
var (
	SystemRepoAdd    = "repo-add"
	SystemRepoRemove = "repo-remove"
)
View Source
var (
	ErrProfileInvalid  = errors.New("require valid profile")
	ErrRepoDirRelative = errors.New("repository directory path must be absolute")
	ErrRepoDirMissing  = errors.New("repository directory path does not exist")
	ErrRepoDirInvalid  = errors.New("repository directory path is invalid")
	ErrPkgDirExists    = errors.New("package destination directory already exists")
	ErrPkgFileExists   = errors.New("package destination file already exists")
)

Functions

func DependencyGraph

func DependencyGraph(pkgnames []string) (*graph.Graph, error)

DependencyGraph returns a dependency graph of the given package names.

func Download

func Download(destdir string, extract bool, clobber bool, pkgnames []string) error

Download downloads and extracts the given package tarballs.

If a package cannot be found, it will be reported, but the rest of the packages will be downloaded.

func DownloadExtractAUR

func DownloadExtractAUR(ap *aur.Package, destdir string, clobber bool) error

DownloadExtractAUR is a helper for Download and DownloadUpgrades.

func DownloadPackages

func DownloadPackages(pkgs aur.Packages, destdir string, extract bool, clobber bool) error

DownloadPackages downloads the given AUR packages, printing messages for each one.

func DownloadTarballAUR

func DownloadTarballAUR(ap *aur.Package, destdir string, clobber bool) error

DownloadTarballAUR downloads the given package from AUR.

func List

func List(pkgs pacman.AnyPackages, f pkgutil.MapFunc) []string

Types

type InvalidFileError

type InvalidFileError struct {
	Filepath string
	WantDir  bool
}

func (InvalidFileError) Error

func (e InvalidFileError) Error() string

type NotExistsError

type NotExistsError struct {
	Filepath string
}

func (NotExistsError) Error

func (e NotExistsError) Error() string

type Repo

type Repo struct {
	// Directory is the absolute path to the directory where the
	// packages are stored.
	Directory string
	// Database is the relative path to the repository database,
	// relative from Directory.
	Database string

	// RequireSignature specifies whether files can be added without signature.
	RequireSignature bool
	// Backup specifies whether to backup old packages.
	Backup bool
	// BackupDir specifies where old packages are backed up to.
	// If the path is not absolute, then it is interpreted as
	// relative to the repository directory.
	BackupDir string
	// IgnoreUpgrades specifies which packages to ignore when looking
	// for upgrades. Explicitely specifying the file will override the
	// ignore however.
	IgnoreAUR []string

	// AddParameters are parameters to add to the repo-add
	// command line.
	AddParameters []string
	// RemoveParameters are parameters to add to the repo-remove
	// command line.
	RemoveParameters []string
}

func New

func New(repo string) *Repo

New creates a new default configuration with repo as the repository database. It is assumed that the database resides in the same directory as the packages.

If repo is invalid (because it is absolute), nil is returned. We don't check for database existance, because at this point, it might not exist yet.

func NewFromConf

func NewFromConf(c *conf.Configuration) (*Repo, error)

NewFromConf creates a new configuration based on the configuration file.

func (*Repo) AddToDatabase

func (r *Repo) AddToDatabase(pkgfiles ...string) error

AddToDatabase adds the given packages to the repository database.

func (*Repo) AssertSetup

func (r *Repo) AssertSetup() error

AssertSetup returns nil if a normal repository setup is present: the directory exists.

While it would make sense to check for readability and writability, in modern systems there are so many ways to achieve this, that to test all of them is more effort than it is worth.

func (*Repo) Copy

func (r *Repo) Copy(h errs.Handler, pkgfiles ...string) error

Copy copies the given files into the repository if they do not already exist there and adds them to the database.

func (*Repo) CreateDatabase

func (r *Repo) CreateDatabase() error

CreateDatabase creates the repository database (but does nothing else).

func (*Repo) DatabasePath

func (r *Repo) DatabasePath() string

DatabasePath returns the entire path to the database.

func (*Repo) DeleteDatabase

func (r *Repo) DeleteDatabase() error

DeleteDatabase deletes the repository database (but not the files).

func (*Repo) Dispatch

func (r *Repo) Dispatch(h errs.Handler, pkgfiles ...string) error

Dispatch either removes the given files or it backs them up.

func (*Repo) Exists

func (r *Repo) Exists(p pacman.AnyPackage) bool

Exists checks the existance of a package file; this is only necessary for packages read from the database. If the file can't be read for any reason, then chances are any client will not be able to read it either, and so false is returned.

func (*Repo) FindMissing

func (r *Repo) FindMissing() (pacman.Packages, error)

FindMissing returns all packages from the database that do not have associated files existing.

func (*Repo) FindNewest

func (r *Repo) FindNewest(h errs.Handler, pkgnames ...string) (pacman.Packages, error)

FindNewest returns the newest package files found for the given package names. If no names are given, all names are searched for.

func (*Repo) FindSimilar

func (r *Repo) FindSimilar(h errs.Handler, pkgfiles ...string) (pacman.Packages, error)

FindSimilar finds package files in the repository that have the same package name. The pkgfile given is filtered from the results.

This makes this function useful for finding all the other packages given a particular package file.

If no pkgfiles are given, nil is returned.

func (*Repo) FindUpdates

func (r *Repo) FindUpdates(h errs.Handler, pkgnames ...string) (pacman.Packages, error)

FindUpdates finds all given packages with updates. If no names are given, all names are checked. Multiple packages with the same name may be returned. Use pkutil.FilterNewest to deal with this.

func (*Repo) FindUpgrades

func (r *Repo) FindUpgrades(h errs.Handler, pkgnames ...string) (Upgrades, error)

FindUpgrades finds all upgrades it finds to the given packages. If no package names are given, all available package names are searched.

func (*Repo) IgnoreFltr

func (r *Repo) IgnoreFltr() pkgutil.FilterFunc

IgnoreFltr returns a FilterFunc for filtering out packages that should be ignored. For example, for a list of meta.Packages:

pkgs = pkgutil.Filter(pkgs, r.ignoreFltr()).(meta.Packages)

func (*Repo) IgnoreMap

func (r *Repo) IgnoreMap() map[string]bool

IgnoreMap returns a map of packages to ignore.

func (*Repo) IsObsoleteCached

func (r *Repo) IsObsoleteCached() bool

IsObsoleteCached returns true when obsolete package files should be cached instead of backed-up or deleted.

If the backup directory is the directory where all the packages are, then the idea is that we leave them in place.

func (r *Repo) Link(h errs.Handler, pkgfiles ...string) error

Link tries to hard link the file, and failing that, copies it over.

func (*Repo) ListDatabase

func (r *Repo) ListDatabase(f pkgutil.MapFunc) ([]string, error)

func (*Repo) ListDirectory

func (r *Repo) ListDirectory(h errs.Handler, f pkgutil.MapFunc) ([]string, error)

func (*Repo) ListMeta

func (r *Repo) ListMeta(h errs.Handler, aur bool, f func(pacman.AnyPackage) string) ([]string, error)

func (*Repo) MakeAbs

func (r *Repo) MakeAbs(pkgs pacman.Packages)

MakeAbs makes all package filenames absolute. It is much easier to do this to all packages than figure out when we need it and when we don't.

func (*Repo) Move

func (r *Repo) Move(h errs.Handler, pkgfiles ...string) error

Move moves the given files into the repository if they do not already exist there and adds them to the database. If the files already exist there, then they are still deleted from where they were. Thus, the move always appears to have worked, even if no work was done.

The exception is that when the source and destination files are the same; then no move or deletion is performed.

func (*Repo) Name

func (r *Repo) Name() string

Name returns the name of the repository, which is interpreted to be the name of the database up to the first period.

func (*Repo) OnlyNames

func (r *Repo) OnlyNames(h errs.Handler) ([]string, error)

OnlyNames reads all possible package names from the repository. This includes packages from the database where the files have been deleted.

func (*Repo) ReadAUR

func (r *Repo) ReadAUR(h errs.Handler, pkgnames ...string) (aur.Packages, error)

ReadAUR reads the given package names from AUR. If no package names are given, ReadAUR reads all the names found in the repository.

If you don't need this special feature on zero packages, then please use aur.ReadAll instead!

func (*Repo) ReadAllNames

func (r *Repo) ReadAllNames(h errs.Handler) (pacman.Packages, error)

ReadAllNames returns all packages in the repository.

func (*Repo) ReadDatabase

func (r *Repo) ReadDatabase() (pacman.Packages, error)

ReadDatabase reads the database at r.Directory/r.Database. If the database does not exist, then an empty list is returned.

func (*Repo) ReadDir

func (r *Repo) ReadDir(h errs.Handler) (pacman.Packages, error)

func (*Repo) ReadMeta

func (r *Repo) ReadMeta(h errs.Handler, pkgnames ...string) (meta.Packages, error)

ReadMeta returns all meta packages in the repository that match the given names. If no names are given, all packages in repository are returned.

func (*Repo) ReadNames

func (r *Repo) ReadNames(h errs.Handler, pkgnames ...string) (pacman.Packages, error)

ReadNames returns all packages in the repository that match the given names. If no names are given, no packages are returned.

func (*Repo) Remove

func (r *Repo) Remove(h errs.Handler, pkgnames ...string) error

Remove removes the given names from the database and dispatches the files.

func (*Repo) RemoveFromDatabase

func (r *Repo) RemoveFromDatabase(pkgnames ...string) error

RemoveFromDatabase removes the given packages from the repository database.

func (*Repo) Setup

func (r *Repo) Setup() error

Setup creates the directory and returns an error if not possible.

func (*Repo) Update

func (r *Repo) Update(h errs.Handler, pkgnames ...string) error

Update adds the newest package found for the given name to the database and dispatches the obsolete packages. Any obsolete entries in the database are removed.

If pkgnames is empty, the entire repository is scanned.

TODO: What happens when there are multiple files, and you delete the most recent one. Which file is deleted?

type SignedPkg

type SignedPkg struct {
	PkgFile string
	SigFile string
}

SignedPkg represents the path components of a potentially signed package.

func NewSignedPkg

func NewSignedPkg(p string) (*SignedPkg, error)

NewSignedPkg returns a new SignedPkg, accompanied with an error if there is an error reading whether the signature file exists or not.

func (*SignedPkg) Apply

func (p *SignedPkg) Apply(f func(string, bool) error) error

Apply executes the function f for the package path, then the signature path. It returns the first error encountered.

func (*SignedPkg) HasSignature

func (p *SignedPkg) HasSignature() bool

HasSignature returns whether the package is accompanied by a signature file.

func (*SignedPkg) NameSet

func (p *SignedPkg) NameSet() string

NameSet returns the basename of the package file and the signature file.

func (*SignedPkg) PathSet

func (p *SignedPkg) PathSet() string

PathSet returns the path of the package file and the signature file.

type Upgrade

type Upgrade struct {
	Old *pacman.Package
	New *aur.Package
}

Upgrade represents an available AUR upgrade.

func (*Upgrade) Base

func (u *Upgrade) Base() string

func (*Upgrade) DownloadURL

func (u *Upgrade) DownloadURL() string

DownloadURL returns the download URL of the upgrade.

func (*Upgrade) Name

func (u *Upgrade) Name() string

Name returns the package name of the upgrade.

func (*Upgrade) String

func (u *Upgrade) String() string

String returns a representation of the available upgrade, in the form:

pkgname: oldver -> newver

func (*Upgrade) Versions

func (u *Upgrade) Versions() (from string, to string)

Versions returns the old and the new version of the packages.

type Upgrades

type Upgrades []*Upgrade

Upgrades is a list of Upgrade, which can be sorted using sort.Sort.

func (Upgrades) Len

func (u Upgrades) Len() int

func (Upgrades) Less

func (u Upgrades) Less(i, j int) bool

func (Upgrades) Swap

func (u Upgrades) Swap(i, j int)

Jump to

Keyboard shortcuts

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