added required partitioning package installations
Some checks failed
Build / build (push) Failing after 4m53s
Some checks failed
Build / build (push) Failing after 4m53s
This commit is contained in:
@@ -72,6 +72,11 @@ func (m InstallModel) startInstall() tea.Cmd {
|
||||
}
|
||||
|
||||
func (m InstallModel) performInstall() error {
|
||||
// Check for required tools before starting installation
|
||||
if err := m.checkRequiredTools(); err != nil {
|
||||
return fmt.Errorf("missing required tools: %w", err)
|
||||
}
|
||||
|
||||
m.updateProgress(1, "Partitioning disk...")
|
||||
if err := m.partitionDisk(); err != nil {
|
||||
return fmt.Errorf("partitioning failed: %w", err)
|
||||
@@ -115,6 +120,81 @@ func (m InstallModel) performInstall() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m InstallModel) checkRequiredTools() error {
|
||||
requiredTools := []string{
|
||||
"sgdisk",
|
||||
"wipefs",
|
||||
"partprobe",
|
||||
"mkfs.fat",
|
||||
"mkfs.btrfs",
|
||||
"mount",
|
||||
"umount",
|
||||
"dd",
|
||||
"blkid",
|
||||
"fuser",
|
||||
}
|
||||
|
||||
missingTools := []string{}
|
||||
for _, tool := range requiredTools {
|
||||
if _, err := exec.LookPath(tool); err != nil {
|
||||
missingTools = append(missingTools, tool)
|
||||
}
|
||||
}
|
||||
|
||||
if len(missingTools) > 0 {
|
||||
// Try to install missing tools
|
||||
if err := m.installMissingTools(missingTools); err != nil {
|
||||
return fmt.Errorf("failed to install missing tools %v: %w", missingTools, err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m InstallModel) installMissingTools(tools []string) error {
|
||||
// Install required packages for partitioning tools
|
||||
requiredPackages := []string{}
|
||||
|
||||
// Map tools to packages that provide them
|
||||
toolToPackage := map[string]string{
|
||||
"sgdisk": "gptfdisk",
|
||||
"wipefs": "util-linux",
|
||||
"partprobe": "parted",
|
||||
"mkfs.fat": "dosfstools",
|
||||
"mkfs.btrfs": "btrfs-progs",
|
||||
"blkid": "util-linux",
|
||||
"fuser": "psmisc",
|
||||
}
|
||||
|
||||
// Determine which packages need to be installed
|
||||
neededPackages := make(map[string]bool)
|
||||
for _, tool := range tools {
|
||||
if pkg, exists := toolToPackage[tool]; exists {
|
||||
neededPackages[pkg] = true
|
||||
}
|
||||
}
|
||||
|
||||
// Convert map to slice
|
||||
for pkg := range neededPackages {
|
||||
requiredPackages = append(requiredPackages, pkg)
|
||||
}
|
||||
|
||||
if len(requiredPackages) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Install the packages
|
||||
m.updateProgress(m.currentStep, "Installing required tools...")
|
||||
cmd := exec.Command("pacman", "-Sy", "--noconfirm")
|
||||
cmd.Args = append(cmd.Args, requiredPackages...)
|
||||
|
||||
if output, err := cmd.CombinedOutput(); err != nil {
|
||||
return fmt.Errorf("failed to install required packages: %w\nOutput: %s", err, string(output))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m InstallModel) updateProgress(step int, message string) {
|
||||
m.currentStep = step
|
||||
m.status = message
|
||||
|
||||
Reference in New Issue
Block a user