scoop

package
v0.0.9 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	DetailFieldBin           = "bin"
	DetailFieldShortcuts     = "shortcuts"
	DetailFieldUrl           = "url"
	DetailFieldHash          = "hash"
	DetailFieldArchitecture  = "architecture"
	DetailFieldDescription   = "description"
	DetailFieldVersion       = "version"
	DetailFieldNotes         = "notes"
	DetailFieldDepends       = "depends"
	DetailFieldEnvSet        = "env_set"
	DetailFieldEnvAddPath    = "env_add_path"
	DetailFieldPersist       = "persist"
	DetailFieldExtractDir    = "extract_dir"
	DetailFieldExtractTo     = "extract_to"
	DetailFieldPostInstall   = "post_install"
	DetailFieldPreInstall    = "pre_install"
	DetailFieldPreUninstall  = "pre_uninstall"
	DetailFieldPostUninstall = "post_uninstall"
	DetailFieldInstaller     = "installer"
	DetailFieldUninstaller   = "uninstaller"
	DetailFieldInnoSetup     = "innosetup"
)

Variables

View Source
var (
	ErrAlreadyInstalled         = errors.New("app already installed (same version)")
	ErrAppNotFound              = errors.New("app not found")
	ErrAppNotAvailableInVersion = errors.New("app not available in desird version")
)

DetailFieldsAll is a list of all available DetailFields to load during App.LoadDetails. Use these if you need all fields or don't care whether unneeded fields are being loaded.

View Source
var ErrBucketNoGitDir = errors.New(".git dir at path not found")
View Source
var ErrBucketNotFound = errors.New("bucket not found")

Functions

func CachePath

func CachePath(app, version, url string) string

CachePath generates a path given the app, a version and the target URL. The rules defined here are taken from the scoop code.

func GetDefaultScoopDir added in v0.0.3

func GetDefaultScoopDir() (string, error)

func ParseAppIdentifier added in v0.0.3

func ParseAppIdentifier(name string) (string, string, string)

ParseAppIdentifier returns all fragments of an app. The fragments are (in order) (bucket, name, version). Not that `bucket` and `version` can be empty.

Types

type App

type App struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Version     string `json:"version"`
	Notes       string `json:"notes"`

	Bin        []Bin        `json:"bin"`
	Shortcuts  []Shortcut   `json:"shortcuts"`
	EnvAddPath []string     `json:"env_add_path"`
	EnvSet     []EnvVar     `json:"env_set"`
	Persist    []PersistDir `json:"persist"`

	Downloadables []Downloadable `json:"downloadables"`

	Depends      []Dependency                      `json:"depends"`
	Architecture map[ArchitectureKey]*Architecture `json:"architecture"`
	InnoSetup    bool                              `json:"innosetup"`
	// Installer deprecates msi
	Installer     *Installer   `json:"installer"`
	Uninstaller   *Uninstaller `json:"uninstaller"`
	PreInstall    []string     `json:"pre_install"`
	PostInstall   []string     `json:"post_install"`
	PreUninstall  []string     `json:"pre_uninstall"`
	PostUninstall []string     `json:"post_uninstall"`
	ExtractTo     []string     `json:"extract_to"`

	Bucket *Bucket `json:"-"`
	// contains filtered or unexported fields
}

App represents an application, which may or may not be installed and may or may not be part of a bucket. "Headless" manifests are also a thing, for example when you are using an auto-generated manifest for a version that's not available anymore. In that case, scoop will lose the bucket information.

Note that this structure doesn't reflect the same schema as the scoop manifests, as we are trying to make usage easier, not just as hard.

func (*App) AvailableVersions added in v0.0.3

func (a *App) AvailableVersions() ([]string, error)

func (*App) AvailableVersionsN added in v0.0.4

func (a *App) AvailableVersionsN(maxVersions int) ([]string, error)

func (*App) ForArch added in v0.0.4

func (a *App) ForArch(arch ArchitectureKey) *AppResolved

ForArch will create a merged version that includes all the relevant fields at root level. Access to architecture shouldn't be required anymore, it should be ready to use for installtion, update or uninstall.

func (*App) LoadDetails

func (a *App) LoadDetails(fields ...string) error

LoadDetails will load additional data regarding the manifest, such as description and version information. This causes IO on your drive and therefore isn't done by default.

func (*App) LoadDetailsWithIter added in v0.0.3

func (a *App) LoadDetailsWithIter(iter *jsoniter.Iterator, fields ...string) error

LoadDetails will load additional data regarding the manifest, such as description and version information. This causes IO on your drive and therefore isn't done by default.

func (*App) ManifestForVersion added in v0.0.3

func (a *App) ManifestForVersion(targetVersion string) (io.ReadSeeker, error)

ManifestForVersion will search through history til a version equal to the desired version is found. Note that we compare the versions and stop searching if a lower version is encountered. This function is expected to be very slow, be warned!

func (*App) ManifestPath

func (a *App) ManifestPath() string

type AppResolved added in v0.0.4

type AppResolved struct {
	*App

	Bin       []Bin      `json:"bin"`
	Shortcuts []Shortcut `json:"shortcuts"`

	Downloadables []Downloadable `json:"downloadables"`

	// Installer deprecates msi; InnoSetup bool should be same for each
	// architecture. The docs don't mention it.
	Installer   *Installer `json:"installer"`
	PreInstall  []string   `json:"pre_install"`
	PostInstall []string   `json:"post_install"`
}

AppResolved is a version of app forming the data into a way that it's ready for installation, deinstallation or update.

func (*AppResolved) Download added in v0.0.4

func (resolvedApp *AppResolved) Download(
	cacheDir string,
	arch ArchitectureKey,
	verifyHashes, overwriteCache bool,
) (chan any, error)

Download will download all files for the desired architecture, skipping already cached files. The cache lookups happen before downloading and are synchronous, directly returning an error instead of using the error channel. As soon as download starts (chan, chan, nil) is returned. Both channels are closed upon completion (success / failure). FIXME Make single result chan with a types: (download_start, download_finished, cache_hit)

type Architecture added in v0.0.3

type Architecture struct {
	Downloadables []Downloadable `json:"items"`

	Bin       []Bin
	Shortcuts []Shortcut

	// Installer replaces MSI
	Installer   *Installer
	Uninstaller *Uninstaller

	// PreInstall contains a list of commands to execute before installation.
	// Note that PreUninstall isn't supported in ArchitectureItem, even though
	// Uninstaller is supported.
	PreInstall []string
	// PreInstall contains a list of commands to execute after installation.
	// Note that PostUninstall isn't supported in ArchitectureItem, even though
	// Uninstaller is supported.
	PostInstall []string
}

type ArchitectureKey added in v0.0.3

type ArchitectureKey string
const (
	// Architecture32Bit is for x386 (intel/amd). It is the default if no arch
	// has been specified.
	ArchitectureKey32Bit ArchitectureKey = "32bit"
	// Architecture32Bit is for x686 (intel/amd)
	ArchitectureKey64Bit ArchitectureKey = "64bit"
	ArchitectureKeyARM64 ArchitectureKey = "arm64"
)

type Bin added in v0.0.3

type Bin struct {
	Name  string
	Alias string
	Args  []string
}

type Bucket

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

func (*Bucket) AvailableApps

func (b *Bucket) AvailableApps() ([]*App, error)

AvailableApps returns unloaded app manifests. You need to call App.LoadDetails on each one. This allows for optimisation by parallelisation where desired.

func (*Bucket) Dir

func (b *Bucket) Dir() string

Dir is the bucket directory, which contains the subdirectory "bucket" with the manifests.

func (*Bucket) FindApp added in v0.0.4

func (b *Bucket) FindApp(name string) *App

func (*Bucket) ManifestDir

func (b *Bucket) ManifestDir() string

ManifestDir is the directory path of the bucket without a leading slash.

func (*Bucket) Name

func (b *Bucket) Name() string

Bucket is the directory name of the bucket and therefore name of the bucket.

func (*Bucket) Remove

func (b *Bucket) Remove() error

Remove removes the bucket, but doesn't unisntall any of its installed applications.

type CacheHit added in v0.0.4

type CacheHit struct {
	Downloadable *Downloadable
}

type ChecksumMismatchError added in v0.0.4

type ChecksumMismatchError struct {
	Expected string
	Actual   string
	File     string
}

func (*ChecksumMismatchError) Error added in v0.0.4

func (err *ChecksumMismatchError) Error() string

type Dependencies added in v0.0.3

type Dependencies struct {
	App    *App
	Values []*Dependencies
}

type Dependency added in v0.0.3

type Dependency struct {
	Bucket string
	Name   string
}

type Downloadable added in v0.0.4

type Downloadable struct {
	URL  string
	Hash string
	// ExtractDir specifies which dir should be extracted from the downloaded
	// archive. However, there might be more URLs than there are ExtractDirs.
	ExtractDir string
	ExtractTo  string
}

type EnvVar added in v0.0.3

type EnvVar struct {
	Key, Value string
}

type FinishedDownload added in v0.0.4

type FinishedDownload struct {
	Downloadable *Downloadable
}

type InstalledApp added in v0.0.3

type InstalledApp struct {
	*App
	// Hold indicates whether the app should be kept on the currently installed
	// version. It's versioning pinning.
	Hold bool
	// Archictecture defines which architecture was used for installation. On a
	// 64Bit system for example, this could also be 32Bit, but not vice versa.
	Architecture ArchitectureKey
}

type Installer added in v0.0.3

type Installer struct {
	// File is the installer executable. If not specified, this will
	// automatically be set to the last item of the URLs. Note, that this will
	// be looked up in the extracted dirs, if explicitly specified.
	File   string
	Script []string
	Args   []string
	Keep   bool
}

type KnownBucket added in v0.0.4

type KnownBucket struct {
	Name string
	URL  string
}

type OutdatedApp added in v0.0.3

type OutdatedApp struct {
	*InstalledApp

	ManifestDeleted bool
	LatestVersion   string
}

type PersistDir added in v0.0.7

type PersistDir struct {
	Dir string
	// LinkName is optional and can be used to rename the [Dir].
	LinkName string
}

PersistDir represents a directory in the installation of the application, which the app or the user will write to. This is placed in a separate location and kept upon uninstallation.

type Scoop added in v0.0.3

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

func NewCustomScoop added in v0.0.3

func NewCustomScoop(scoopRoot string) *Scoop

func NewScoop added in v0.0.3

func NewScoop() (*Scoop, error)

func (*Scoop) AppDir added in v0.0.4

func (scoop *Scoop) AppDir() string

func (*Scoop) BucketDir added in v0.0.4

func (scoop *Scoop) BucketDir() string

func (*Scoop) CacheDir added in v0.0.4

func (scoop *Scoop) CacheDir() string

func (*Scoop) CreateShim added in v0.0.4

func (scoop *Scoop) CreateShim(path string, bin Bin) error

func (*Scoop) DependencyTree added in v0.0.3

func (scoop *Scoop) DependencyTree(a *App) (*Dependencies, error)

func (*Scoop) FindAvailableApp added in v0.0.4

func (scoop *Scoop) FindAvailableApp(name string) (*App, error)

func (*Scoop) FindInstalledApp added in v0.0.4

func (scoop *Scoop) FindInstalledApp(name string) (*InstalledApp, error)

func (*Scoop) GetBucket added in v0.0.3

func (scoop *Scoop) GetBucket(name string) *Bucket

GetBucket constructs a new bucket object pointing at the given bucket. At this point, the bucket might not necessarily exist.

func (*Scoop) GetKnownBuckets added in v0.0.3

func (scoop *Scoop) GetKnownBuckets() ([]KnownBucket, error)

GetKnownBuckets returns the list of available "default" buckets that are available, but might have not necessarily been installed locally.

func (*Scoop) GetLocalBuckets added in v0.0.3

func (scoop *Scoop) GetLocalBuckets() ([]*Bucket, error)

GetLocalBuckets is an API representation of locally installed buckets.

func (*Scoop) GetOutdatedApps added in v0.0.3

func (scoop *Scoop) GetOutdatedApps() ([]*OutdatedApp, error)

func (*Scoop) Install added in v0.0.3

func (scoop *Scoop) Install(appName string, arch ArchitectureKey) error

func (*Scoop) InstallAll added in v0.0.4

func (scoop *Scoop) InstallAll(appNames []string, arch ArchitectureKey) []error

InstallAll will install the given application into userspace. If an app is already installed, it will be updated if applicable.

One key difference to scoop however, is how installing a concrete version works. Instead of creating a dirty manifest, we will search for the old manifest, install it and hold the app. This will have the same effect for the user, but without the fact that the user will never again get update notifications.

func (*Scoop) InstalledApps added in v0.0.4

func (scoop *Scoop) InstalledApps() ([]*InstalledApp, error)

func (*Scoop) LookupCache added in v0.0.3

func (scoop *Scoop) LookupCache(app, version string) ([]string, error)

LookupCache will check the cache dir for matching entries. Note that the `app` parameter must be non-empty, but the version is optional.

func (*Scoop) PersistDir added in v0.0.4

func (scoop *Scoop) PersistDir() string

func (*Scoop) RemoveShims added in v0.0.4

func (scoop *Scoop) RemoveShims(bins ...Bin) error

func (*Scoop) ReverseDependencyTree added in v0.0.3

func (scoop *Scoop) ReverseDependencyTree(apps []*App, app *App) *Dependencies

func (*Scoop) ScoopInstallationDir added in v0.0.4

func (scoop *Scoop) ScoopInstallationDir() string

func (*Scoop) ShimDir added in v0.0.4

func (scoop *Scoop) ShimDir() string

func (Scoop) ShortcutDir added in v0.0.7

func (scoop Scoop) ShortcutDir() (string, error)

func (*Scoop) Uninstall added in v0.0.4

func (scoop *Scoop) Uninstall(app *InstalledApp, arch ArchitectureKey) error

type Shortcut added in v0.0.7

type Shortcut struct {
	Name         string
	ShortcutName string
	Args         string
	Icon         string
}

type StartedDownload added in v0.0.4

type StartedDownload struct {
	Downloadable *Downloadable
}

type Uninstaller added in v0.0.4

type Uninstaller Installer

Jump to

Keyboard shortcuts

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