How to install Gentoo emerge on a non-Gentoo Distribution of Linux

The Linux distribution, Gentoo Linux, uses a program called emerge to manage its packages. Emerge uses portage to install and manage its software, similar to BSD. Portage installs software by compiling from source instead of installing the binary. This allows the software to be optimized to your system, while most distributions use general binary packages. Through this HowTo you will be able to use emerge to update your entire system.

Requirements

 * 1) Computer with Linux
 * 2) Gentoo Stages tar balls, downloaded from the ftp://distro.ibiblio.org/pub/linux/distributions/gentoo/releases/x86/current/stages/
 * 3) Software: tar, bz2, binutils (you should already have these installed)
 * 4) Working version of gcc, It may be a good idea to have a version of gcc installed in a place other than /usr or /usr/local

Steps

 * Preamble: This HowTo is not an easy task, it requires a significant amount of knowledge in Linux. These steps will most likely NOT be replicatable, word for word, and will require a good knowlege of your system. It would be significantly easier to install Gentoo Linux from scratch.


 * 1) Make Directories:
 * ''mkdir -p /usr/lib/portage/bin
 * mkdir -p /usr/lib/portage/pym
 * mkdir -p /usr/portage/profiles
 * mkdir -p /usr/local/portage
 * mkdir -p /etc/env.d
 * mkdir -p /etc/portage/profile
 * mkdir -p /var/log/portage
 * mkdir -p /var/tmp/portage
 * mkdir -p /etc/config-archive
 * mkdir -p /var/lib/init.d
 * mkdir -p /var/lib/portage
 * mkdir -p /usr/man/man1
 * mkdir -p /usr/man/man5
 * mkdir -p /usr/portage/sys-apps/portage/files ''
 * 1)  Download gentoo stages 1, 2, and 3 into an empty folder
 * ftp://distro.ibiblio.org/pub/linux/distributions/gentoo/releases/x86/current/stages/ 
 * stage 1 is in x86, you can download stages 2 and 3 for your specific processor
 * 1) Untar all stages in the folder created. See: HowTo: Untar
 * 2) Copy usr/lib/portage to /usr/lib/portage.
 * 3)  Untar portage-x.x.x & copy portage to /usr/portage
 * 4)  Create a symbolic links to the portage bin directory by executing
 * ln -s /usr/lib/portage/bin/* /usr/bin/


 * ln -s /usr/lib/portage/bin/* /usr/sbin/
 * 1)  Edit /etc/passwd and add
 * 'portage:x:250:250:portage:var/tmp/portage:/bin/false'
 * 1)  Edit /etc/group and add portage::250:portage
 * 2)  Copy /usr/lib/portage/pym/* to /usr/lib/python2.x/site-packages
 * 3)  edit/create file  '/etc/env.d/10ldpath' and add all you library directories in the file /etc/ld.so.conf
 * LDPATH=/usr/kerberos/lib:/usr/X11R6/lib:/usr/lib/qt-3.1/lib:/usr/local/lib/:/usr/lib/sane:/usr/lib
 * 1)  edit/create file /etc/env.d/05gcc and enter the following with the location to you gcc
 * ROOTPATH="/usr/local/gcc-3.4.4/"
 * MANPATH="/usr/local/gcc-3.4.4/man"
 * INFOPATH="/usr/local/gcc-3.4.4/info"
 * CC="gcc"
 * CXX="g++"
 * LDPATH="/usr/local/gcc-3.4.4/lib"
 * 1)  edit/create the file /etc/env.d/compiler and add these lines:
 * CC=gcc
 * CXX=g++
 * 1)  Exicute emerge sync
 * 2)  edit/create /etc/portage/profile/package.provided and add the following
 * sys-apps/baselayout
 * sys-fs/devfsd
 * sys-kernel/linux-headers
 * sys-libs/pwdb
 * sys-libs/pam
 * sys-libs/pam-login
 * gnome-base/gdm
 * sys-apps/kbd
 * sys-devel/bin86
 * sys-devel/binutils
 * net-misc/iputils
 * sys-apps/shadow
 * net-misc/dhcpcd
 * sys-apps/slocate
 * sys-apps/modutils
 * sys-libs/glibc
 * sys-devel/gcc
 * sys-libs/ncurses
 * app-crypt/hashalot
 * sys-apps/cronbase
 * x11-base/opengl-update
 * net-nds/openldap
 * net-mail/mailbase
 * net-www/epiphany
 * net-nds/portmap
 * net-fs/samba
 * net-misc/openssh
 * dev-lang/python
 * sys-fs/e2fsprogs
 * 1)  emerge -f baselayout
 * 2)  untar /usr/portage/distfiles/baselayout*.tar.bz2 (aka rcscripts)
 * 3)  cd {rcscripts}/sbin; cp depscan.sh /sbin; cp functions.sh /sbin
 * 4)  ln -s /sbin/functions.sh /etc/init.d;  ln -s /sbin/depscan.sh /etc/init.d
 * This step cures these errors
 * /usr/portage/eclass/eutils.eclass: einfo: command not found
 * /usr/portage/eclass/eutils.eclass: eend: command not found
 * 1)  mkdir -p /lib/rcscripts/awk;  cd {rcscripts}/awk;  cp *.awk /lib/rcscripts/awk/
 * 2)  ln -s /usr/local/bin/gcc /usr/bin; ln -s /usr/local/bin/g++ /usr/bin
 * Cures the make: gcc: Command not found
 * 1)  emerge gawk
 * 2)  emerge portage
 * 3)  emerge sandbox
 * solves !!! Problem with sandbox binary. Disabling... 
 * 1) At this point emerge should work.  You may have to manually edit some config files.  If a package does not install and the solution is in Common Errors. install the package from source manually with ./configure --prefix=/usr, if the  package still will not install, add the packages exact name to /etc/portage/profile/package.provided, and this will tell emerge that that package is installed manually and accept that this dependency is fulfilled.  See: HowTo: Install a program from source.

Common Errors
configure.in:5: but the definition used by this AM_INIT_AUTOMAKE configure.in:5: comes from Automake 1.6.3. You should recreate configure.in:5: aclocal.m4 with aclocal and run automake again.'' rm -f /etc/make.profile x86: # ln -sf /usr/portage/profiles/selinux/2007.0/x86 /etc/make.profile x86 (hardened): # ln -sf /usr/portage/profiles/selinux/2007.0/x86/hardened /etc/make.profile AMD64: # ln -sf /usr/portage/profiles/selinux/2007.0/amd64 /etc/make.profile AMD64 (hardened): # ln -sf /usr/portage/profiles/selinux/2007.0/amd64/hardened /etc/make.profile
 * Error: !!! Problem with sandbox binary. Disabling... 
 * Solution:
 * emerge sandbox
 * Error: 
 * make: gcc: Command not found
 * Solution: 
 * ln -s /usr/local/bin/gcc /usr/bin; ln -s /usr/local/bin/g++ /usr/bin
 * Error:
 * ''/usr/portage/eclass/eutils.eclass: einfo: command not found
 * /usr/portage/eclass/eutils.eclass: eend: command not found''
 * Solution:
 * ln -s /sbin/functions.sh /etc/init.d; ln -s /sbin/depscan.sh /etc/init.d
 * Error: Package will not install
 * Solution: Install the package from source manually with ./configure --prefix=/usr, if the package still will not install, add the packages exact name to /etc/portage/profile/package.provided, and this will tell emerge that that package is installed manually and accept that this dependency is fulfilled
 * Error: ''configure.in:5: version mismatch. This is Automake 1.7.9,
 * Solution: Reinstalling the old version of Automake sometimes helps, but not always
 * Error: Symlinking make.profile
 * Solution

USE="3dnow acpi dedicated ethereal faad ffmpeg firebird freetype gtkhtml \    apache2 xsl mysql mng openssh tiff -arts -kde -qt eds gd dba" CHOST="i686-pc-linux-gnu" CFLAGS="-march=athlon-xp -Os -pipe -fstack-protector" CXXFLAGS="${CFLAGS}" ACCEPT_KEYWORDS="x86" PORTAGE_TMPDIR="/var/tmp" PORTDIR="/usr/portage" DISTDIR="${PORTDIR}/distfiles" PKGDIR="${PORTDIR}/packages" MAKEOPTS="-j2" AUTOCLEAN="yes" FEATURES="sandbox ccache" GENTOO_MIRRORS="ftp://ftp-mirror.internap.com/pub/gentoo/ http://www.gtlib.cc.gatech.edu/pub/gentoo \                ftp://ftp.ussg.iu.edu/pub/linux/gentoo ftp://ftp.ucsb.edu/pub/mirrors/linux/gentoo/ \                 http://gentoo.mirrors.pair.com/ http://gentoo.seren.com/gentoo"
 * Error: Problem with /etc/make.conf
 * Solution Make.conf Example

Credits

 * Created by: User:ZyMOS

From HowTo Wiki, a Wikia wiki.