Saturday, September 30, 2017

Understanding inner workings of crossdev.


The crossdev executable is going to install a toolchain in your host machine for a foreign architecture as regular ebuilds. The root of this foreign architecture (RF) will be placed in /usr/ where is in the same syntax as the -t switch to crossdev.
Now question is, where do you get the ebuild of the toolchain for the foreign architecture? crossdev creates a separate overlay (the directory of the overlay must be added to PORTDIR_OVERLAY in make.conf of the host machine) which contains packages within a newly created category (in that overlay) named ; the packages (belonging to the toolchain) in this overlay are basically symlinks to certain directories (belonging to the toolchain) on the host system. These packages within category only contains the essential components of the toolchain and are merged just like any other package. The result of the installation is that the toolchain for the foreign architecture is installed with the prefix (-); emerge is also installed in the same way.
As said before these executables (including emerge) operate assuming RF as the root dir. All configuration in RF will be respected by these commands which includes make.conf, package.use, package.keyword etc... this includes the overlays, but it appears that the gentoo portage tree of the host is always searched. Don't understand why, or the mechanism.
Executing this crossdev with the switches will start building the toolchain using the emerge command itself (unless you've passed some switches which present it from doing so).
These packages will populate a few things in /usr/.
After these have been build, you can either build @system thus create the installation from scratch without a stage3; however I dont think this'll work, so I would say you extract a stage 3 in /usr/ without overwriting the make.conf in it since it's a special make.conf which works with the toolchain command as installed on the host; however this make.conf is underoptimized, so I would say you merge both the make.conf with the crossdev specific parts commented out when actually running the system and when using crossdev, you toggle the crossdev parts.
crossdev will also make a make.profile but unfortunately it's symlinked to the wrong profile, overwrite it with the one in the stage3 tarballs and change it to your preferred profile.
Whatever change you do, remember that running crossdev again will overwrite those, so 1) back them up and 2) never run crossdev again. Upgrade these packages using your host's PM.
As of using eix in RF, use EIX_PREFIX= for that.

No comments:

Post a Comment