apt

package module
v0.0.0-...-64d2364 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

README

Golang apt client

This is a golang client library for Debian APT Package Manager (dpkg and apt).

License

Copyright (C) 2017 Arduino AG (http://www.arduino.cc/)

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddRepository

func AddRepository(repo *Repository, configFolderPath string) error

AddRepository adds the specified repository by changing the specified APT config folder (usually /etc/apt). The new repository is saved into a file named "managed.list"

func EditRepository

func EditRepository(old *Repository, new *Repository, configFolderPath string) error

EditRepository replace an old repo configuration with a new repo configuration in the specified APT config folder (usually /etc/apt).

func RemoveRepository

func RemoveRepository(repo *Repository, configFolderPath string) error

RemoveRepository removes a repository from the repository list files found in the specified APT config folder (usually /etc/apt)

Types

type AptManager

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

AptManager creates an apt manager

func NewAptManager

func NewAptManager() *AptManager

NewAptManager returns a new apt manager

func (*AptManager) CheckForUpdates

func (am *AptManager) CheckForUpdates() error

CheckForUpdates runs an apt update to retrieve new packages available from the repositories

func (*AptManager) DistUpgrade

func (am *AptManager) DistUpgrade() (err error)

DistUpgrade upgrades all upgradable packages, it may remove older versions to install newer ones.

func (*AptManager) Install

func (am *AptManager) Install(packs ...*Package) error

Install installs a set of packages

func (*AptManager) List

func (am *AptManager) List() ([]*Package, error)

List returns a list of packages available in the system with their respective status.

func (*AptManager) ListUpgradable

func (am *AptManager) ListUpgradable() ([]*Package, error)

ListUpgradable return all the upgradable packages and the version that is going to be installed if an UpgradeAll is performed

func (*AptManager) Remove

func (am *AptManager) Remove(packs ...*Package) error

Remove removes a set of packages

func (*AptManager) Search

func (am *AptManager) Search(pattern string) ([]*Package, error)

Search list packages available in the system that match the search pattern

func (*AptManager) SetStderr

func (am *AptManager) SetStderr(w io.Writer)

SetStderr sets stderr writer

func (*AptManager) SetStdout

func (am *AptManager) SetStdout(w io.Writer)

SetStdout sets stdout writer

func (*AptManager) Upgrade

func (am *AptManager) Upgrade(packs ...*Package) (err error)

Upgrade runs the upgrade for a set of packages

func (*AptManager) UpgradeAll

func (am *AptManager) UpgradeAll() (err error)

UpgradeAll upgrade all upgradable packages

type Package

type Package struct {
	Name             string
	Status           string
	Architecture     string
	Version          string
	ShortDescription string
	InstalledSizeKB  int
}

Package is a package available in the APT system

type Repository

type Repository struct {
	Enabled      bool
	SourceRepo   bool
	Options      string
	URI          string
	Distribution string
	Components   string
	Comment      string
	// contains filtered or unexported fields
}

Repository contains metadata about a repository installed in the system

func (*Repository) APTConfigLine

func (r *Repository) APTConfigLine() string

APTConfigLine returns the "deb" or "deb-src" config line to put in source.list to install the Repository

func (*Repository) Equals

func (r *Repository) Equals(repo *Repository) bool

Equals check if the Repository metadata are equivalent to the one provided as parameter. Two Repository are equivalent if all metadata matches with the exception of Enabled and Comment.

type RepositoryList

type RepositoryList []*Repository

RepositoryList is an array of Repository definitions

func ParseAPTConfigFolder

func ParseAPTConfigFolder(folderPath string) (RepositoryList, error)

ParseAPTConfigFolder scans an APT config folder (usually /etc/apt) to get information about all configured repositories, it scans also "source.list.d" subfolder to find all the "*.list" files.

func (RepositoryList) Contains

func (r RepositoryList) Contains(repo *Repository) bool

Contains checks if a repository definition is contained in the RepositoryList

func (RepositoryList) Find

func (r RepositoryList) Find(repoToFind *Repository) *Repository

Find search in the RepositoryList a repo that has the same metadata as the one passed as parameter

Jump to

Keyboard shortcuts

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