updated deps check
This commit is contained in:
parent
87ef90c354
commit
7840cb8b39
1 changed files with 24 additions and 4 deletions
28
main.go
28
main.go
|
@ -69,12 +69,32 @@ func printHelp() {
|
|||
|
||||
// checkDependencies verifies if required dependencies are installed
|
||||
func checkDependencies() error {
|
||||
dependencies := []string{"mercurial", "python3", "rsync", "git"}
|
||||
for _, dep := range dependencies {
|
||||
if _, err := exec.LookPath(dep); err != nil {
|
||||
return fmt.Errorf("dependency %s is not installed. Please run: sudo apt install %s", dep, dep)
|
||||
dependencies := map[string]string{
|
||||
"mercurial": "hg",
|
||||
"python3": "python3",
|
||||
"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
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue