From bd1c5e2a4a2c74f5468ccbd4731896215c3d85eb Mon Sep 17 00:00:00 2001 From: ndwarshuis Date: Sat, 13 Mar 2021 20:55:59 -0500 Subject: [PATCH] FIX call emacs as normal user --- dot_bin/executable_bootstrap_pkgs | 13 +++++++------ run_once_after_10_install-packages.sh | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/dot_bin/executable_bootstrap_pkgs b/dot_bin/executable_bootstrap_pkgs index 5048afe..c5ff0fe 100644 --- a/dot_bin/executable_bootstrap_pkgs +++ b/dot_bin/executable_bootstrap_pkgs @@ -14,8 +14,9 @@ ## 6. remove the temporary HOME for yay ## 7. remove the pacman sudo privilege for nobody -pkgsrc_dir="$1" -emacs_dir="$2" +home_user="$1" +pkgsrc_dir="$2" +emacs_dir="$3" makepkg_tmp=/tmp/bootstrap-makepkg yaytmp=/tmp/bootstrap-yay @@ -62,10 +63,10 @@ run_yay() { ## packages for emacs (install emacs first to read the config) pacman --needed -S emacs - emacs -batch -l "$emacs_dir/init.el" --eval \ + sudo -u "$home_user" emacs -batch -l "$emacs_dir/init.el" --eval \ '(print (format "pkgs: %s" (s-join " " (nd/get-aur-dependencies t))))' IFS=' ' read -r -a emacs_pkgs \ - < <(emacs -batch -l "$emacs_dir/init.el" --eval \ + < <(sudo -u "$home_user" emacs -batch -l "$emacs_dir/init.el" --eval \ '(print (format "pkgs: %s" (s-join " " (nd/get-aur-dependencies t))))' \ 2>/dev/null \ sed -n -e 's/"pkgs: \(.*\)"/\1/p') @@ -147,8 +148,8 @@ if [[ ! "$(id -u)" = "0" ]]; then exit 1 fi -if [ "$#" -ne 2 ]; then - echo "Must supply custom package location and emacs root. Exiting" +if [ "$#" -ne 3 ]; then + echo "Must supply calling user, custom package dir, and emacs dir. Exiting" exit 1 fi diff --git a/run_once_after_10_install-packages.sh b/run_once_after_10_install-packages.sh index c66e77c..b3af217 100644 --- a/run_once_after_10_install-packages.sh +++ b/run_once_after_10_install-packages.sh @@ -44,7 +44,7 @@ clone_maybe https://github.com/ndwarshuis/.emacs.d.git "$emacs_dir" # only be used once. Pass the emacs config directory so it can get a list of # dependencies for emacs -sudo "$HOME/.bin/bootstrap_pkgs" "$HOME/.local/share/packages" "$emacs_dir" +sudo "$(id -u)" "$HOME/.bin/bootstrap_pkgs" "$HOME/.local/share/packages" "$emacs_dir" # Install Haskell dependencies for emacs. This is only necessary because some # Haskell programs are not packaged as "bin" or "stack" packages, in which case