tenseleyflow/parrot / 0568072

Browse files

fixes to hook install process

Authored by espadonne
SHA
056807231e03634f21968d1dc90bcdbabcd769b9
Parents
ecafac1
Tree
d1abba4

1 changed file

StatusFile+-
M cmd/install.go 20 4
cmd/install.gomodified
@@ -56,11 +56,27 @@ func installHooks(cmd *cobra.Command, args []string) {
56
 		hookFile = "parrot-hook.sh"
56
 		hookFile = "parrot-hook.sh"
57
 	}
57
 	}
58
 
58
 
59
-	possiblePaths := []string{
59
+	// Build list of possible paths, starting with most specific
60
-		filepath.Join("/usr/share/parrot", hookFile),       // RPM installation
60
+	possiblePaths := []string{}
61
-		filepath.Join("/usr/local/share/parrot", hookFile), // Manual installation
61
+
62
-		filepath.Join(".", hookFile),                       // Development
62
+	// Check relative to executable (works for NixOS, Homebrew, and other non-FHS systems)
63
+	if exePath, err := os.Executable(); err == nil {
64
+		// Resolve symlinks to get actual binary location
65
+		if realPath, err := filepath.EvalSymlinks(exePath); err == nil {
66
+			exePath = realPath
67
+		}
68
+		exeDir := filepath.Dir(exePath)
69
+		// Try ../share/parrot/ relative to bin directory
70
+		possiblePaths = append(possiblePaths, filepath.Join(exeDir, "..", "share", "parrot", hookFile))
63
 	}
71
 	}
72
+
73
+	// Standard FHS and user paths
74
+	possiblePaths = append(possiblePaths,
75
+		filepath.Join("/usr/share/parrot", hookFile),            // RPM/system installation
76
+		filepath.Join("/usr/local/share/parrot", hookFile),      // Manual system installation
77
+		filepath.Join(homeDir, ".local/share/parrot", hookFile), // make install (user local)
78
+		filepath.Join(".", hookFile),                            // Development
79
+	)
64
 	
80
 	
65
 	for _, path := range possiblePaths {
81
 	for _, path := range possiblePaths {
66
 		if _, err := os.Stat(path); err == nil {
82
 		if _, err := os.Stat(path); err == nil {