You are not logged in.

#1 2020-10-21 03:38:24

MountainX
Member
Registered: 2016-02-08
Posts: 371

[SOLVED] possible to build AUR package while in chroot?

I created a chroot as if I was installing Arch and I added all the development related packages (such as arch-install-scripts base base-devel devtools namcap shellcheck and others). I did this with "pacstrap -i". Then I created a build user, added it to wheel and sys groups, and added the sudoers permissions.

Then I tried to run makepkg.

sudo arch-chroot /$chrootpath
su builduser
cd /opt/builds/
git clone https://aur.archlinux.org/yay-bin.git
cd yay-bin/
makepkg -si

Here's the error:

==> Making package: yay-bin 10.1.0-1 (Tue 20 Oct 2020 10:44:55 PM EDT)
==> Checking runtime dependencies...
error: failed to initialize alpm library
(could not open database: /var/lib/pacman/)
==> ERROR: 'pacman' returned a fatal error (255):

I get the same error with any AUR package I try to make with makepkg.

Here are some of the things I checked so far:

# cat /var/lib/pacman/local/ALPM_DB_VERSION
9
# ls -la /var/lib/pacman/
total 0
drwxr-xr-x   4 root root    80 Oct 20 23:09 .
drwxr-xr-x  19 root root   380 Oct 20 22:23 ..
drwxr-x--x 797 root root 15960 Oct 20 22:55 local
drwxr-xr-x   2 root root   220 Oct 20 23:09 sync

I also ran the following but it didn't resolve the issue.

pacman-key --init
pacman-key --refresh-keys

I even tried "pacman-db-upgrade" although I knew that wasn't the issue because this is a fresh install. I also double checked "pacman -Syyu" and all packages are up to date. I can install any packages with pacman without errors.

Is it possible I cannot install AUR packges in a chroot the way I'm trying? Or did I miss a step?

Why am I doing this? I want to learn. I'm just trying a few new things. I am not having total success with the usual methods of building (AUR or custom) packages in a chroot. So far I have learned a lot about extra-x86_64 and aurutils.

If you want to see what I'm doing with aurutils, here's my recent post:
aurutils: building in a chroot, signing packages, adding to local repo

I want to try something entirely different, so I tired making a normal Arch system in a chroot, but not booting into it. Maybe that was a bad idea?

Last edited by MountainX (2020-10-27 06:11:55)

Offline

#2 2020-10-21 03:46:33

Awebb
Member
Registered: 2010-05-06
Posts: 6,275

Re: [SOLVED] possible to build AUR package while in chroot?

You have it right in front of you. Look at the permissions of "local", compare it to the others and fix it.

Edit: On top of that, do not ignore the info boxes in the wiki!
https://wiki.archlinux.org/index.php/Makepkg#Usage

Last edited by Awebb (2020-10-21 03:50:01)

Offline

#3 2020-10-21 04:31:16

MountainX
Member
Registered: 2016-02-08
Posts: 371

Re: [SOLVED] possible to build AUR package while in chroot?

Awebb wrote:

You have it right in front of you. Look at the permissions of "local", compare it to the others and fix it.

Edit: On top of that, do not ignore the info boxes in the wiki!
https://wiki.archlinux.org/index.php/Makepkg#Usage

Thank you. I'm not sure how I missed the permissions issue. I looked right at it multiple times and didn't see it.

I don't think I overlooked anything in the info boxes in the wiki. I'm not running makepkg as root. Was there something specific you think I ignored?

Last edited by MountainX (2020-10-21 04:31:46)

Offline

#4 2020-10-21 05:56:57

Awebb
Member
Registered: 2010-05-06
Posts: 6,275

Re: [SOLVED] possible to build AUR package while in chroot?

MountainX wrote:
Awebb wrote:

You have it right in front of you. Look at the permissions of "local", compare it to the others and fix it.

Edit: On top of that, do not ignore the info boxes in the wiki!
https://wiki.archlinux.org/index.php/Makepkg#Usage

Thank you. I'm not sure how I missed the permissions issue. I looked right at it multiple times and didn't see it.

I don't think I overlooked anything in the info boxes in the wiki. I'm not running makepkg as root. Was there something specific you think I ignored?

This time I overlooked your su builduser! Nothing to see here :-)

Offline

#5 2020-10-21 06:26:19

MountainX
Member
Registered: 2016-02-08
Posts: 371

Re: [SOLVED] possible to build AUR package while in chroot?

So now I know that it is possible to build AUR packages inside a chroot using this method.

I ended up using aurutils. I built (and signed) around 20 different AUR packages with this command:

xargs -a tobuild.txt aur sync --sign --upgrades --noconfirm --database="$reponame"

One required a GPG key import. (More on that below.) Other than that, all dependencies were resolved and all packages were built without errors. Of all the methods I tried for the last few days, this is the first one to work.

What I did is similar to what I was trying here:
aurutils: building in a chroot, signing packages, adding to local repo / Creating & Modifying Packages / Arch Linux Forums

xargs -a tobuild.txt aur sync --chroot --sign --upgrades --noconfirm --database="$reponame" --directory=/$CHROOT

In that case, I was taking the more usual approach to building in a chroot, but many packages were failing (usually due to dependency issues).

Due to not knowing how to solve those errors, I tried a different way to gain some experience; this alternate way worked with only minor issues.

I'd like to learn why the other method isn't working for me. I tried a lot of things, and I never resolved the issues with many packages. Ultimately, I prefer to do things the way most other people do them, so I'd like to learn what I was doing wrong in that approach.

Final note: I encountered two unusual issues in the current approach that I had to work around inside the chroot. First, this would not work:

gpg --recv-keys F4A7678C9C6B0B2B

So I did that outside the chroot, exported the key to a file, and then imported it from the file inside the chroot.

The second thing was the permissions I asked about in the OP. I ultimately had to do this hack:

sudo chmod -R 777 /var/lib/pacman/

I tried every method of fixing this, and I paid close attention to the permissions this time. Nothing worked. It's something unusual about working inside the chroot, I guess. But I have the chroot inside my private system and it is entirely in a RAM tmpfs, so as soon as I copy the built and signed packages, I can delete the chroot. (I have a script to recreate it when needed, and I was just doing this for testing.)

Last edited by MountainX (2020-10-21 06:29:41)

Offline

#6 2020-10-21 07:15:07

Awebb
Member
Registered: 2010-05-06
Posts: 6,275

Re: [SOLVED] possible to build AUR package while in chroot?

Is 777 right? Doesn't 755 for folders and 644 for files suffice?

Offline

#7 2020-10-21 19:40:34

MountainX
Member
Registered: 2016-02-08
Posts: 371

Re: [SOLVED] possible to build AUR package while in chroot?

Awebb wrote:

Is 777 right? Doesn't 755 for folders and 644 for files suffice?

No, 777 is almost never "right". Strangely, that's what was required here. My other option, which I may try today, is to change the ownership to "builduser". Neither is right or normal for this directory. So if anyone knows what's going on, please tell me. This is a chroot created with "pacstrap -i" and I am not booting it, just chrooting into it.

Offline

#8 2020-10-27 06:16:52

MountainX
Member
Registered: 2016-02-08
Posts: 371

Re: [SOLVED] possible to build AUR package while in chroot?

My question was: "Is it possible to build AUR package while in chroot?"
The answer is yes. Question solved.

I can build both AUR and custom packages in a chroot using either aurutils, extra-x86_64 from devtools, or even a chroot I create manually.

In the last few messages above I mentioned a strange permissions issue. I never got to the bottom of that, but I have not run into it again.

Last edited by MountainX (2020-10-27 06:17:18)

Offline

Board footer

Powered by FluxBB