apt

package module
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 11 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 CheckForUpdates

func CheckForUpdates() (output []byte, err error)

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

func DistUpgrade

func DistUpgrade() (output []byte, err error)

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

func Download added in v0.2.0

func Download(pack *Package, targetPath string) (output []byte, err error)

Download triest to downlaod a set of packages targetPath should be absolute.

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 GetDependencies added in v0.2.0

func GetDependencies(pack *Package) (list []string, err error)

Get a list of dependencies, from the bottom up.

func Install

func Install(targetPath string, packs ...*Package) (output []byte, err error)

Install installs a set of packages

func InstallDry added in v0.1.1

func InstallDry(packs ...*Package) (output []byte, err error)

Install tries to install a set of packages

func Remove

func Remove(packs ...*Package) (output []byte, err error)

Remove removes a set of packages

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)

func Upgrade

func Upgrade(packs ...*Package) (output []byte, err error)

Upgrade runs the upgrade for a set of packages

func UpgradeAll

func UpgradeAll() (output []byte, err error)

UpgradeAll upgrade all upgradable packages

Types

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

func List

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

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

func ListUpgradable

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

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

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

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

type Repository

type Repository struct {
	Enabled      bool
	SourceRepo   bool
	Options      string
	URI          string
	Distribution string
	Components   string
	Comment      string
	ConfigFile   string
}

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