Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/INSTALLER_CI_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ This directory contains GitHub Actions workflows for the dotfiles installer proj
**Platforms Tested**:
- Ubuntu (latest)
- Debian (bookworm container)
- Fedora (latest)
- CentOS (latest)
- macOS (latest)

## Build Process
Expand Down Expand Up @@ -94,4 +96,4 @@ mkdir -p "$HOME"

- **Linting**: Will integrate golangci-lint later
- **Security Scanning**: Can add Trivy scans if needed
- **Release Automation**: Will add when ready for releases
- **Release Automation**: Will add when ready for releases
9 changes: 9 additions & 0 deletions .github/workflows/installer-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ jobs:
- os: ubuntu-latest
platform: debian
container: debian:bookworm
- os: ubuntu-latest
platform: fedora
container: fedora:latest
- os: ubuntu-latest
platform: centos
container: quay.io/centos/centos:latest
- os: macos-latest
platform: macos

Expand Down Expand Up @@ -236,6 +242,9 @@ jobs:
run: |
if [ "${{ matrix.platform }}" = "macos" ]; then
brew install expect
elif [ "${{ matrix.platform }}" = "fedora" ] || [ "${{ matrix.platform }}" = "centos" ]; then
# For Fedora/CentOS - install expect via dnf
dnf install -y expect
else
# For Ubuntu/Debian - check if sudo exists, otherwise run directly (containers)
if command -v sudo >/dev/null 2>&1; then
Expand Down
45 changes: 42 additions & 3 deletions installer/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import (
"github.com/MrPointer/dotfiles/installer/lib/apt"
"github.com/MrPointer/dotfiles/installer/lib/brew"
"github.com/MrPointer/dotfiles/installer/lib/compatibility"
"github.com/MrPointer/dotfiles/installer/lib/dnf"
"github.com/MrPointer/dotfiles/installer/lib/dotfilesmanager"
"github.com/MrPointer/dotfiles/installer/lib/dotfilesmanager/chezmoi"
"github.com/MrPointer/dotfiles/installer/lib/gpg"
"github.com/MrPointer/dotfiles/installer/lib/packageresolver"
"github.com/MrPointer/dotfiles/installer/lib/pkgmanager"
"github.com/MrPointer/dotfiles/installer/lib/shell"
"github.com/MrPointer/dotfiles/installer/utils/logger"
Expand Down Expand Up @@ -138,6 +140,8 @@ func createPackageManagerForSystem(sysInfo *compatibility.SystemInfo) pkgmanager
switch sysInfo.DistroName {
case "ubuntu", "debian":
return apt.NewAptPackageManager(cliLogger, globalCommander, globalOsManager, privilege.NewDefaultEscalator(cliLogger, globalCommander, globalOsManager), GetDisplayMode())
case "fedora", "centos", "rhel":
return dnf.NewDnfPackageManager(cliLogger, globalCommander, globalOsManager, privilege.NewDefaultEscalator(cliLogger, globalCommander, globalOsManager), GetDisplayMode())
default:
cliLogger.Warning("Unsupported Linux distribution for automatic package installation: %s", sysInfo.DistroName)
return nil
Expand All @@ -155,6 +159,23 @@ func createPackageManagerForSystem(sysInfo *compatibility.SystemInfo) pkgmanager
}
}

// createPackageResolverForSystem creates a package resolver for the given system.
func createPackageResolverForSystem(packageManager pkgmanager.PackageManager, sysInfo *compatibility.SystemInfo) *packageresolver.Resolver {
// Load package mappings
mappings, err := packageresolver.LoadPackageMappings(viper.GetViper(), "")
if err != nil {
return nil
}

// Create and return resolver
resolver, err := packageresolver.NewResolver(mappings, packageManager, sysInfo)
if err != nil {
return nil
}

return resolver
}

// handlePrerequisiteInstallation handles automatic installation of missing prerequisites.
// Returns true if prerequisites were installed and compatibility should be re-checked.
func handlePrerequisiteInstallation(sysInfo compatibility.SystemInfo, log logger.Logger) bool {
Expand Down Expand Up @@ -212,14 +233,32 @@ func handlePrerequisiteInstallation(sysInfo compatibility.SystemInfo, log logger

// Install each selected prerequisite
installed := false

// Create package resolver to get proper package info including types
resolver := createPackageResolverForSystem(packageManager, &sysInfo)
if resolver == nil {
log.Warning("Cannot resolve package information for this system")
return false
}

for _, name := range prerequisitesToInstall {
if detail, exists := sysInfo.Prerequisites.Details[name]; exists {
log.StartProgress(fmt.Sprintf("Installing %s", detail.Description))

// Use the prerequisite name directly as the package name
packageInfo := pkgmanager.NewRequestedPackageInfo(name, nil)
// Resolve the prerequisite to get proper package name and type
resolvedPackage, err := resolver.Resolve(name, "")
if err != nil {
log.FailProgress(fmt.Sprintf("Failed to resolve package %s", name), err)
return false
}

// Create package info with resolved name and type
packageInfo := pkgmanager.NewRequestedPackageInfoWithType(
resolvedPackage.Name,
resolvedPackage.Type,
resolvedPackage.VersionConstraints)

err := packageManager.InstallPackage(packageInfo)
err = packageManager.InstallPackage(packageInfo)
if err != nil {
log.FailProgress(fmt.Sprintf("Failed to install %s", detail.Description), err)
return false
Expand Down
41 changes: 28 additions & 13 deletions installer/internal/config/compatibility.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,17 @@ operatingSystems:
description: "Git version control system"
install_hint: "sudo apt-get install git"
fedora:
supported: false
notes: "Support planned for future release"
supported: true
version_constraint: ">= 35"
notes: "Fedora 35 or newer"
prerequisites:
- name: "development-tools"
# Use same name as Ubuntu because this acts as a key, resolved later by the package-resolver
- name: "build-essential"
command: "gcc"
description: "Development tools group including gcc, make, and other build tools"
install_hint: "sudo dnf group install 'Development Tools'"
- name: "procps-ng"
# Use same name as Ubuntu because this acts as a key, resolved later by the package-resolver
- name: "procps"
command: "ps"
description: "Process utilities"
install_hint: "sudo dnf install procps-ng"
Expand All @@ -82,14 +85,17 @@ operatingSystems:
description: "Git version control system"
install_hint: "sudo dnf install git"
centos:
supported: false
notes: "Support planned for future release"
supported: true
notes: "CentOS 6 or newer"
version_constraint: ">= 6"
prerequisites:
- name: "development-tools"
# Use same name as Ubuntu because this acts as a key, resolved later by the package-resolver
- name: "build-essential"
command: "gcc"
description: "Development tools group including gcc, make, and other build tools"
install_hint: "sudo dnf group install 'Development Tools'"
- name: "procps-ng"
# Use same name as Ubuntu because this acts as a key, resolved later by the package-resolver
- name: "procps"
command: "ps"
description: "Process utilities"
install_hint: "sudo dnf install procps-ng"
Expand All @@ -106,14 +112,17 @@ operatingSystems:
description: "Git version control system"
install_hint: "sudo dnf install git"
redhat:
supported: false
notes: "Support planned for future release"
supported: true
notes: "Red Hat Enterprise Linux 6 or newer"
version_constraint: ">= 6"
prerequisites:
- name: "development-tools"
# Use same name as Ubuntu because this acts as a key, resolved later by the package-resolver
- name: "build-essential"
command: "gcc"
description: "Development tools group including gcc, make, and other build tools"
install_hint: "sudo dnf group install 'Development Tools'"
- name: "procps-ng"
# Use same name as Ubuntu because this acts as a key, resolved later by the package-resolver
- name: "procps"
command: "ps"
description: "Process utilities"
install_hint: "sudo dnf install procps-ng"
Expand All @@ -129,13 +138,19 @@ operatingSystems:
command: "git"
description: "Git version control system"
install_hint: "sudo dnf install git"
rocky:
supported: false
notes: "No current plans for support"
almalinux:
supported: false
notes: "No current plans for support"
suse:
supported: false
notes: "No current plans for support"
# Add more Linux distributions here as needed
darwin:
supported: true
notes: "macOS 10.15 or newer recommended"
notes: "macOS 12 or newer"
prerequisites:
- name: "xcode-command-line-tools"
command: "xcode-select"
Expand Down
35 changes: 35 additions & 0 deletions installer/internal/config/packagemap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ packages:
name: git
brew:
name: git
dnf:
name: git
gpg:
apt:
name: gnupg2 # Debian/Ubuntu often use gnupg2
Expand All @@ -17,8 +19,41 @@ packages:
name: neovim
brew:
name: neovim
dnf:
name: neovim
zsh:
apt:
name: zsh
brew:
name: zsh
dnf:
name: zsh
build-essential:
apt:
name: build-essential
dnf:
type: group
name:
fedora: development-tools
centos: "Development Tools"
rhel: "Development Tools"
# Note: Other package managers would define their equivalents here
curl:
apt:
name: curl
brew:
name: curl
dnf:
name: curl
file:
apt:
name: file
brew:
name: file
dnf:
name: file
procps:
apt:
name: procps
dnf:
name: procps-ng
Loading
Loading