package distro

import "github.com/purpleidea/mgmt/util/distro"

Package distro is for utilities that deal with os/distro things. Best to keep these all in one place so that adding this data happens all in the same file.

Index

Constants

const (
	// FamilyRedHat represents distros like Fedora and RHEL.
	FamilyRedHat = "redhat"

	// FamilyDebian represents distros like Debian and Ubuntu.
	FamilyDebian = "debian"

	// FamilyArchLinux represents primarily ArchLinux.
	FamilyArchLinux = "archlinux"

	// DistroDebian is the Debian distro.
	DistroDebian = "debian"

	// DistroFedora is the Fedora distro.
	DistroFedora = "fedora"
)

Variables

var (
	// MapDistroToBootstrapPackages is a map of distro to packages needed to
	// run our software.
	MapDistroToBootstrapPackages = map[string][]string{

		DistroDebian: {
			"libaugeas-dev",
			"libvirt-dev",
			"packagekit-tools",
		},
		DistroFedora: {
			"augeas-devel",
			"libvirt-devel",
			"PackageKit",
		},
	}

	// MapDistroToGuestfsPackages is a map of distro to packages needed to
	// run the virt-builder software and guestfs suite.
	MapDistroToGuestfsPackages = map[string][]string{

		DistroDebian: {
			"guestfs-tools",
		},
		DistroFedora: {
			"guestfs-tools",
		},
	}
)

Functions

func Distro

func Distro(ctx context.Context) (string, error)

Distro returns the distro name.

func Family

func Family(ctx context.Context) (string, error)

Family returns the distro family.

func IsDistroArchLinux

func IsDistroArchLinux(ctx context.Context) (bool, error)

IsDistroArchLinux detects if the os distro is archlinux.

func IsDistroDebian

func IsDistroDebian(ctx context.Context) (bool, error)

IsDistroDebian detects if the os distro is debian. (Not ubuntu!)

func IsDistroFedora

func IsDistroFedora(ctx context.Context) (bool, error)

IsDistroFedora detects if the os distro is fedora.

func IsFamilyArchLinux

func IsFamilyArchLinux(ctx context.Context) (bool, error)

IsFamilyArchLinux detects if the os family is archlinux.

func IsFamilyDebian

func IsFamilyDebian(ctx context.Context) (bool, error)

IsFamilyDebian detects if the os family is debian.

func IsFamilyRedHat

func IsFamilyRedHat(ctx context.Context) (bool, error)

IsFamilyRedHat detects if the os family is redhat.

func ToBootstrapPackages

func ToBootstrapPackages(distro string) ([]string, bool)

ToBootstrapPackages returns the list of packages corresponding to the distro for bootstrapping. This returns false if the value doesn't exist.

func ToGuestfsPackages

func ToGuestfsPackages(distro string) ([]string, bool)

ToGuestfsPackages returns the list of packages corresponding to the distro for running the virt-builder software and guestfs suite. This returns false if the value doesn't exist.

Source Files

distro.go

Version
v0.0.0-20250322185616-c50a578426f1 (latest)
Published
Mar 22, 2025
Platform
linux/amd64
Imports
3 packages
Last checked
4 days ago

Tools for package owners.