Gentoo Prefix NetBSD

From Gentoo Wiki
Jump to: navigation, search
Currently Gentoo Prefix does not work on NetBSD. This is a work in progress and this page will contains notes about my efforts to get it up and running.


Start by installing bash via pkgsrc, because thats what I use for the guide.

The following is added to ~/.bashrc:

FILE ~/.bashrc
export EPREFIX="$HOME/gentoo"
export LDFLAGS="-L$EPREFIX/usr/lib -Wl,-rpath=$EPREFIX/usr/lib -L$EPREFIX/lib -Wl,-rpath=$EPREFIX/lib"
export PATH="$EPREFIX/usr/bin:$EPREFIX/bin:$EPREFIX/tmp/usr/bin:$EPREFIX/tmp/bin:$PATH"

The EPREFIX part is your choice. Another popular option is EPREFIX=/usr/gentoo

Now we need the main tools. We are trying to follow the Gentoo Prefix Bootstrap Process for UNIX-like systems but NetBSD requires a lot of changes to get it working. Anyways, you need the following two files:

Save them in your home directory. In fact anything you download, put it there for the purpose of this guide.

user $chmod 755 ~/ ~/

There is no Gentoo Prefix Profile for NetBSD on x86_64 so get profile-x86_64-pc-netbsd.tgz and put it in your home directory.

user $mkdir $EPREFIX
user $cd $EPREFIX
user $tar zxvf ~/profile-x86_64-pc-netbsd.tgz

We have to edit to add support for our profile. Open it up and add the following sections:

    ldflags_make_defaults="LDFLAGS=\"-L${ROOT}/usr/lib -Wl,-rpath=${ROOT}/usr/lib -L${ROOT}/lib -Wl,-rpath=${ROOT}/lib\""
    case `uname -p` in
        CHOST="`uname -p`-pc-netbsdelf"

m4 and bison must be installed *before* bash. We can just go down the list until we get to m4

user $./ $EPREFIX/tmp make
user $./ $EPREFIX/tmp wget
user $./ $EPREFIX/tmp sed
user $./ $EPREFIX/tmp m4

Bootstrapping m4 will probably fail due to problems with fseeko.c and fflush.c. Download patch-lib-fflush.c and also patch-lib-fseeko.c and put them in your home directory. Because the script will overwrite everything each time its run, we have to patch the source tarball and replace the original.

user $cd $EPREFIX/tmp/usr/portage/distfiles
user $mkdir tmp
user $cd tmp
user $tar zxvf ../m4-1.4.15.tar.gz
user $cd m4-1.4.15/lib
user $patch fflush.c < ~/patch-lib-fflush.c
user $patch fseeko.c < ~/patch-lib-fseeko.c
user $cd ../..
user $tar zcvf m4-1.4.15.tar.gz m4-1.4.15/
user $cd ..
user $cp tmp/m4-1.4.15.tar.gz .
user $rm -rf tmp
user $cd

This time it should work with our fixed tarball

user $./ $EPREFIX/tmp m4
user $ ./ $EPREFIX/tmp bison

Now we can go ahead and bootstrap bash

user $./ $EPREFIX/tmp
user $hash -r

Next up... coreutils which also has fflush.c and fseeko.c. It will fail but we run it first to download the source.

user $./ $EPREFIX/tmp coreutils

When it aborts we go ahead and patch the source tarball exactly like we did for m4. Just patch the coreutils-8.16 not both. With luck it will build cleanly and install itself.
We get a breather now, several packages should bootstrap without issues.

user $./ $EPREFIX/tmp findutils
user $./ $EPREFIX/tmp tar
user $./ $EPREFIX/tmp patch
user $./ $EPREFIX/tmp grep
user $./ $EPREFIX/tmp gawk
user $./ $EPREFIX/tmp bash
user $./ $EPREFIX/tmp zlib
user $./ $EPREFIX/tmp python

At this point we are going to get the tree and portage. We will use latest_tree to hopefully pick up some bug fixes.

user $./ $EPREFIX latest_tree
user $./ $EPREFIX portage
user $hash -r

Soon we will have serious errors with libtool unless something is done. Edit your ~/.bashrc and insert this:

FILE ~/.bashrc
export CONFIG_SHELL="$EPREFIX/bin/bash"