# emerge osx-epic-fail
Gentoo Prefix Bootstrap Process for Mac OS X has a lengthy walkthrough on getting Gentoo’s emerge package management system installed onto a Mac OSX system. Naturally I had to give it a shot! I’ve never worked with Gentoo before so I really had no idea what to expect from emerge.
From a few conversations with a collegue I learned that I could very easily tailor the build process to my specific environment by customizing the make.conf file for emerge. Unlike some package management systems that either grab a generic binary for your platform, emerge will pull down the latest source code and compile it directly for your specific machine. If I recall correctly, the FreeBSD ports collection also works this way, as does Debian’s apt (although I’m not sure of the ability to modify machine-specific compile time flags with either system)
The install detailed in the walkthrough (see link above) is a bit sparse on background information such as why call emerge with the oneshot option. (still not sure about that myself, from the emerge man page: “Emerge as normal, but do not add the packages to the world profile for later updating”) Each of the build steps took a rather long time on the aging Mac G4 box and I unfortunately kept running into compile errors about 3/4ths of the way through the process. The process failed trying to compile Autom4te (an M4 replacement for autoconf) due to various reasons (one of which might be a missing perl library)
After stepping through the various stages of the install a couple of times and only getting marginal success, I decided the easiest route would be to script the install process so that I could re-run it at my leisure. I just grabbed the commands listed in the walkthrough and stuck them in a shell script (no error-checking or anything fancy) which would allow me to set a couple of variables and then re-run the script as often as needed. The script (and the author’s walkthrough) relies on another script called ‘bootstrap-prefix.sh’ (also available from the walkthrough site) so I created a directory called ‘emerge’ and therein placed both the ‘bootstrap-prefix.sh’ script and my own ’setup_gentoo_bootstrap_env.sh’ script.
I set my ‘EPREFIX’ variable to /usr/local/gentoo, so everytime the process would fail, I could just ‘rm -rf /usr/local/gentoo’ and start over. Since part of the process includes pulling down all the latest sources I figured that if I just waited a week, maybe someone would have found the issue and fixed it. But alas, as of this morning the process still fails in the same spot. So I’ll send a note to the maintainer and see what happens. Until that time I have to conclude that emerge on OSX constitutes the ‘epic-fail’ tag.
After all of this, I finally just grabbed the latest macports and within minutes I installed several standard software packages. Both macports and fink provide very easy access for OSX to most readily available linux software. However it does appear at the moment that macports has been getting more attention and is more supported (at least by comparing the verbage on each of their websites) and even though I’ve been a big fan of fink in the past, I went with macports if for no better reason other than its the one that I haven’t utilized before.
Code for setup_gentoo_bootstrap_env.sh located after the cut.
#!/bin/sh
export EPREFIX=/usr/local/gentoo
export PATH=”$EPREFIX/usr/bin:$EPREFIX/bin:$EPREFIX/tmp/usr/bin:$EPREFIX/tmp/bin:$PATH”./bootstrap-prefix.sh $EPREFIX tree
./bootstrap-prefix.sh $EPREFIX/tmp wget
./bootstrap-prefix.sh $EPREFIX/tmp tar
./bootstrap-prefix.sh $EPREFIX/tmp sed
./bootstrap-prefix.sh $EPREFIX/tmp python
./bootstrap-prefix.sh $EPREFIX/tmp gawk
./bootstrap-prefix.sh $EPREFIX/tmp findutils
./bootstrap-prefix.sh $EPREFIX portageexport LDFLAGS=”-Wl,-search_paths_first -L${EPREFIX}/usr/lib -L${EPREFIX}/lib”
export CPPFLAGS=”-I${EPREFIX}/usr/include”hash -r
emerge –oneshot sed
emerge –oneshot “<bash-3.2_p33″
emerge –oneshot –nodeps wgetemerge –oneshot coreutils
emerge –oneshot findutils
emerge –oneshot tar
emerge –oneshot grep
emerge –oneshot gawkenv FEATURES=”-collision-protect” emerge –oneshot portage
emerge –oneshot baselayout-prefix







April 3rd, 2008 at 7:43 pm
Debian apt can compile packages, but generally just gets the binary from the repository.
Testing has shown that, with the current state of optimization that the Intel processors are doing, it doesn’t make sense to compile for your specific post-586 flavor; some tests showed that it was faster to use a generic i686 binary than it was to compile a tuned one for your processor. (But of course I have no idea if that’s true on G4 or G5s - probably not.)
April 3rd, 2008 at 7:46 pm
Actually it was the subject of being able to specifically compile to the G4’s altivec options that made me curious about using emerge. On my intel-based macs I’ll easily just stick w/fink or macports!