Gentoo: Converting no-multilib to multilib

So it’s said that it’s not possible. Not supported perhaps, but definitely possible. Writing this here for reference, it’s also not supported in any way seeing that I’m not even close to what can even remotely be considered an expert in the field. I just figured someone else will run into the same situation, and might find this useful as a base to work from.


Strategy
Well, the reason why “it’s not possible” is because your toolchain is broken. Not really, but there are requirements and either you need to go building a cross-toolchain using crossdev, or you need to obtain the required toolchain in some other way. Frankly, the thought of going through crossdev is an interesting one, but there exists a simpler strategy. Compiling the toolchain on the box itself fails. Note, compiling, not portage failures. This means that we are likely able to install binary packages, and this is the crucial clue.

In the case where a multilib machine is available, just create binary packages there, otherwise, follow instructions below.

chroot environment

Well, the normal strategy is a re-install. We’re going to cheat, we’re going to somewhat install a new system, then build binary packages and just use those. So download a stage3 AMD64 stage tarball. I then did this (for obvious reasons as root):

mkdir /home/multilib
tar xvpf /path/to/stage3-amd64-??.tar.bz2 -C /home/multilib
mkdir /home/multilib/usr/portage
for i in usr/portage dev sys proc; do
    # Changed to use --rbind from --bind - as per the manpage this
    # mounts sub-mounts too, incl. /dev/shm which has recently become a problem.
    mount --rbind /$i /home/multilib/$i
done
cp /etc/resolv.conf /home/multilib/etc/
cp /etc/make.conf /home/multilib/etc/
mkdir /home/multilib/etc/portage
cp /etc/portage/package.* /home/multilib/etc/portage/
chroot /home/multilib

Updating portage

Probably not required, but I want portage inside of and outside of my root to be the same to reduce the risk of things going wrong:

emerge -uav portage

At this point, also double check that you’ve got a sane profile selected, I just use the base one:

tiny ~ # eselect profile list
Available profile symlink targets:
  [1]   default/linux/amd64/10.0 *
  [2]   default/linux/amd64/10.0/desktop
  [3]   default/linux/amd64/10.0/desktop/gnome
  [4]   default/linux/amd64/10.0/desktop/kde
  [5]   default/linux/amd64/10.0/developer
  [6]   default/linux/amd64/10.0/no-multilib
  [7]   default/linux/amd64/10.0/server
  [8]   hardened/linux/amd64/10.0
  [9]   hardened/linux/amd64/10.0/no-multilib
  [10]  selinux/2007.0/amd64
  [11]  selinux/2007.0/amd64/hardened
  [12]  selinux/v2refpolicy/amd64
  [13]  selinux/v2refpolicy/amd64/desktop
  [14]  selinux/v2refpolicy/amd64/developer
  [15]  selinux/v2refpolicy/amd64/hardened
  [16]  selinux/v2refpolicy/amd64/server
tiny ~ #

Updating the toolchain

The question here really is what’s all part of the toolchain. This is a valid question, and frankly I’m not an expert. The easy way is to just make binary packages of the entire default system, you probably want to recompile most of your libraries etc anyway, so we can just as well do this inside the chroot and use the binary packages outside. So by wasting some extra cycles we make this easy:

emerge -euav --buildpkg system

After a while you’ll be prompted to recompile everything in the stage tarball, probably most things will be upgraded anyway (probably). I’m not a fan of wasting CPU cycles for the heck of it, however, I’ve got other things I need to be busy with. So I’ll just burn the CPU in the background and be done with it for now.

Returning to the no-multilib system

Right, now we switch the profile:

eselect profile set default/linux/amd64/10.0

And now we remerge system (remember the binary packages was created in a bind mounted /usr/portage so there is no need to copy things around).

emerge -euavk1 system

Before saying yes, make sure that anything that looks critical says “binary” and not “ebuild”. On my system everything was labeled binary so I just proceeded.

world

Whether or not world needs to be rebuild or not I do not know. I’m not going to waste that number of cycles at the moment, but if/when time permits and you’d rather be on the “save” side, you’re welcome to remerge world with:

emerge -1euakv world

This will include system, but for system it will use the binary packages if they are still applicable, meaning it won’t waste as much time (especially on things like glibc which can take a while to compile).

I can confirm working by having merged wine after this, and actually starting up winbox.

8 thoughts on “Gentoo: Converting no-multilib to multilib

  1. This btw, should be listed in the official documentations on how to convert non-multilib to multilib. It was painless, straight forward, easy to understand and worked like a charm. Thanks.

  2. Yea well. Officially you shouldn’t make mistakes that requires this kind of trickery :). But then again – I’ve never re-installed a Gentoo box – EVER. Other than stolen laptops and completely buggered hardware.

  3. Going back and forth from multilib to no-multilib shouldn’t be considered a mistake nor require trickery – and in fact I don’t consider what you suggested here trickery, it’s actually a very clever solution.
    I just bookmarked this page and will give it a try this evening.
    You should consider adding this to the gentoo wiki :)

  4. Worked like a charm, as expected.
    Just a few other useful tips:
    – Avoid using /dev/shm as temp folder for portage, both in the chroot and in the main system, as it may run short when using buildpkg and create an unecessary mess
    – I rebooted (just to unmount everything) and deleted the binary packages before rebuilding world. Takes a bigger while, but satisfies my paranoia

  5. After setting CONFIG_IA32_EMULATION in my kernel config, which of course is necessary, it worked like a charm.
    Being a clean and easy solution this really should be on gentoo-wiki

Leave a Reply

Email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Spam Protection by WP-SpamFree