You are not logged in.

#1 2024-01-07 12:28:38

meezoarch
Member
Registered: 2022-12-01
Posts: 42

Installing AUR packages while chroot?

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

#2 2024-01-07 12:42:12

Lone_Wolf
Forum Moderator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 12,394

Re: Installing AUR packages while chroot?

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 to complicated ?
Try clean chroot manager by graysky

Offline

#3 2024-01-07 12:51:04

meezoarch
Member
Registered: 2022-12-01
Posts: 42

Re: Installing AUR packages while chroot?

Lone_Wolf wrote:

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

#4 2024-01-07 13:15:14

Lone_Wolf
Forum Moderator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 12,394

Re: Installing AUR packages while chroot?

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 to complicated ?
Try clean chroot manager by graysky

Offline

#5 2024-01-07 14:56:37

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,924
Website

Re: Installing AUR packages while chroot?

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?

Last edited by Trilby (2024-01-07 14:57:53)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#6 2024-01-07 16:53:23

meezoarch
Member
Registered: 2022-12-01
Posts: 42

Re: Installing AUR packages while chroot?

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

#7 2024-01-07 16:55:05

meezoarch
Member
Registered: 2022-12-01
Posts: 42

Re: Installing AUR packages while chroot?

Trilby wrote:
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

Board footer

Powered by FluxBB