package osutil
import "github.com/tredoe/osutil"
Package osutil defines operating systems and detects the Linux distribution. Also, it handles basic operations in the management of packages in FreeBSD, Linux and macOs operating systems.
Index ¶
- Variables
- func SetupLogger(log, logShell *log.Logger)
- func SystemFromGOOS() (sys System, dist Distro, err error)
- type Distro
- type Manager
- func NewPkgFromSystem(sys System, dis Distro) (Manager, error)
- func NewPkgFromType(pkg PackageType) Manager
- type ManagerBrew
- func (m ManagerBrew) Clean() error
- func (m ManagerBrew) ExecPath() string
- func (m ManagerBrew) Install(name ...string) error
- func (m ManagerBrew) Purge(name ...string) error
- func (m ManagerBrew) Remove(name ...string) error
- func (m ManagerBrew) Update() error
- func (m ManagerBrew) Upgrade() error
- type ManagerDeb
- func (m ManagerDeb) Clean() error
- func (m ManagerDeb) ExecPath() string
- func (m ManagerDeb) Install(name ...string) error
- func (m ManagerDeb) Purge(name ...string) error
- func (m ManagerDeb) Remove(name ...string) error
- func (m ManagerDeb) Update() error
- func (m ManagerDeb) Upgrade() error
- type ManagerDnf
- func (m ManagerDnf) Clean() error
- func (m ManagerDnf) ExecPath() string
- func (m ManagerDnf) Install(name ...string) error
- func (m ManagerDnf) Purge(name ...string) error
- func (m ManagerDnf) Remove(name ...string) error
- func (m ManagerDnf) Update() error
- func (m ManagerDnf) Upgrade() error
- type ManagerEbuild
- func (m ManagerEbuild) Clean() error
- func (m ManagerEbuild) ExecPath() string
- func (m ManagerEbuild) Install(name ...string) error
- func (m ManagerEbuild) Purge(name ...string) error
- func (m ManagerEbuild) Remove(name ...string) error
- func (m ManagerEbuild) Update() error
- func (m ManagerEbuild) Upgrade() error
- type ManagerPacman
- func (m ManagerPacman) Clean() error
- func (m ManagerPacman) ExecPath() string
- func (m ManagerPacman) Install(name ...string) error
- func (m ManagerPacman) Purge(name ...string) error
- func (m ManagerPacman) Remove(name ...string) error
- func (m ManagerPacman) Update() error
- func (m ManagerPacman) Upgrade() error
- type ManagerPkg
- func (m ManagerPkg) Clean() error
- func (m ManagerPkg) ExecPath() string
- func (m ManagerPkg) Install(name ...string) error
- func (m ManagerPkg) Purge(name ...string) error
- func (m ManagerPkg) Remove(name ...string) error
- func (m ManagerPkg) Update() error
- func (m ManagerPkg) Upgrade() error
- type ManagerRpm
- func (m ManagerRpm) Clean() error
- func (m ManagerRpm) ExecPath() string
- func (m ManagerRpm) Install(name ...string) error
- func (m ManagerRpm) Purge(name ...string) error
- func (m ManagerRpm) Remove(name ...string) error
- func (m ManagerRpm) Update() error
- func (m ManagerRpm) Upgrade() error
- type ManagerVoid
- func (m ManagerVoid) Clean() error
- func (m ManagerVoid) ExecPath() string
- func (m ManagerVoid) Install(name ...string) error
- func (m ManagerVoid) Purge(name ...string) error
- func (m ManagerVoid) Remove(name ...string) error
- func (m ManagerVoid) Update() error
- func (m ManagerVoid) Upgrade() error
- type ManagerYum
- func (m ManagerYum) Clean() error
- func (m ManagerYum) ExecPath() string
- func (m ManagerYum) Install(name ...string) error
- func (m ManagerYum) Purge(name ...string) error
- func (m ManagerYum) Remove(name ...string) error
- func (m ManagerYum) Update() error
- func (m ManagerYum) Upgrade() error
- type ManagerZypp
- func (m ManagerZypp) Clean() error
- func (m ManagerZypp) ExecPath() string
- func (m ManagerZypp) Install(name ...string) error
- func (m ManagerZypp) Purge(name ...string) error
- func (m ManagerZypp) Remove(name ...string) error
- func (m ManagerZypp) Update() error
- func (m ManagerZypp) Upgrade() error
- type PackageType
- func Detect() (PackageType, error)
- func (pkg PackageType) ExecPath() string
- func (pkg PackageType) String() string
- type System
Variables ¶
var ListSystem = [...]System{FreeBSD, Linux, MacOS, Windows}
ListSystem is the list of allowed operating systems.
Functions ¶
func SetupLogger ¶
SetupLogger setups the loggers used by some packages. 'log' is used by the packages 'edi', 'fileutil' and 'userutil'. 'logShell' is used by the packages 'executil' and 'pkg'.
func SystemFromGOOS ¶
SystemFromGOOS returns the system from 'GOOS', and the distribution at Linux systems.
Types ¶
type Distro ¶
type Distro int
Distro represents a distribution of Linux system.
Most used Linux distributions.
func DetectDistro ¶
DetectDistro returns the Linux distribution.
func (Distro) String ¶
type Manager ¶
type Manager interface { // ExecPath returns the executable path. ExecPath() string // Install installs packages. Install(name ...string) error // Remove removes packages. Remove(name ...string) error // Purge removes packages and its configuration files. Purge(name ...string) error // Update resynchronizes the package index files from their sources. Update() error // Upgrade upgrades all the packages on the system. Upgrade() error // Clean erases both packages downloaded and orphaned dependencies. Clean() error }
Manager is the common interface to handle different package systems.
func NewPkgFromSystem ¶
NewPkgFromSystem returns the package manager used by a system.
func NewPkgFromType ¶
func NewPkgFromType(pkg PackageType) Manager
NewPkgFromType returns the interface to handle the package manager.
type ManagerBrew ¶
type ManagerBrew struct{}
ManagerBrew is the interface to handle the macOS package manager.
func (ManagerBrew) Clean ¶
func (m ManagerBrew) Clean() error
func (ManagerBrew) ExecPath ¶
func (m ManagerBrew) ExecPath() string
func (ManagerBrew) Install ¶
func (m ManagerBrew) Install(name ...string) error
func (ManagerBrew) Purge ¶
func (m ManagerBrew) Purge(name ...string) error
func (ManagerBrew) Remove ¶
func (m ManagerBrew) Remove(name ...string) error
func (ManagerBrew) Update ¶
func (m ManagerBrew) Update() error
func (ManagerBrew) Upgrade ¶
func (m ManagerBrew) Upgrade() error
type ManagerDeb ¶
type ManagerDeb struct{}
ManagerDeb is the interface to handle the package manager of Linux systems based at Debian.
func (ManagerDeb) Clean ¶
func (m ManagerDeb) Clean() error
func (ManagerDeb) ExecPath ¶
func (m ManagerDeb) ExecPath() string
func (ManagerDeb) Install ¶
func (m ManagerDeb) Install(name ...string) error
func (ManagerDeb) Purge ¶
func (m ManagerDeb) Purge(name ...string) error
func (ManagerDeb) Remove ¶
func (m ManagerDeb) Remove(name ...string) error
func (ManagerDeb) Update ¶
func (m ManagerDeb) Update() error
func (ManagerDeb) Upgrade ¶
func (m ManagerDeb) Upgrade() error
type ManagerDnf ¶
type ManagerDnf struct{}
ManagerDnf is the interface to handle the package manager DNG of Linux systems based at Red Hat.
func (ManagerDnf) Clean ¶
func (m ManagerDnf) Clean() error
func (ManagerDnf) ExecPath ¶
func (m ManagerDnf) ExecPath() string
func (ManagerDnf) Install ¶
func (m ManagerDnf) Install(name ...string) error
func (ManagerDnf) Purge ¶
func (m ManagerDnf) Purge(name ...string) error
func (ManagerDnf) Remove ¶
func (m ManagerDnf) Remove(name ...string) error
func (ManagerDnf) Update ¶
func (m ManagerDnf) Update() error
func (ManagerDnf) Upgrade ¶
func (m ManagerDnf) Upgrade() error
type ManagerEbuild ¶
type ManagerEbuild struct{}
ManagerEbuild is the interface to handle the package manager of Linux systems based at Gentoo.
func (ManagerEbuild) Clean ¶
func (m ManagerEbuild) Clean() error
func (ManagerEbuild) ExecPath ¶
func (m ManagerEbuild) ExecPath() string
func (ManagerEbuild) Install ¶
func (m ManagerEbuild) Install(name ...string) error
func (ManagerEbuild) Purge ¶
func (m ManagerEbuild) Purge(name ...string) error
func (ManagerEbuild) Remove ¶
func (m ManagerEbuild) Remove(name ...string) error
func (ManagerEbuild) Update ¶
func (m ManagerEbuild) Update() error
func (ManagerEbuild) Upgrade ¶
func (m ManagerEbuild) Upgrade() error
type ManagerPacman ¶
type ManagerPacman struct{}
ManagerPacman is the interface to handle the package manager of Linux systems based at Arch.
func (ManagerPacman) Clean ¶
func (m ManagerPacman) Clean() error
func (ManagerPacman) ExecPath ¶
func (m ManagerPacman) ExecPath() string
func (ManagerPacman) Install ¶
func (m ManagerPacman) Install(name ...string) error
func (ManagerPacman) Purge ¶
func (m ManagerPacman) Purge(name ...string) error
func (ManagerPacman) Remove ¶
func (m ManagerPacman) Remove(name ...string) error
func (ManagerPacman) Update ¶
func (m ManagerPacman) Update() error
func (ManagerPacman) Upgrade ¶
func (m ManagerPacman) Upgrade() error
type ManagerPkg ¶
type ManagerPkg struct{}
ManagerPkg is the interface to handle the FreeBSD package manager, called 'package' or 'pkg'.
func (ManagerPkg) Clean ¶
func (m ManagerPkg) Clean() error
func (ManagerPkg) ExecPath ¶
func (m ManagerPkg) ExecPath() string
func (ManagerPkg) Install ¶
func (m ManagerPkg) Install(name ...string) error
func (ManagerPkg) Purge ¶
func (m ManagerPkg) Purge(name ...string) error
func (ManagerPkg) Remove ¶
func (m ManagerPkg) Remove(name ...string) error
func (ManagerPkg) Update ¶
func (m ManagerPkg) Update() error
func (ManagerPkg) Upgrade ¶
func (m ManagerPkg) Upgrade() error
type ManagerRpm ¶
type ManagerRpm struct{}
ManagerRpm is the interface to handle the package manager RPM of Linux systems based at Red Hat.
func (ManagerRpm) Clean ¶
func (m ManagerRpm) Clean() error
func (ManagerRpm) ExecPath ¶
func (m ManagerRpm) ExecPath() string
func (ManagerRpm) Install ¶
func (m ManagerRpm) Install(name ...string) error
func (ManagerRpm) Purge ¶
func (m ManagerRpm) Purge(name ...string) error
func (ManagerRpm) Remove ¶
func (m ManagerRpm) Remove(name ...string) error
func (ManagerRpm) Update ¶
func (m ManagerRpm) Update() error
func (ManagerRpm) Upgrade ¶
func (m ManagerRpm) Upgrade() error
type ManagerVoid ¶
type ManagerVoid struct{}
ManagerVoid is the interface to pass a Manager with an error, avoiding to have to use a pointer.
func (ManagerVoid) Clean ¶
func (m ManagerVoid) Clean() error
func (ManagerVoid) ExecPath ¶
func (m ManagerVoid) ExecPath() string
func (ManagerVoid) Install ¶
func (m ManagerVoid) Install(name ...string) error
func (ManagerVoid) Purge ¶
func (m ManagerVoid) Purge(name ...string) error
func (ManagerVoid) Remove ¶
func (m ManagerVoid) Remove(name ...string) error
func (ManagerVoid) Update ¶
func (m ManagerVoid) Update() error
func (ManagerVoid) Upgrade ¶
func (m ManagerVoid) Upgrade() error
type ManagerYum ¶
type ManagerYum struct{}
ManagerYum is the interface to handle the package manager YUM of Linux systems based at Red Hat.
func (ManagerYum) Clean ¶
func (m ManagerYum) Clean() error
func (ManagerYum) ExecPath ¶
func (m ManagerYum) ExecPath() string
func (ManagerYum) Install ¶
func (m ManagerYum) Install(name ...string) error
func (ManagerYum) Purge ¶
func (m ManagerYum) Purge(name ...string) error
func (ManagerYum) Remove ¶
func (m ManagerYum) Remove(name ...string) error
func (ManagerYum) Update ¶
func (m ManagerYum) Update() error
func (ManagerYum) Upgrade ¶
func (m ManagerYum) Upgrade() error
type ManagerZypp ¶
type ManagerZypp struct{}
ManagerZypp is the interface to handle the package manager of Linux systems based at SUSE.
func (ManagerZypp) Clean ¶
func (m ManagerZypp) Clean() error
func (ManagerZypp) ExecPath ¶
func (m ManagerZypp) ExecPath() string
func (ManagerZypp) Install ¶
func (m ManagerZypp) Install(name ...string) error
func (ManagerZypp) Purge ¶
func (m ManagerZypp) Purge(name ...string) error
func (ManagerZypp) Remove ¶
func (m ManagerZypp) Remove(name ...string) error
func (ManagerZypp) Update ¶
func (m ManagerZypp) Update() error
func (ManagerZypp) Upgrade ¶
func (m ManagerZypp) Upgrade() error
type PackageType ¶
type PackageType int8
PackageType represents a package management system.
const ( // Linux Deb PackageType = iota + 1 Dnf Ebuild Pacman Rpm Yum Zypp // BSD Brew Pkg )
func Detect ¶
func Detect() (PackageType, error)
Detect tries to get the package system used in the system, looking for executables in directories "/usr/bin" and "/usr/local/bin".
func (PackageType) ExecPath ¶
func (pkg PackageType) ExecPath() string
ExecPath returns the executable path.
func (PackageType) String ¶
func (pkg PackageType) String() string
type System ¶
type System uint8
System represents an operating system.
The operating systems.
func (System) String ¶
Source Files ¶
distro.go doc.go log.go pkg.go pkg_arch.go pkg_centos.go pkg_debian.go pkg_freebsd_.go pkg_gentoo.go pkg_macos_.go pkg_suse.go pkg_void.go system.go
Directories ¶
Path | Synopsis |
---|---|
config | |
config/shconf | Package shconf implements a parser and scanner for the configuration in format shell-variable. |
edi | Package edi allows edit files. |
executil | Package executil lets to call to system commands. |
fileutil | Package fileutil handles common operations in files. |
internal | |
userutil | Package userutil provides access to UNIX users database in local files. |
userutil/crypt | Package crypt provides interface for password crypt functions and collects common constants. |
userutil/crypt/apr1_crypt | Package apr1_crypt implements the standard Unix MD5-crypt algorithm created by Poul-Henning Kamp for FreeBSD, and modified by the Apache project. |
userutil/crypt/common | Package common contains routines used by multiple password hashing algorithms. |
userutil/crypt/md5_crypt | Package md5_crypt implements the standard Unix MD5-crypt algorithm created by Poul-Henning Kamp for FreeBSD. |
userutil/crypt/sha256_crypt | Package sha256_crypt implements Ulrich Drepper's SHA256-crypt password hashing algorithm. |
userutil/crypt/sha512_crypt | Package sha512_crypt implements Ulrich Drepper's SHA512-crypt password hashing algorithm. |
- Version
- v1.1.8
- Published
- Aug 4, 2021
- Platform
- js/wasm
- Imports
- 10 packages
- Last checked
- now –
Tools for package owners.