updated deps check

This commit is contained in:
partisan 2024-12-08 09:34:08 +01:00
parent 87ef90c354
commit 7840cb8b39

28
main.go
View file

@ -69,12 +69,32 @@ func printHelp() {
// checkDependencies verifies if required dependencies are installed // checkDependencies verifies if required dependencies are installed
func checkDependencies() error { func checkDependencies() error {
dependencies := []string{"mercurial", "python3", "rsync", "git"} dependencies := map[string]string{
for _, dep := range dependencies { "mercurial": "hg",
if _, err := exec.LookPath(dep); err != nil { "python3": "python3",
return fmt.Errorf("dependency %s is not installed. Please run: sudo apt install %s", dep, dep) "rsync": "rsync",
"git": "git",
}
// Log the PATH for debugging
fmt.Printf("Current PATH: %s\n", os.Getenv("PATH"))
for dep, cmd := range dependencies {
// Use LookPath to check availability
if _, err := exec.LookPath(cmd); err != nil {
return fmt.Errorf("dependency %s is not installed or not found in PATH. Please run: sudo apt install %s", dep, dep)
}
// For python3, run a specific version check to confirm
if dep == "python3" {
out, err := exec.Command(cmd, "--version").Output()
if err != nil {
return fmt.Errorf("dependency %s is installed but not functional. Ensure 'python3 --version' works correctly: %v", dep, err)
}
fmt.Printf("Detected %s: %s", dep, string(out))
} }
} }
return nil return nil
} }