Dream of Engineerings (en)

The tech blog written by yuya_presto

Installing Gentoo Prefix with Xcode 4.3.1

I think it may be odd to write first article which theme is Gentoo... which is special situation.

My new MacBook Air has essential *nix shell environment, which is preinstalled. :) I also installed "homebrew" to retrive more benefit of shell environment. But there is also problems. Some of commands (like readlink -f) behave differently from Linux's one. And there are less package (called formula in homebrew) than popular linux distros, I felt.

Finally I decided to remove homebrew and to install Gentoo Linux (the Linux distro which is small footprint, also fully customizable by modern package manager, like ports) on my MacBook AIr.

There are two ways to install on mac:

  1. Install real Linux (from kernel to elf binary) on VM or BootCamp
    • +: More packages
    • +: Easy to install
    • +: Seperated filesystem (Safer)
    • +: Customizable kernel
    • -: Requires >=1G RAM assignment for VM (Reffer this post)
    • -: Cannot use any OS X functions (like commands, guis)
  2. Install "Gentoo Prefix" (which compiles binaries for darwin (os x) kernel)
    • +: Small foot print (no constant RAM)
    • +: Unified shell environment (both OS X and Linux)
    • -: Less tested
    • -: Complex installation procedure (without stage3 tarball)

VM would use 1/4 of my RAM all the time... Finally I decided to use Gentoo Prefix.

To install Gentoo Prefix on OS X, refer installation document and go on with the procedure. But in my case, some problem occured. I'll show problem/solution below.

Problem 1:
Installing binutils-apple package fails with latest Xcode (4.3.1). Prebuilt "bootstrap" environment lacks of newer binutils-apple package (*.ebuild) which is in the current prefixed portage tree.
In addition, doing "emerge --sync" first caused some other emergings failed.

Solution 1:
Sync your repo partially before emerge.

$ rsync -avz rsync://rsync.gentoo.org/gentoo-portage/sys-devel/binutils-apple/ ~/gentoo/usr/portage/sys-devel/binutils-apple
$ rsync -avz rsync://rsync.gentoo.org/gentoo-portage/metadata/cache/sys-devel/binutils-apple-4.3 ~/gentoo/usr/portage/sys-devel/binutils-apple-4.3

Problem 2:
Installing portage package failes circular dependencies with gettext package.

dev-vcs/git-, ebuild scheduled for merge) depends on
 (dev-lang/python-2.7.2-r3::gentoo, ebuild scheduled for merge) (buildtime)
  (virtual/libintl-0::gentoo, ebuild scheduled for merge) (buildtime)
   (sys-devel/gettext-, ebuild scheduled for merge) (runtime)
    (dev-vcs/git-, ebuild scheduled for merge) (runtime)

It might be possible to break this cycle
by applying any of the following changes:
- sys-devel/gettext- (Change USE: -git)
- dev-vcs/git- (Change USE: -python)

Solution 2:
Installing gettext without git support at first with below command. Then install portage.
(* Maybe it is better to emerge portage with --nodeps flag to solve this, not tested.) 

$ USE=-git emerge -1 gettext

I added "-march=core2" to CFLAGS in make.conf, to optimize for MacBook Air Mid 2011.
(* corei7 and corei7-avx is not available on gcc 4.2.1)

I created script to complete PREPARATION for prefix installation.
Please test, and leave comment to fix :)

(2012/04/15: Fixed Xcode version was wrong (was 3.1, 4.3.1 is correct). gist code not working correctly and I'll fix lator.)