Gentoo Binary Packages
April 9th, 2006 by Warren FalkIn an effort to save myself some time, I’m looking into setting up a share on my network dedicated to hosting precompiled gentoo packages (that I’ve compiled myself). This way when I unmerge a package and want to remerge it later, or I want to merge the same package on identically configured (same architecture and optimizations), I don’t have to go through all the trouble of recompiling everything.
I’m using a samba share because I already have one. If you want to use NFS or something else, then that is fine, but you’ll have to transpose this list as necessary. Also note that to use a samba share, you’ll want to have the smbfs module compiled and inserted, or compiled into the kernel. The basic process works as follows:
UPDATED: I’ve updated this now due to a problem with newer versions of portage getting ACCESS DENIED errors when creating the binaries. Because of the way the sandbox works, you can’t have symlinks inside the package directory (PKGDIR) that point outside the sandbox’s directory write list.
- [Server A] Set up a centralized directory with read/write access for storing the binary packages. Share it with samba.
- [Server B] Set up a centralized web server (apache in my case) that can point to the share. This could be the same box as “A”, but mine is not.
- [Client] Mount the samba share somewhere. Mine is called “pub” because it was already created and I mount it in /mnt/pub, for instance.
- [Client] cd into the share, and create a folder for your architecture. This should be something like i686-pc-linux-gnu-4.1.0/pentium4/O2. The first directory name (e.g. i686-pc-linux-gnu) is the compiler architecture (CHOST) being used (from `gcc-config -c`). The next directory name (e.g. pentium4) is the architecture. This comes from the -march in CFLAGS in /etc/make.conf. The next is the compiler optimization used (e.g. O2 for -O2) in the CFLAGS of /etc/make.conf.
- [Client] Add PKGDIR variable to /etc/make.conf that points to the directory you created in the previous step
- [Client] Add to /etc/make.conf: FEATURES=”buildpkg”
- [Client] (optional, see caveat) Use quickpkg to create binary packages of everything you already have built. Caveat: if the package contains any files you’ve modified, these go into your binary package. So this isn’t really safe. The better thing to do is to re-emerge everything.
- [Client] Add the following alias to your /etc/bash/bashrc aliases, alias emerge=”emerge –usepkg –getbinpkg”
- [Client] Add to /etc/make.conf: PORTAGE_BINHOST=”http:///path/to/share/i686-pc-linux-gnu/pentium4/O2/” (Try not to miss the last slash as it results in a redirect from the server and an annoying message from emerge)
The basic idea, here, is that steps 1 and 2 create a central repository. Steps 3-8 ensure that binaries are cached for existing builds and new builds, and step 9 sets the system up to use the cached binaries if they are available.
Tips:
One thing I noticed is that I have some machines configured to use the -march k8 and some to use -march athlon64, but that these are aliases for the same thing and produce identical binaries. So, if you want to share binaries between these machines, you can symlink the k8 and athlon64 directories under the x86_64* dir.
Caveats:
- I believe that different glibc versions might cause problems and this could potentially be remedied by adding a glibc version into the PKGDIR and PORTAGE_BINHOST paths.
- If you upgrade gcc, gcc-config will not fix /etc/make for you to put the new binaries in a new folder, so you just have to remember to do that. I experimented with having make.conf detect the current version, but that caused problems with gcc-config.
- If you share these among machines, it looks like the USE flags are compiled into the binaries so the two machines are forced to use the same USE flags or compile separately. Compiling separately might cause some confusing problems since the paths to the binary packages will be identical causing overwrites.

