aurfetch

package module
v0.0.0-...-2d96e71 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2019 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

aurfetch is a library for managing the downloading, updating and reviewing of packages downloaded from the AUR.

The general workflow is:

// Create handle
fetch := aurfetch.MakeHandle()
pkgs := []string{"foo", "bar"}

// Download pkgs
fetched, err := fetch.Download(pkgs)
// Filter to packages that need to be merged
toMerge, err := fetch.NeedsMerge(fetched)

// Insert review code with either fetch.PrintDiffs or fetch.DiffsToFile or fetch.MakeView

// Merge
err := fetch.Merge(toMerge)
// Mark everything as seen
err := fetch.MarkSeen(pkgs)

Index

Constants

View Source
const EMPTY_TREE string = "4b825dc642cb6eb9a060e54bf8d69288fbee4904"
View Source
const REF_NAME string = "AUR_SEEN"

/ The ref used for tracking what commits have been seen

Variables

This section is empty.

Functions

This section is empty.

Types

type DownloadCB

type DownloadCB func(pkg string, n int, out string, err error)

DownloadCB is the callback passed into the download function. pkg: The pkgbase of the package being downloaded n: The number of packages that have been downloaded out: the output from git clone/fetch

type Handle

type Handle struct {
	AURURL         string
	CacheDir       string
	PatchDir       string
	GitCommand     string
	GitArgs        []string
	GitCommandArgs []string
	GitEnvironment []string
}

func MakeHandle

func MakeHandle(cacheDir string, patchDir string) Handle

func (Handle) DiffsToFile

func (h Handle) DiffsToFile(pkgs []string, colour bool) error

DiffsToFile writes diffs of packages to DiffDir.

Each diff will be named <pkgbase>.diff

func (Handle) Download

func (h Handle) Download(pkgs []string) ([]string, *MultiError)

Download downloads a list of packages. git clone will be used for new downloads and git fetch for existing rpos

func (Handle) DownloadCB

func (h Handle) DownloadCB(pkgs []string, cb DownloadCB) []string

DownloadCB downloads a list of packages and calls cb after each download. git clone will be used for new downloads and git fetch for existing rpos

func (Handle) MakeView

func (h Handle) MakeView(pkgs []string, diffs []string) (string, error)

Creates a view of packages to be installed.

A view is intended for the user to inspect for security purposes. The view will include pkgbuilds of newly cloned packages and diffs of packages that have been updated. There is also a directory containing all the packages in the transaction.

The returning string is a path to the tempdir created to host this view. The directory should be deleted by the caller when the view is no longer needed.

Note the diffs should have already been created using DiffsToFile before calling.

func (Handle) MarkSeen

func (h Handle) MarkSeen(pkgs []string) error

MarkSeen marks a packages as seen.

If a package has been seen then it is assumed everything up to and including the current commit has been reviewed by the user. Therefore diffs will be between the repo at this point and upstream.

func (Handle) Merge

func (h Handle) Merge(pkgs []string) error

Merge merges a list of packages with upstream.

func (Handle) MergeCB

func (h Handle) MergeCB(pkgs []string, cb MergeCB) error

MergeCB merges a list of packages with upstram, calling cb after each successful merge.

func (Handle) NeedsMerge

func (h Handle) NeedsMerge(pkgs []string) ([]string, error)

NeedsMerge filters a list of packages to ones that need to be merged.

A package is considered to need merging if AUR_SEEN is equal or newer than upstream's HEAD If AUR_SEEN is not defined then HEAD is used instead.

func (Handle) PrintDiffs

func (h Handle) PrintDiffs(pkgs []string) error

PrintDiffs prints a list of diffs using git diff. This means git's pager and other config settings will be respected

func (Handle) URL

func (h Handle) URL(pkgbase string) string

URL gets the URL to the specified AUR git repo

type MergeCB

type MergeCB func(pkg string, n int, out string)

MergeCB is the callback passed into the merge function. pkg: The pkgbase of the package being merged n: The number of packages that have been merged

type MultiError

type MultiError struct {
	Errors []error
}

func (*MultiError) Add

func (err *MultiError) Add(e error)

func (*MultiError) Error

func (err *MultiError) Error() string

func (*MultiError) Return

func (err *MultiError) Return() *MultiError

Jump to

Keyboard shortcuts

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