Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Use crossdev to directly update other system's packages
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
M95D
Tux's lil' helper
Tux's lil' helper


Joined: 03 Jan 2020
Posts: 94

PostPosted: Fri Dec 01, 2023 11:05 am    Post subject: Use crossdev to directly update other system's packages Reply with quote

Hi.

I have a very low power devboard (RPi3 clone) and a normal desktop. I run Gentoo on the desktop and I also tried to run it on the devboard, but emerging packages is simply too slow and there's not enough RAM.
Gentoo on the devboard is installed on a micro-SD card.
Can I mount the SD card in some directory on the desktop (like /usr/<arch>) and use crossdev to update packages directly on the SD card without any binpkg or distcc?

Thanks.
Back to top
View user's profile Send private message
pingtoo
Veteran
Veteran


Joined: 10 Sep 2021
Posts: 1125
Location: Richmond Hill, Canada

PostPosted: Fri Dec 01, 2023 12:09 pm    Post subject: Reply with quote

M95D,

Quote:
mount the SD card in some directory on the desktop
Can you clarify what do you mean by "mount"? Do you mean over network?

It can certainly work, just follow the Gentoo chroot method either suggested in Gentoo Forums or Gentoo chroot. The only thing I would suggest is install app-emulation/qemu on your Desktop that will perform building. Sometimes packages have step require execution intermediate target binary in order to complete build.
Back to top
View user's profile Send private message
M95D
Tux's lil' helper
Tux's lil' helper


Joined: 03 Jan 2020
Posts: 94

PostPosted: Fri Dec 01, 2023 2:24 pm    Post subject: Reply with quote

No network mount. Turn off the devboard, take the card out, put it in the desktop's card reader, mount the card into some directory and run crossdev/emerge/something to directly update packages that are installed on the card and install new ones.

Chroot can't be used because the desktop machine is x86 and the devboard is arm. The desktop won't be able to run gcc or any other native binaries from the card without emulation. Qemu and emulations are slow. I would prefer to use crossdev or some other cross-toolchain to build packages directly from the host Gentoo system.

https://wiki.gentoo.org/wiki/Cross_build_environment describes how to build a base system. It doesn't say if the same commands (especially <arch>-emerge) can be used to update a system that was previously used (no longer "clean" - user added files, various packages installed, config files edited, defaults changed, etc.).

I can live with the fact that some packages can't be built on a x86 host. I want to be able to update at least the very large packages like llvm, gcc, libre/openoffice and firefox.
Back to top
View user's profile Send private message
pingtoo
Veteran
Veteran


Joined: 10 Sep 2021
Posts: 1125
Location: Richmond Hill, Canada

PostPosted: Fri Dec 01, 2023 2:59 pm    Post subject: Reply with quote

M95D,

Thanks for the clarification.

Just like /proc, /sys and /dev, chrossdev install everything in /usr/<arch> it can be bind-mounted into <chroot>/usr/<arch>.

Have a look of this gentoo wiki about cross container It is very out dated. but the concept is correct you can follow it in principle. You don't have to use container. Although personally I prefer container over chroot but this is matter of taste.

just a idea, may be you can just dump the SD as image (dd if=/dev/<sdcard> of=/path/to/sd-image bs=1M) mount the image and work on it. Once you are done, you re-image it back to SD.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54535
Location: 56N 3W

PostPosted: Fri Dec 01, 2023 4:42 pm    Post subject: Reply with quote

M95D,

Crossdev won't build everything.

Cross compiling requires a few changed lines in make.conf from native but otherwise, your idea works.
Crossdev will expect to build into /usr/<tuple>

Chroot works too ... sort of.
You need QEMU built with USE=static-user and host binfmt support.
Install the QEMU binary into the target root. It will emulate the target CPU to run arm code on the host.
As its register level hardware emulation, its slow, but you can use all of the hosts resources.

See Further Reading for your options and more details.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
M95D
Tux's lil' helper
Tux's lil' helper


Joined: 03 Jan 2020
Posts: 94

PostPosted: Fri Dec 01, 2023 7:48 pm    Post subject: Reply with quote

NeddySeagoon wrote:

Cross compiling requires a few changed lines in make.conf from native but otherwise, your idea works.
Crossdev will expect to build into /usr/<tuple>

So I'll mount the card root into /usr/armv7-unknown-.../
I already built the toolchain. What do I do with the files that are already there? Make a copy of them on the SD card?
Or mount the card first and run crossdev to create the toolchain after?

Except -mcpu and related gcc options, are there any other changes necessary in make.conf? Can I leave them like that when I move the card back to the devboard?
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54535
Location: 56N 3W

PostPosted: Fri Dec 01, 2023 9:06 pm    Post subject: Reply with quote

M95D,

/usr/<Target_CHOST>/ is your RPi3 clone host target root filesystem.
Copy its etc/portage make.conf somewhere safe because you need to read it later.

Mount you SD card filesystem tree rooted at /usr/<Target_CHOST>/

Compare its make.conf with the one you saved and make the adjustments required for cross compiling.

I use two make.conf files one called make.conf_native and the other, make.conf_cross, with a symbolic link called make.conf to choose between them.

When you call
Code:
<Target_CHOST>-emerge ...
the code will be installed straight to the SDCard.
You may want to set the cross make.conf to build in the hosts tmpfs to save wear and tear on the SDCard.

Cross compiling will not work for everything.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
M95D
Tux's lil' helper
Tux's lil' helper


Joined: 03 Jan 2020
Posts: 94

PostPosted: Tue Dec 05, 2023 4:38 pm    Post subject: Reply with quote

I tried. It worked, but for very few packages.
Worked: gcc, llvm
Didn't work: rust, all packages dependent on rust (such as librsvg), perl, nodejs (really dissapointed by this!).

Because of librsvg, I couldn't even get as far as having a working X.

I put the card back into the devboard and it will probably take a week to build nodejs.
Back to top
View user's profile Send private message
pingtoo
Veteran
Veteran


Joined: 10 Sep 2021
Posts: 1125
Location: Richmond Hill, Canada

PostPosted: Tue Dec 05, 2023 4:46 pm    Post subject: Reply with quote

I wonder what failed. :?

I can think of why for perl, it is because the perl build system require targeted mini-perl (or something alike) to complete. But not sure if other is similar.

Did you build QEMU with static-user? and setup binfmt? if you do then may be we can help to find out what else make the build fail.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54535
Location: 56N 3W

PostPosted: Tue Dec 05, 2023 4:54 pm    Post subject: Reply with quote

M95D,

Share a build log and your target system specs.

gcc knows to not bootstrap when cross compiling.
Perl is cross compiling hostile.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
ddavidson72
n00b
n00b


Joined: 29 Dec 2013
Posts: 11

PostPosted: Mon Aug 26, 2024 10:26 pm    Post subject: Reply with quote

Thank you people for this work. Based on what I am reading, I think am trying to accomplish the exact same objectives. I had the same problems, and I learned how to solve most of them from your posts here. Thanks again.

I am also following the instructions in the crossdev wiki. There seems to be the superceding article for the aforementioned crossdev build article, but I have also reviewed this one extensively. The crossdev wiki article I am reading is here:
https://wiki.gentoo.org/wiki/Crossdev

I think I almost have something working. The thing I am still confused about is how to manage the different and differing portage repositories and profiles among the 2 platforms. For example, it feels like I am juggling 3 repositories:

1. /var/db/repos/gentoo on the x86_64 workstation. I am using the workstation to cross compile arm64 packages and kernels, trying to leverage the workstation's multiprocessing power to save time.

2. /var/db/repos/gentoo repository on the microSD card. The microSD card is where I want to save the outputs of the cross compiled kernels and packages. I would be fine using this one exclusively for the microSD card, ensuring it's segmented from the workstation's repositories.

3. The recommended /var/db/repos/crossdev separate overlay repository, also on the x86_64 workstation, which is recommended from the crossdev article I mentioned earlier from the gentoo wiki. The wiki recommended using the "master = gentoo"

To save time, I wanted to try to start out with the arm64 stage3 archive already extracted on my microSD card's root file system. The stage3 archive for the arm64 platform has /etc/portage/make.profile, which is a symbolic link to:
../../var/db/repos/gentoo/profiles/default/linux/arm64/23.0/desktop

...which doesn't exist. This link points to nothing, because the stage3 archive doesn't contain the portage tree. So like I have done for many of my gentoo installations, I downloaded the latest portage tree, placing it into the microSD card at this path: /var/db/repos/gentoo (I renamed the directory "portage" to "gentoo").

That seems okay so far - when I get on the workstation this resolves to the path I would expect. If I mounted the microSD card root file system on /usr/aarch64-unknown-linux-gnu, the make.profile symbolic link ends up resolving to:
Code:

/usr/aarch64-unknown-linux-gnu/var/db/repos/gentoo/profiles/default/linux/arm64/23.0/desktop


Code:

/usr/aarch64-unknown-linux-gnu/etc/portage # ls -lah
total 52K
drwxr-xr-x  8 root root 4.0K Aug 26 13:43 .
drwxr-xr-x 40 root root 4.0K Aug 26 13:37 ..
drwxr-xr-x  2 root root 4.0K Aug 11 17:27 binrepos.conf
-rw-r--r--  1 root root  976 Aug 26 13:41 make.conf
-rw-r--r--  1 root root  976 Aug 26 13:41 make.conf.crossdev
-rw-r--r--  1 root root  709 Aug 26 13:41 make.conf.default
-rw-r--r--  1 root root  713 Aug 26 13:41 make.conf.pi
lrwxrwxrwx  1 root root   67 Aug 11 17:27 make.profile -> ../../var/db/repos/gentoo/profiles/default/linux/arm64/23.0/desktop
drwxr-xr-x  2 root root 4.0K Aug 11 17:55 package.accept_keywords
drwxr-xr-x  2 root root 4.0K Aug 26 13:34 package.license
drwxr-xr-x  2 root root 4.0K Aug 11 17:55 package.mask
drwxr-xr-x  2 root root 4.0K Aug 11 17:55 package.use
drwxr-xr-x  3 root root 4.0K Nov 27  2022 profile


The symbolic link seems to be valid and working okay. I can see the files in the profile directory.

Code:

ls ../../var/db/repos/gentoo/profiles/default/linux/arm64/23.0/desktop
eapi  gnome  parent  plasma  systemd


But when I run this command (as root):

PORTAGE_CONFIGROOT=/usr/aarch64-unknown-linux-gnu eselect profile list

All the expected targets show up in the list, but no link targets are selected in the output. If I pick one of the targets, what ends up happening, is, the symbolic link changes, instead resolving to the same repository path on the x86_64 workstation, not the microSD anymore. And I thought that this was the thing that the crossdev wiki was trying to guard against by suggesting to make a separate repository for the crossdev. For example, if I run this:

PORTAGE_CONFIGROOT=/usr/aarch64-unknown-linux-gnu eselect profile set 19

The crossdev environment links the profile to the local repository on the workstation now, instead of using the one on the microSD card, please notice that the symlink is now pointing up 4 directories instead of 2. Now the symlink points to:

Code:

../../../../var/db/repos/gentoo/profiles/default/linux/arm64/23.0/desktop/

instead of:
Code:

../../var/db/repos/gentoo/profiles/default/linux/arm64/23.0/desktop


Code:

root@workstation:/usr/aarch64-unknown-linux-gnu/etc/portage # PORTAGE_CONFIGROOT=/usr/aarch64-unknown-linux-gnu eselect profile set 19
root@workstation:/usr/aarch64-unknown-linux-gnu/etc/portage # ls -lah
total 52K
drwxr-xr-x  8 root root 4.0K Aug 26 14:13 .
drwxr-xr-x 40 root root 4.0K Aug 26 13:37 ..
drwxr-xr-x  2 root root 4.0K Aug 11 17:27 binrepos.conf
-rw-r--r--  1 root root  976 Aug 26 13:41 make.conf
-rw-r--r--  1 root root  976 Aug 26 13:41 make.conf.crossdev
-rw-r--r--  1 root root  709 Aug 26 13:41 make.conf.default
-rw-r--r--  1 root root  713 Aug 26 13:41 make.conf.pi
lrwxrwxrwx  1 root root   73 Aug 26 14:13 make.profile -> ../../../../var/db/repos/gentoo/profiles/default/linux/arm64/23.0/desktop
drwxr-xr-x  2 root root 4.0K Aug 11 17:55 package.accept_keywords
drwxr-xr-x  2 root root 4.0K Aug 26 13:34 package.license
drwxr-xr-x  2 root root 4.0K Aug 11 17:55 package.mask
drwxr-xr-x  2 root root 4.0K Aug 11 17:55 package.use
drwxr-xr-x  3 root root 4.0K Nov 27  2022 profile


This works- I can compile packages for that architecture and things seem to be working. Emerging packages seems to work for the most part. I know it was clearly stated that not everything is going to work. I am expecting to see issues. But it seems to be working.
The problem is - I think this is emerging packages using the local repository, from the workstation, the /var/db/repos/gentoo/profiles/default/linux/arm64/23.0/desktop, not the one from the sdcard, which should be /usr/aarch64-unknown-linux-gnu/var/db/repos/gentoo/profiles/default/linux/arm64/23.0/desktop.

And then the crossdev wiki suggests to make a separate repository for this, making a "masters = gentoo" for the crossdev repository configuration, but the same thing happens.

/etc/portage/repos.conf/crossdev.conf
Code:

[crossdev]
location = /var/db/repos/crossdev
priority = 10
masters = gentoo
auto-sync = no


If I use the crossdev repository, because there is no portage tree (I think because of the masters = gentoo parameter), the symlink actually points back to an amd64 target (and won't let me pick am arm64 target!).

I tried making the separate crossdev repository both ways, including using the eselect repository tool, and also tried manually creating it, and it was the same result. It makes a separate directory in /var/db/repos/crossdev, but the directory is mostly empty (except for the metadata, repo_name, etc) - there is no separate portage tree and there are no targets. So when I am trying to use this, the symbolic link seems to be broken, and it thus defaults to "amd64" instead.
So I think if I use this, it also still works (after I am somehow able to get past the same bug where I can only select amd64 targets) and again, it compiles packages, but I think it's using /var/db/repos/gentoo from the workstation again to do this, which I think is what the crossdev article strongly recommended against, and why it was strongly recommended to use a separate repository.

At the end of the day, what am I trying to do? This:

1. Cross compile arm64 packages and kernels, leverage my workstation to do this, save the outputs to the microSD card.
2. When I boot the microSD card on the SoC board, I want it to be able to know about that history. A "genlop -l" command should be able to accurately reveal which packages are installed.
3. I want to be able to install packages then from the SoC instance. If I am out in the world with my SoC and I want to do "emerge sync" and "emerge @world" then I want to still be able to do that if it's possible.
4. And then say there's something just too big to compile, like the same problem that M95D had, I want to be able to shutdown the SoC, move the microSD back to the workstation, sync the portage tree for that gentoo installation on that microSD card, thar SDcard from that device (not using the portage tree/repository on my workstation - I want that separated), and do a @world update if needed, again, updating the microSD card.

I am also using 2 versions of make.conf, as it was recommended (thanks again NeddySeagoon). One version of the file is being used when the microSD is mounted on the workstation build system, and the other version is used when it's being used on the SoC board.

make.conf using on the microSD when cross compiling on the workstation:
Code:

CHOST=aarch64-unknown-linux-gnu
CBUILD=x86_64-pc-linux-gnu

ROOT=/usr/${CHOST}/

ACCEPT_KEYWORDS="${ARCH} ~${ARCH}"

#USE="${ARCH}"
USE="alsa bdplus bluray btrfs cdr dvd iproute2 ipv6 kde mp3 mp4 mpeg mysql mysqli ncurses network ogg opengl openh264 plasma png pulseaudio python qt5 snmp speex spell ssl syslog theora truetype unicode usb v4l v4l2 vim-syntax vorbis vulkan wayland -gtk -gnome"

CFLAGS="-O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

FEATURES="-collision-protect sandbox buildpkg noman noinfo nodoc"
# Be sure we dont overwrite pkgs from another repo..
PKGDIR=${ROOT}var/cache/binpkgs/
#PORTAGE_TMPDIR=${ROOT}tmp/
PORTAGE_TMPDIR=/tmp/

VIDEO_CARDS="v3d vc4"

PKG_CONFIG_PATH="${ROOT}usr/lib/pkgconfig/"


make.conf when executing on the SoC:
Code:

CHOST=aarch64-unknown-linux-gnu

#USE="${ARCH}"
USE="alsa bdplus bluray btrfs cdr dvd iproute2 ipv6 kde mp3 mp4 mpeg mysql mysqli ncurses network ogg opengl openh264 plasma png pulseaudio python qt5 snmp speex spell ssl syslog theora truetype unicode usb v4l v4l2 vim-syntax vorbis vulkan wayland -gtk -gnome"

CFLAGS="-O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}"

FEATURES="-collision-protect sandbox buildpkg noman noinfo nodoc"

VIDEO_CARDS="v3d vc4"


Again, mainly, I want to protect the /var/db/repos/gentoo on my workstation, but I want to also be able to manage and upgrade the /var/db/repos/gentoo on the microSD card using the workstation's crossdev tools, while segmenting it so there's no corruption to the repository on my workstation.

Thanks again for your thoughts and feedback.
Back to top
View user's profile Send private message
pingtoo
Veteran
Veteran


Joined: 10 Sep 2021
Posts: 1125
Location: Richmond Hill, Canada

PostPosted: Tue Aug 27, 2024 12:19 am    Post subject: Reply with quote

ddavidson72,

I think you are almost there but may be miss a little bit when you execute emerge command.

Please have a look at the script I posted It seems to be same as your steps but may be my script step order can give you some insight.

As the post stated, I did not complete test it. so let me know if you run into problem. we can try to work out the detail.
Back to top
View user's profile Send private message
ddavidson72
n00b
n00b


Joined: 29 Dec 2013
Posts: 11

PostPosted: Wed Aug 28, 2024 3:33 am    Post subject: Reply with quote

pingtoo wrote:
ddavidson72,

I think you are almost there but may be miss a little bit when you execute emerge command.

Please have a look at the script I posted It seems to be same as your steps but may be my script step order can give you some insight.

As the post stated, I did not complete test it. so let me know if you run into problem. we can try to work out the detail.


Hi Pingtoo,

Thank you for sharing the forum article and the script! I learned a few new things from your script.
You taught me a few new things, but I think you also reminded me something I was thinking about, and I was on the right track, and I think this idea you gave me is going to get me on track.

I noticed the repository being mounted using the "bind" operation option:
Code:

mount --bind /var/db/repos/gentoo $CHROOT/var/db/repos/gentoo


The MAN page describes this as making part of a file hierarchy so it's available somewhere else:

Code:

   Bind mount operation
       Remount part of the file hierarchy somewhere else. The call is:
          mount --bind olddir newdir


And so I think the same thing is happening here: the cross compiler, and probably even using the QEMU emulation to chroot into the environment, when compiling packages, it's using the originating directory for the repository, which in this case, is /var/db/repos/gentoo. This is the default repository for the default portage tree on a typical gentoo installation.

I think the crossdev article is recommending to set up a separate repository for the crossdev environment exclusively, as to guard against potential corruption being introduced to the local repository and installed packages database on the local system.

When I was working on this problem, I was thinking, I could "cheat" and use a symbolic link for the crossdev repository, and then the symlink could point to the repository for the target that is being built. While I think the "bind" option is much cleaner, I am starting to think it will have the same effect again- it still forces me to account for 3 repositories: 1 for the workstation host, 1 for the crossdev env, and one for the target SoC.

Side note- I think the original user in the other forum article is having the same problem:

Code:

gentoo / # eselect profile show
Current /etc/portage/make.profile symlink:
!!! Error: get_repos failed


This is telling me that the user is pretty much having the same issue: how to manage the symlink in the target, which repository it should point to, etc. Like I was thinking about in my last post, the stage3 doesn't have a portage tree- that's a separate thing (easy to add, like I did). Maybe this person has not aimed the link at a repository.

But then, after that, that user will be faced again with the same issue you and I are facing: how do we leverage that using crossdev? Crossdev always seems to want to use the local repository, hence the "../../../../var/db/repos/<repo-name>" for its automatic creation of the make.profile symbolic link, again, pointing back to the real workstation file system, not the one on the SoC.

So then I was thinking about just making a completely separate repository for crossdev, and use a separate portage tree, but it feels like the system will still end up using the same portage tree anyway, because it will always be a higher priority than the default:

From: https://wiki.gentoo.org/wiki/Ebuild_repository#Installing_packages_from_other_repositories (at the time of this post):
Code:

If the latest version of a package is available from more than one ebuild repository, the repository with the highest priority will be used. The priority can be set for an ebuild repository in /etc/portage/repos.conf. The Gentoo ebuild repository has a default priority set to -1000, and the default if a priority is not set for a repository is 0. If several ebuild repositories have the same priority (such as two or more not having any priority set, so having priority 0), the order is undetermined - a package to install will be selected arbitrarily.


So it feels like, anyway I it gets sliced and diced, it ends up using the same tree, and for all 3 systems:
1. The cross dev repository gets a higher priority (as per the recommendations crossdev wiki). This means packages found in crossdev will take precedence. So when I do emerge something on the local workstation, not using the crossdev compiler, it will still opt for the crossdev repo because of the higher priority (higher than the default -1000). If masters = gentoo and sync = no is set, I am thinking it's going to use the default portage tree, not a separate one.

2. When specifying the crossdev repo using the crossdev compiler, it will still use the same repository: the crossdev.

3. When I chroot the SoC, say for example using arch-chroot, and I am using the "bind" mount option, I am also using the same repo again, and thus, the same portage tree.

I found the -oO option in the gentoo wiki- this seems to allow you to select the repo just for the command, but it doesn't seem to work on the "eselect set" command.

Maybe that makes it easier to manage: maybe you can use any portage tree, as long as it's current (up to date).

So I am starting to think that the thing that we should be guarding against, maybe it's not portage tree corruption, but maybe package database / package installation corruption instead.

I guess the other thing I was concerned about, was the ""-collision-protect" option in the make.conf. Again, my main concern is guarding against package and repository corruption, and I am starting to think it might be a smart idea to remove this.

Code:

FEATURES="-collision-protect [output omitted]...


What are your thoughts?

I am just going to try to build the @system and see how it goes. I will write back with more status.

Thanks again for the script, ideas, your thoughts and feedback! :)
Back to top
View user's profile Send private message
pingtoo
Veteran
Veteran


Joined: 10 Sep 2021
Posts: 1125
Location: Richmond Hill, Canada

PostPosted: Wed Aug 28, 2024 3:11 pm    Post subject: Reply with quote

ddavidson72,

Thank you very much for your detail information. Very much appreciated.

I think we may not sharing same concept (or at least some detail not same)

I think you use "repository" for two different entities. One is Portage's repo structure for crossdev, the other is Gentoo's repo (a.k.a portage snapshot) which is Gentoo developer sharing ebuild for what is know as Gentoo system.

And then there is PORTAGE_CONFIGROOT which from your post seems to link (associate) it with portage snapshot in some way I am not sure.

So I will clarify what is in my posted script and hopefully this will help our communication. I will have some very obviously Gentoo concept in my description so please bear with me, it is intent to make sure I share my point of view so it will not be assumed.

In my script, there are three entities, The host (X86 Gentoo), the crossdev construct and CHROOT construct (where target platform binary reside)

Each for of three entities have its own Gentoo Portage environment (which have its own etc/portage/*)

The idea in my script is using the CHROOT as location to store target platform environment it is not meant to be use for building unless there is some need to execute target native binary during package build process.

Primary we want to use crossdev toolchain to build, because it is running Host native binary so it will be much faster compare to the QEMU emulated environment.

So the script try to make crossdev environment as close as CHROOT environment, however let the crossdev-emerge put the build result into CHROOT instead the default /usr/<crossdev-taget/

Why crossdev environment need to close to CHROOT because crosdev-emerge use information in /usr/<crossdev-target/etc/portage/* for build options but use CHROOT/var/lib/portage and CHROOT/var/db/pkg for install related decision

I am not sure I understand your concern of "corruption". The Portage tree used during emerge is read-only there will not be anything introduce into Portage tree no matter which of the those three environment.

You may have notice I use "snapshot" refer to Portage tree. This is because you don't need to make three environments share same "version". As you know Gentoo is a rolling system, every day Gentoo change a little bit. So the idea is take a snapshot of the rolling changes so it will be fixated of that moment and you build process now can cross several days without worry about chasing Gentoo's changes.

my script bind mount var/db/repos/gentoo and var/cache/distfiles is because my practice. I don't update my gentoo system. I only rebuild entire system when I upgrade (the upgrade usually involve hardware changes). So my portage tree always fixed on the initial build process day. That way my system is always consist. if later I have miner requrement changes and simple targeted emerge run into problem then it usually mean that portage snapshot have a bug. I will either patch it myself or find a near future snapshot that resolve my issue and stay there.

As using symbolic link, I also try this trick in early day of learning, but later I found it is too big of effort try to keep it working as thing change, so I abandoned the idea.

A little explain for my early paragraph about "repository" and "construct". A Portage "construct" consist few parts,
- etc/portage/*
- var/db/pkg/*
- var/db/repos/*
- var/lib/portage/*
- var/cache/{binpkgs,distfiles}
I have left out some other part for portage because they are not related in this conversation.

The crossdev only have etc/portage/* because by design it is not expecting something install in to crossdev environment.

The CHROOT usually don't need var/db/repos/* because we don't expect to build anything in there. but in when package build process require target native execution you going to need to build that package in the CHROOT therefor just setup ahead in case this need happen.

The Host (Gentoo) have set of Portage "construct" for its own maintenance, then there is another set for crossdev. because it is the Host that maintain crossdev integrity so it need to have a var/db/repos/crossdev to isolate another set of compiler tool chain. So to not pollute Host compiler tool chain.

I am not sure I cover everything because I kind lost my thoughts, English is not my first language, it take a toll on me when I try to put together ideas in words and at same time I need to find the right "word" and right sentences. So let me know if I created something confusing and I will try to explain where I can.
Back to top
View user's profile Send private message
ddavidson72
n00b
n00b


Joined: 29 Dec 2013
Posts: 11

PostPosted: Thu Aug 29, 2024 1:27 pm    Post subject: Reply with quote

Hello again Pingtoo,

Thank you also for sharing more information and more context.

Yes, I think we're still on the same sheet of music and trying to accomplish very similar objectives. I think we're going about it almost the same way, and I also noticed that your script isn't really using the actual binary qemu chroot, but you're right, just setting up the construct. I noticed that qemu-aarch64 was being copied, but I don't think it's being executed as part of your script, is it? And then I can see the binfmt service is being used, and I was needing to start that in order to chroot using qemu binaries. But for this, I don't think we're doing that yet, and I think I'm trying to do something very similar like you are trying. Like everybody has mentioned, the qemu chroot is very slow, and I think we're trying to find something a little more optimal and scalable. Maybe the minor difference here is that you like to use your process to do just fresh, up-to-date releases/builds, where my goals are a little different and I want to do some incremental updates. It feels like it's the same thing though, especially starting off with a fresh build- I have the same 3 things I am juggling, like your setup:
1. I have the x86_64 that I am running and then installing the crossdev package on that to cross-compile.
2. I have the crossdev construct. I am using it to emerge packages and cross-compile kernel images for the SoC.
3. I also have the SoC construct. Like it was mentioned here, I was going to keep this on the microSD card and mount it on /usr/aarch64-unknown-linux-gnu/, but I was also just working with it in a directory, like you were also doing with your /choot directory, but I wasn't mounting the other mount points /proc, /sys, /dev, etc. That seems to work okay too- I can compile packages.

I think there still is "building" going on because the "emerge-aarch64-unknown-linux-gnu" command is still going to "build" binaries for the other arch, and thus "building" (compiling) is still taking place in both our environments. That's also the Gentoo way, right?! :)

Yes, you're right, I was being very ambiguous about referring the the portage snapshot, and using this synonymous with the portage tree, the repository, etc. I was thinking about this later, and remembered that the make.profile really doesn't point at the portage ebuilds, but to the profile for that arch. And I think you're right- it should be read only. But profiles are nested in the tree, and the symbolic link for the make.profile usually resolves to something in the tree.

So I think we're totally on the same sheet of music.

For the corruption concerns, I was a little concerned about the corruption because of what I read on the gentoo wiki page for crossdev-

from: https://wiki.gentoo.org/wiki/Crossdev (at the time of this post) - there is this warning under the "Crossdev Overlay" heading:
Code:

Warning
Improperly using crossdev may "pollute" ebuild repositories: crossdev operates by adding packages to an ebuild repository, so care must be taken to ensure crossdev adds packages to a separate repository. Follow one of the creation methods below to create a separate repository for crossdev.


and:
Code:

If the Gentoo ebuild repository is synchronized using Git, or any other method with Manifest files that do not include checksums for ebuilds, prevent "masked by: corruption" errors with:
FILE /var/db/repos/crossdev/metadata/layout.conf

masters = gentoo
thin-manifests = true


The thing I am most concerned with is taking care not to hose up the x86 system when I'm trying to use it to build the construct for the SoC.

I think your English is great, keep it up, and thanks for it.
Back to top
View user's profile Send private message
pingtoo
Veteran
Veteran


Joined: 10 Sep 2021
Posts: 1125
Location: Richmond Hill, Canada

PostPosted: Thu Aug 29, 2024 2:14 pm    Post subject: Reply with quote

ddavidson72,

Thank you very much!

As long as you are comfortable with that script and you understand what it is doing you are good as gold.

The "script" is really not mine per se. it is target for the topic poster. it use qemu and crossdev because the thread OP want to do it that way. So first part of script was trying to setup a CHROOT, second part is to configure crossdev to make sure it match target setup. Having CHROOT environment ready is for case where build want to use target native binary as part of build process then the package will have to utilize qemu for a slow build, but the script make it ready, so it is easiler to switch between crossdev or chroot build.

I come up that script is because I am in middle of design my catalyst stage4 build process, so I was study catalyst code and found the code logic match the topic poster to large degree. so I manage to write down each step. it more of extract of execution logs.

Good luck with you journey with RPI :).
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum