You are not logged in.
I want to add add a function to install some AUR packages on my custum arch install script. I am getting permission errors and not sure about the correct way of acheiving that.
This is what I have so far:
mkdir /mnt/home/"$USER"/.AUR
for pkg in "${aur_all[@]}"; do
#did not work
# arch-chroot /mnt git clone https://aur.archlinux.org/${pkg}.git
# arch-chroot /mnt bash -c "cd ${pkg} && makepkg -si --noconfirm"
arch-chroot /mnt sudo -u "$USER" git clone https://aur.archlinux.org/${pkg}.git /mnt/home/"$USER"/.AUR
arch-chroot /mnt sudo -u "$USER" bash -c "cd /mnt/home/${USER}/.AUR/${pkg} && makepkg -si --noconfirm"
done
Kindly help.
Offline
The typical method used is to build the packages on another system and just copy the created binaries to the install medium.
It seems you don't want that, https://wiki.archlinux.org/title/Develo … ean_chroot has good info about using a chroot to build archlinux packages and should give you an idea.
Last edited by Lone_Wolf (2024-01-07 12:42:59)
Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
clean chroot building not flexible enough ?
Try clean chroot manager by graysky
Offline
The typical method used is to build the packages on another system and just copy the created binaries to the install medium.
It seems you don't want that, https://wiki.archlinux.org/title/Develo … ean_chroot has good info about using a chroot to build archlinux packages and should give you an idea.
Thank you for your prompt response.
I followed the link but did not quite understand.
Do you mind explaining further?
Perhaps with an example? Sorry!
Offline
make sure devtools and base-devel are part of your install environment (if 32-bit build are needed, also add multilib-devel )
create a user foo with a home-directory and bash as shell
switch to this user
create a directory $HOME/foo-build and cd into it. run git clone to retrieve the files needed for building aur-foo .
cd to the aur-foo folder .
execute extra-x86_64-build -c
Try these steps manually before using them in a script .
Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
clean chroot building not flexible enough ?
Try clean chroot manager by graysky
Offline
I am getting permission errors ... #did not work
https://bbs.archlinux.org/viewtopic.php?id=57855
What are the errors? What do you expect "$USER" to be in that context? (edit: nevermind this part, it would seem it must be set in some other part of the script you haven't shown). But do those lines with sudo $USER work?
Last edited by Trilby (2024-01-07 14:57:53)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
I got it to work.
Basically it seems that the step I was missing was to switch user. To run the script without having to enter the password I added some lines as below.
# as part of a function
arch-chroot /mnt sed -i 's/^%wheel ALL=(ALL:ALL) ALL$/%wheel ALL=(ALL:ALL) NOPASSWD: ALL/' /etc/sudoers
# Install the required ones:
for pkg in "${aur_all[@]}"; do
local COMMAND="mkdir -p /home/$USER/.AUR && cd /home/$USER/.AUR && git clone https://aur.archlinux.org/${pkg}.git && (cd $pkg && makepkg -si --noconfirm)"
arch-chroot /mnt bash -c "echo -e \"$USERPASS\n$USERPASS\n$USERPASS\n$USERPASS\n\" | su $USER -s /usr/bin/bash -c \"$COMMAND\""
done
arch-chroot /mnt sed -i 's/^%wheel ALL=(ALL:ALL) NOPASSWD: ALL$/%wheel ALL=(ALL:ALL) ALL/' /etc/sudoers
Last edited by meezoarch (2024-01-07 17:38:01)
Offline
meezoarch wrote:I am getting permission errors ... #did not work
https://bbs.archlinux.org/viewtopic.php?id=57855
What are the errors?
What do you expect "$USER" to be in that context?(edit: nevermind this part, it would seem it must be set in some other part of the script you haven't shown). But do those lines with sudo $USER work?
Yes $USER is defined and the sudo $USER was not working => permission denied error.
Please see my comment above. I am happy to take further suggestions.
Offline