mirror of
https://github.com/fosrl/pangolin.git
synced 2025-06-21 04:45:41 +02:00
Update for new dnf
This commit is contained in:
parent
23b5dcfbed
commit
0cfc4d7dad
1 changed files with 27 additions and 5 deletions
|
@ -17,6 +17,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
"unicode"
|
"unicode"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"golang.org/x/term"
|
"golang.org/x/term"
|
||||||
)
|
)
|
||||||
|
@ -397,7 +398,7 @@ func installDocker() error {
|
||||||
return fmt.Errorf("failed to detect Linux distribution: %v", err)
|
return fmt.Errorf("failed to detect Linux distribution: %v", err)
|
||||||
}
|
}
|
||||||
osRelease := string(output)
|
osRelease := string(output)
|
||||||
|
|
||||||
// Detect system architecture
|
// Detect system architecture
|
||||||
archCmd := exec.Command("uname", "-m")
|
archCmd := exec.Command("uname", "-m")
|
||||||
archOutput, err := archCmd.Output()
|
archOutput, err := archCmd.Output()
|
||||||
|
@ -405,7 +406,7 @@ func installDocker() error {
|
||||||
return fmt.Errorf("failed to detect system architecture: %v", err)
|
return fmt.Errorf("failed to detect system architecture: %v", err)
|
||||||
}
|
}
|
||||||
arch := strings.TrimSpace(string(archOutput))
|
arch := strings.TrimSpace(string(archOutput))
|
||||||
|
|
||||||
// Map architecture to Docker's architecture naming
|
// Map architecture to Docker's architecture naming
|
||||||
var dockerArch string
|
var dockerArch string
|
||||||
switch arch {
|
switch arch {
|
||||||
|
@ -438,11 +439,31 @@ func installDocker() error {
|
||||||
apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
|
apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
|
||||||
`, dockerArch))
|
`, dockerArch))
|
||||||
case strings.Contains(osRelease, "ID=fedora"):
|
case strings.Contains(osRelease, "ID=fedora"):
|
||||||
installCmd = exec.Command("bash", "-c", `
|
// Detect Fedora version to handle DNF 5 changes
|
||||||
|
versionCmd := exec.Command("bash", "-c", "grep VERSION_ID /etc/os-release | cut -d'=' -f2 | tr -d '\"'")
|
||||||
|
versionOutput, err := versionCmd.Output()
|
||||||
|
var fedoraVersion int
|
||||||
|
if err == nil {
|
||||||
|
if v, parseErr := strconv.Atoi(strings.TrimSpace(string(versionOutput))); parseErr == nil {
|
||||||
|
fedoraVersion = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use appropriate DNF syntax based on version
|
||||||
|
var repoCmd string
|
||||||
|
if fedoraVersion >= 42 {
|
||||||
|
// DNF 5 syntax for Fedora 42+
|
||||||
|
repoCmd = "dnf config-manager addrepo --from-repofile=https://download.docker.com/linux/fedora/docker-ce.repo"
|
||||||
|
} else {
|
||||||
|
// DNF 4 syntax for Fedora < 42
|
||||||
|
repoCmd = "dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo"
|
||||||
|
}
|
||||||
|
|
||||||
|
installCmd = exec.Command("bash", "-c", fmt.Sprintf(`
|
||||||
dnf -y install dnf-plugins-core &&
|
dnf -y install dnf-plugins-core &&
|
||||||
dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo &&
|
%s &&
|
||||||
dnf install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
|
dnf install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
|
||||||
`)
|
`, repoCmd))
|
||||||
case strings.Contains(osRelease, "ID=opensuse") || strings.Contains(osRelease, "ID=\"opensuse-"):
|
case strings.Contains(osRelease, "ID=opensuse") || strings.Contains(osRelease, "ID=\"opensuse-"):
|
||||||
installCmd = exec.Command("bash", "-c", `
|
installCmd = exec.Command("bash", "-c", `
|
||||||
zypper install -y docker docker-compose &&
|
zypper install -y docker docker-compose &&
|
||||||
|
@ -466,6 +487,7 @@ func installDocker() error {
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("unsupported Linux distribution")
|
return fmt.Errorf("unsupported Linux distribution")
|
||||||
}
|
}
|
||||||
|
|
||||||
installCmd.Stdout = os.Stdout
|
installCmd.Stdout = os.Stdout
|
||||||
installCmd.Stderr = os.Stderr
|
installCmd.Stderr = os.Stderr
|
||||||
return installCmd.Run()
|
return installCmd.Run()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue