distros

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var GentooGlobalUseFlags = []string{
	"dbus",
	"udev",
	"alsa",
	"policykit",
	"jpeg",
	"png",
	"webp",
	"gif",
	"tiff",
	"svg",
	"brotli",
	"gdbm",
	"accessibility",
	"gtk",
	"qt6",
	"egl",
	"gbm",
}
View Source
var Registry = make(map[string]DistroConfig)

Registry holds all supported distributions

Functions

func ExecSudoCommand added in v0.5.0

func ExecSudoCommand(ctx context.Context, sudoPassword string, command string) *exec.Cmd

ExecSudoCommand creates an exec.Cmd that runs a command with sudo using the provided password. The password is properly escaped to prevent shell injection and syntax errors.

func GetSupportedDistros

func GetSupportedDistros() []string

GetSupportedDistros returns a list of all supported distribution IDs

func IsDistroSupported

func IsDistroSupported(id string) bool

IsDistroSupported checks if a distribution ID is supported

func IsUnsupportedDistro

func IsUnsupportedDistro(distroID, versionID string) bool

IsUnsupportedDistro checks if a distribution/version combination is supported

func MakeSudoCommand added in v0.5.0

func MakeSudoCommand(sudoPassword string, command string) string

MakeSudoCommand creates a command string that safely passes password to sudo. This helper escapes special characters in the password to prevent shell injection and syntax errors when passwords contain single quotes, apostrophes, or other special chars.

func NewDependencyDetector

func NewDependencyDetector(distribution string, logChan chan<- string) (deps.DependencyDetector, error)

NewDependencyDetector creates a DependencyDetector for the specified distribution

func Register

func Register(id, colorHex string, family DistroFamily, constructor func(config DistroConfig, logChan chan<- string) Distribution)

Register adds a distribution to the registry

Types

type ArchDistribution

type ArchDistribution struct {
	*BaseDistribution
	*ManualPackageInstaller
	// contains filtered or unexported fields
}

func NewArchDistribution

func NewArchDistribution(config DistroConfig, logChan chan<- string) *ArchDistribution

func (*ArchDistribution) DetectDependencies

func (a *ArchDistribution) DetectDependencies(ctx context.Context, wm deps.WindowManager) ([]deps.Dependency, error)

func (*ArchDistribution) DetectDependenciesWithTerminal

func (a *ArchDistribution) DetectDependenciesWithTerminal(ctx context.Context, wm deps.WindowManager, terminal deps.Terminal) ([]deps.Dependency, error)

func (*ArchDistribution) GetColorHex

func (a *ArchDistribution) GetColorHex() string

func (*ArchDistribution) GetFamily

func (a *ArchDistribution) GetFamily() DistroFamily

func (*ArchDistribution) GetID

func (a *ArchDistribution) GetID() string

func (*ArchDistribution) GetPackageManager

func (a *ArchDistribution) GetPackageManager() PackageManagerType

func (*ArchDistribution) GetPackageMapping

func (a *ArchDistribution) GetPackageMapping(wm deps.WindowManager) map[string]PackageMapping

func (*ArchDistribution) GetPackageMappingWithVariants

func (a *ArchDistribution) GetPackageMappingWithVariants(wm deps.WindowManager, variants map[string]deps.PackageVariant) map[string]PackageMapping

func (*ArchDistribution) InstallPackages

func (a *ArchDistribution) InstallPackages(ctx context.Context, dependencies []deps.Dependency, wm deps.WindowManager, sudoPassword string, reinstallFlags map[string]bool, disabledFlags map[string]bool, skipGlobalUseFlags bool, progressChan chan<- InstallProgressMsg) error

func (*ArchDistribution) InstallPrerequisites

func (a *ArchDistribution) InstallPrerequisites(ctx context.Context, sudoPassword string, progressChan chan<- InstallProgressMsg) error

type BaseDistribution

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

BaseDistribution provides common functionality for all distributions

func NewBaseDistribution

func NewBaseDistribution(logChan chan<- string) *BaseDistribution

NewBaseDistribution creates a new base distribution

func (*BaseDistribution) CommandExists

func (b *BaseDistribution) CommandExists(cmd string) bool

type DebianDistribution

type DebianDistribution struct {
	*BaseDistribution
	*ManualPackageInstaller
	// contains filtered or unexported fields
}

func NewDebianDistribution

func NewDebianDistribution(config DistroConfig, logChan chan<- string) *DebianDistribution

func (*DebianDistribution) DetectDependencies

func (d *DebianDistribution) DetectDependencies(ctx context.Context, wm deps.WindowManager) ([]deps.Dependency, error)

func (*DebianDistribution) DetectDependenciesWithTerminal

func (d *DebianDistribution) DetectDependenciesWithTerminal(ctx context.Context, wm deps.WindowManager, terminal deps.Terminal) ([]deps.Dependency, error)

func (*DebianDistribution) GetColorHex

func (d *DebianDistribution) GetColorHex() string

func (*DebianDistribution) GetFamily

func (d *DebianDistribution) GetFamily() DistroFamily

func (*DebianDistribution) GetID

func (d *DebianDistribution) GetID() string

func (*DebianDistribution) GetPackageManager

func (d *DebianDistribution) GetPackageManager() PackageManagerType

func (*DebianDistribution) GetPackageMapping

func (d *DebianDistribution) GetPackageMapping(wm deps.WindowManager) map[string]PackageMapping

func (*DebianDistribution) InstallManualPackages

func (d *DebianDistribution) InstallManualPackages(ctx context.Context, packages []string, sudoPassword string, progressChan chan<- InstallProgressMsg) error

func (*DebianDistribution) InstallPackages

func (d *DebianDistribution) InstallPackages(ctx context.Context, dependencies []deps.Dependency, wm deps.WindowManager, sudoPassword string, reinstallFlags map[string]bool, disabledFlags map[string]bool, skipGlobalUseFlags bool, progressChan chan<- InstallProgressMsg) error

func (*DebianDistribution) InstallPrerequisites

func (d *DebianDistribution) InstallPrerequisites(ctx context.Context, sudoPassword string, progressChan chan<- InstallProgressMsg) error

type Distribution

type Distribution interface {
	// Metadata
	GetID() string
	GetColorHex() string
	GetFamily() DistroFamily
	GetPackageManager() PackageManagerType

	// Dependency Detection
	DetectDependencies(ctx context.Context, wm deps.WindowManager) ([]deps.Dependency, error)
	DetectDependenciesWithTerminal(ctx context.Context, wm deps.WindowManager, terminal deps.Terminal) ([]deps.Dependency, error)

	// Package Installation
	InstallPackages(ctx context.Context, dependencies []deps.Dependency, wm deps.WindowManager, sudoPassword string, reinstallFlags map[string]bool, disabledFlags map[string]bool, skipGlobalUseFlags bool, progressChan chan<- InstallProgressMsg) error

	// Package Mapping
	GetPackageMapping(wm deps.WindowManager) map[string]PackageMapping

	// Prerequisites
	InstallPrerequisites(ctx context.Context, sudoPassword string, progressChan chan<- InstallProgressMsg) error
}

Distribution defines a Linux distribution with all its specific configurations

func NewDistribution

func NewDistribution(id string, logChan chan<- string) (Distribution, error)

NewDistribution creates a distribution instance by ID

func NewPackageInstaller

func NewPackageInstaller(distribution string, logChan chan<- string) (Distribution, error)

NewPackageInstaller creates a Distribution for package installation

type DistroConfig

type DistroConfig struct {
	ID          string
	ColorHex    string
	Family      DistroFamily
	Constructor func(config DistroConfig, logChan chan<- string) Distribution
}

DistroConfig holds configuration for a distribution

type DistroFamily

type DistroFamily string

DistroFamily represents a family of related distributions

const (
	FamilyArch   DistroFamily = "arch"
	FamilyFedora DistroFamily = "fedora"
	FamilySUSE   DistroFamily = "suse"
	FamilyUbuntu DistroFamily = "ubuntu"
	FamilyDebian DistroFamily = "debian"
	FamilyNix    DistroFamily = "nix"
	FamilyGentoo DistroFamily = "gentoo"
)

type DistroInfo

type DistroInfo struct {
	ID           string
	HexColorCode string
}

DistroInfo contains basic information about a distribution

type FedoraDistribution

type FedoraDistribution struct {
	*BaseDistribution
	*ManualPackageInstaller
	// contains filtered or unexported fields
}

func NewFedoraDistribution

func NewFedoraDistribution(config DistroConfig, logChan chan<- string) *FedoraDistribution

func (*FedoraDistribution) DetectDependencies

func (f *FedoraDistribution) DetectDependencies(ctx context.Context, wm deps.WindowManager) ([]deps.Dependency, error)

func (*FedoraDistribution) DetectDependenciesWithTerminal

func (f *FedoraDistribution) DetectDependenciesWithTerminal(ctx context.Context, wm deps.WindowManager, terminal deps.Terminal) ([]deps.Dependency, error)

func (*FedoraDistribution) GetColorHex

func (f *FedoraDistribution) GetColorHex() string

func (*FedoraDistribution) GetFamily

func (f *FedoraDistribution) GetFamily() DistroFamily

func (*FedoraDistribution) GetID

func (f *FedoraDistribution) GetID() string

func (*FedoraDistribution) GetPackageManager

func (f *FedoraDistribution) GetPackageManager() PackageManagerType

func (*FedoraDistribution) GetPackageMapping

func (f *FedoraDistribution) GetPackageMapping(wm deps.WindowManager) map[string]PackageMapping

func (*FedoraDistribution) GetPackageMappingWithVariants

func (f *FedoraDistribution) GetPackageMappingWithVariants(wm deps.WindowManager, variants map[string]deps.PackageVariant) map[string]PackageMapping

func (*FedoraDistribution) InstallPackages

func (f *FedoraDistribution) InstallPackages(ctx context.Context, dependencies []deps.Dependency, wm deps.WindowManager, sudoPassword string, reinstallFlags map[string]bool, disabledFlags map[string]bool, skipGlobalUseFlags bool, progressChan chan<- InstallProgressMsg) error

func (*FedoraDistribution) InstallPrerequisites

func (f *FedoraDistribution) InstallPrerequisites(ctx context.Context, sudoPassword string, progressChan chan<- InstallProgressMsg) error

type GentooDistribution added in v0.3.4

type GentooDistribution struct {
	*BaseDistribution
	*ManualPackageInstaller
	// contains filtered or unexported fields
}

func NewGentooDistribution added in v0.3.4

func NewGentooDistribution(config DistroConfig, logChan chan<- string) *GentooDistribution

func (*GentooDistribution) DetectDependencies added in v0.3.4

func (g *GentooDistribution) DetectDependencies(ctx context.Context, wm deps.WindowManager) ([]deps.Dependency, error)

func (*GentooDistribution) DetectDependenciesWithTerminal added in v0.3.4

func (g *GentooDistribution) DetectDependenciesWithTerminal(ctx context.Context, wm deps.WindowManager, terminal deps.Terminal) ([]deps.Dependency, error)

func (*GentooDistribution) GetColorHex added in v0.3.4

func (g *GentooDistribution) GetColorHex() string

func (*GentooDistribution) GetFamily added in v0.3.4

func (g *GentooDistribution) GetFamily() DistroFamily

func (*GentooDistribution) GetID added in v0.3.4

func (g *GentooDistribution) GetID() string

func (*GentooDistribution) GetPackageManager added in v0.3.4

func (g *GentooDistribution) GetPackageManager() PackageManagerType

func (*GentooDistribution) GetPackageMapping added in v0.3.4

func (g *GentooDistribution) GetPackageMapping(wm deps.WindowManager) map[string]PackageMapping

func (*GentooDistribution) GetPackageMappingWithVariants added in v0.3.4

func (g *GentooDistribution) GetPackageMappingWithVariants(wm deps.WindowManager, variants map[string]deps.PackageVariant) map[string]PackageMapping

func (*GentooDistribution) InstallPackages added in v0.3.4

func (g *GentooDistribution) InstallPackages(ctx context.Context, dependencies []deps.Dependency, wm deps.WindowManager, sudoPassword string, reinstallFlags map[string]bool, disabledFlags map[string]bool, skipGlobalUseFlags bool, progressChan chan<- InstallProgressMsg) error

func (*GentooDistribution) InstallPrerequisites added in v0.3.4

func (g *GentooDistribution) InstallPrerequisites(ctx context.Context, sudoPassword string, progressChan chan<- InstallProgressMsg) error

type InstallPhase

type InstallPhase int

InstallPhase represents the current phase of installation

const (
	PhasePrerequisites InstallPhase = iota
	PhaseAURHelper
	PhaseSystemPackages
	PhaseAURPackages
	PhaseCursorTheme
	PhaseConfiguration
	PhaseComplete
)

type InstallProgressMsg

type InstallProgressMsg struct {
	Phase       InstallPhase
	Progress    float64
	Step        string
	IsComplete  bool
	NeedsSudo   bool
	CommandInfo string
	LogOutput   string
	Error       error
}

InstallProgressMsg represents progress during package installation

type ManualPackageInstaller

type ManualPackageInstaller struct {
	*BaseDistribution
}

ManualPackageInstaller provides methods for installing packages from source

func (*ManualPackageInstaller) InstallManualPackages

func (m *ManualPackageInstaller) InstallManualPackages(ctx context.Context, packages []string, sudoPassword string, progressChan chan<- InstallProgressMsg) error

InstallManualPackages handles packages that need manual building

type NixOSDistribution

type NixOSDistribution struct {
	*BaseDistribution
	// contains filtered or unexported fields
}

func NewNixOSDistribution

func NewNixOSDistribution(config DistroConfig, logChan chan<- string) *NixOSDistribution

func (*NixOSDistribution) DetectDependencies

func (n *NixOSDistribution) DetectDependencies(ctx context.Context, wm deps.WindowManager) ([]deps.Dependency, error)

func (*NixOSDistribution) DetectDependenciesWithTerminal

func (n *NixOSDistribution) DetectDependenciesWithTerminal(ctx context.Context, wm deps.WindowManager, terminal deps.Terminal) ([]deps.Dependency, error)

func (*NixOSDistribution) GetColorHex

func (n *NixOSDistribution) GetColorHex() string

func (*NixOSDistribution) GetFamily

func (n *NixOSDistribution) GetFamily() DistroFamily

func (*NixOSDistribution) GetID

func (n *NixOSDistribution) GetID() string

func (*NixOSDistribution) GetPackageManager

func (n *NixOSDistribution) GetPackageManager() PackageManagerType

func (*NixOSDistribution) GetPackageMapping

func (n *NixOSDistribution) GetPackageMapping(wm deps.WindowManager) map[string]PackageMapping

func (*NixOSDistribution) InstallPackages

func (n *NixOSDistribution) InstallPackages(ctx context.Context, dependencies []deps.Dependency, wm deps.WindowManager, sudoPassword string, reinstallFlags map[string]bool, disabledFlags map[string]bool, skipGlobalUseFlags bool, progressChan chan<- InstallProgressMsg) error

func (*NixOSDistribution) InstallPrerequisites

func (n *NixOSDistribution) InstallPrerequisites(ctx context.Context, sudoPassword string, progressChan chan<- InstallProgressMsg) error

type OSInfo

type OSInfo struct {
	Distribution DistroInfo
	Version      string
	VersionID    string
	PrettyName   string
	Architecture string
}

OSInfo contains complete OS information

func GetOSInfo

func GetOSInfo() (*OSInfo, error)

GetOSInfo detects the current OS and returns information about it

type OpenSUSEDistribution

type OpenSUSEDistribution struct {
	*BaseDistribution
	*ManualPackageInstaller
	// contains filtered or unexported fields
}

func NewOpenSUSEDistribution

func NewOpenSUSEDistribution(config DistroConfig, logChan chan<- string) *OpenSUSEDistribution

func (*OpenSUSEDistribution) DetectDependencies

func (o *OpenSUSEDistribution) DetectDependencies(ctx context.Context, wm deps.WindowManager) ([]deps.Dependency, error)

func (*OpenSUSEDistribution) DetectDependenciesWithTerminal

func (o *OpenSUSEDistribution) DetectDependenciesWithTerminal(ctx context.Context, wm deps.WindowManager, terminal deps.Terminal) ([]deps.Dependency, error)

func (*OpenSUSEDistribution) GetColorHex

func (o *OpenSUSEDistribution) GetColorHex() string

func (*OpenSUSEDistribution) GetFamily

func (o *OpenSUSEDistribution) GetFamily() DistroFamily

func (*OpenSUSEDistribution) GetID

func (o *OpenSUSEDistribution) GetID() string

func (*OpenSUSEDistribution) GetPackageManager

func (o *OpenSUSEDistribution) GetPackageManager() PackageManagerType

func (*OpenSUSEDistribution) GetPackageMapping

func (o *OpenSUSEDistribution) GetPackageMapping(wm deps.WindowManager) map[string]PackageMapping

func (*OpenSUSEDistribution) GetPackageMappingWithVariants

func (o *OpenSUSEDistribution) GetPackageMappingWithVariants(wm deps.WindowManager, variants map[string]deps.PackageVariant) map[string]PackageMapping

func (*OpenSUSEDistribution) InstallManualPackages

func (o *OpenSUSEDistribution) InstallManualPackages(ctx context.Context, packages []string, sudoPassword string, progressChan chan<- InstallProgressMsg) error

InstallManualPackages overrides the base implementation to use openSUSE-specific builds

func (*OpenSUSEDistribution) InstallPackages

func (o *OpenSUSEDistribution) InstallPackages(ctx context.Context, dependencies []deps.Dependency, wm deps.WindowManager, sudoPassword string, reinstallFlags map[string]bool, disabledFlags map[string]bool, skipGlobalUseFlags bool, progressChan chan<- InstallProgressMsg) error

func (*OpenSUSEDistribution) InstallPrerequisites

func (o *OpenSUSEDistribution) InstallPrerequisites(ctx context.Context, sudoPassword string, progressChan chan<- InstallProgressMsg) error

type PackageManagerType

type PackageManagerType string

PackageManagerType defines the package manager a distro uses

const (
	PackageManagerPacman  PackageManagerType = "pacman"
	PackageManagerDNF     PackageManagerType = "dnf"
	PackageManagerAPT     PackageManagerType = "apt"
	PackageManagerZypper  PackageManagerType = "zypper"
	PackageManagerNix     PackageManagerType = "nix"
	PackageManagerPortage PackageManagerType = "portage"
)

type PackageMapping

type PackageMapping struct {
	Name           string         // Package name to install
	Repository     RepositoryType // Repository type
	RepoURL        string         // Repository URL if needed (e.g., COPR repo, PPA)
	BuildFunc      string         // Name of manual build function if RepoTypeManual
	UseFlags       string         // USE flags for Gentoo packages
	AcceptKeywords string         // Accept keywords for Gentoo packages (e.g., "~amd64")
}

PackageMapping defines how to install a package on a specific distro

type RepositoryType

type RepositoryType string

RepositoryType defines the type of repository for a package

const (
	RepoTypeSystem RepositoryType = "system" // Standard system repo (pacman, dnf, apt)
	RepoTypeAUR    RepositoryType = "aur"    // Arch User Repository
	RepoTypeCOPR   RepositoryType = "copr"   // Fedora COPR
	RepoTypePPA    RepositoryType = "ppa"    // Ubuntu PPA
	RepoTypeFlake  RepositoryType = "flake"  // Nix flake
	RepoTypeGURU   RepositoryType = "guru"   // Gentoo GURU
	RepoTypeManual RepositoryType = "manual" // Manual build from source
)

type UbuntuDistribution

type UbuntuDistribution struct {
	*BaseDistribution
	*ManualPackageInstaller
	// contains filtered or unexported fields
}

func NewUbuntuDistribution

func NewUbuntuDistribution(config DistroConfig, logChan chan<- string) *UbuntuDistribution

func (*UbuntuDistribution) DetectDependencies

func (u *UbuntuDistribution) DetectDependencies(ctx context.Context, wm deps.WindowManager) ([]deps.Dependency, error)

func (*UbuntuDistribution) DetectDependenciesWithTerminal

func (u *UbuntuDistribution) DetectDependenciesWithTerminal(ctx context.Context, wm deps.WindowManager, terminal deps.Terminal) ([]deps.Dependency, error)

func (*UbuntuDistribution) GetColorHex

func (u *UbuntuDistribution) GetColorHex() string

func (*UbuntuDistribution) GetFamily

func (u *UbuntuDistribution) GetFamily() DistroFamily

func (*UbuntuDistribution) GetID

func (u *UbuntuDistribution) GetID() string

func (*UbuntuDistribution) GetPackageManager

func (u *UbuntuDistribution) GetPackageManager() PackageManagerType

func (*UbuntuDistribution) GetPackageMapping

func (u *UbuntuDistribution) GetPackageMapping(wm deps.WindowManager) map[string]PackageMapping

func (*UbuntuDistribution) InstallManualPackages

func (u *UbuntuDistribution) InstallManualPackages(ctx context.Context, packages []string, sudoPassword string, progressChan chan<- InstallProgressMsg) error

Override InstallManualPackages for Ubuntu to handle Ubuntu-specific installations

func (*UbuntuDistribution) InstallPackages

func (u *UbuntuDistribution) InstallPackages(ctx context.Context, dependencies []deps.Dependency, wm deps.WindowManager, sudoPassword string, reinstallFlags map[string]bool, disabledFlags map[string]bool, skipGlobalUseFlags bool, progressChan chan<- InstallProgressMsg) error

func (*UbuntuDistribution) InstallPrerequisites

func (u *UbuntuDistribution) InstallPrerequisites(ctx context.Context, sudoPassword string, progressChan chan<- InstallProgressMsg) error

type UnsupportedDistributionError

type UnsupportedDistributionError struct {
	ID string
}

UnsupportedDistributionError is returned when a distribution is not supported

func (*UnsupportedDistributionError) Error

Jump to

Keyboard shortcuts

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