diff --git a/cmd/.version b/cmd/.version index 8d7796c..f8f647e 100644 --- a/cmd/.version +++ b/cmd/.version @@ -1 +1 @@ -AllPac V0.9.1 +AllPac V0.9.2 diff --git a/pkg/packagemanager/install.go b/pkg/packagemanager/install.go index 8e23e7a..78e20b9 100644 --- a/pkg/packagemanager/install.go +++ b/pkg/packagemanager/install.go @@ -165,8 +165,15 @@ func CloneAndInstallFromAUR(repoURL string, skipConfirmation bool) (string, erro return "", fmt.Errorf("error changing directory: %v", err) } - // Build the package using makepkg - cmdMakePkg := exec.Command("makepkg", "-si", "--noconfirm") + // Get the username of the user who invoked sudo + sudoUser := os.Getenv("SUDO_USER") + if sudoUser == "" { + logger.Errorf("cannot determine the non-root user to run makepkg") + return "", fmt.Errorf("cannot determine the non-root user to run makepkg") + } + + // Build the package using makepkg as the non-root user + cmdMakePkg := exec.Command("sudo", "-u", sudoUser, "makepkg", "-si", "--noconfirm") if output, err := cmdMakePkg.CombinedOutput(); err != nil { logger.Errorf("error building package with makepkg: %s, %v", output, err) return "", fmt.Errorf("error building package with makepkg: %s, %v", output, err)