Prefix/NetBSD

From Gentoo Wiki
< Prefix
Jump to:navigation Jump to:search
Warning
Currently Gentoo Prefix does not work on NetBSD. This is a work in progress; page simply contains notes about efforts to get it up and running.

Instructions

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 ~/bootstrap-bash.sh ~/bootstrap-prefix.sh

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 bootstrap-prefix.sh to add support for our profile. Open it up and add the following sections:

FILE bootstrap-prefix.sh
x86_64-pc-netbsd*)
    profile="${PORTDIR}/profiles/prefix/bsd/netbsd/6.0/x64"
    ldflags_make_defaults="LDFLAGS=\"-L${ROOT}/usr/lib -Wl,-rpath=${ROOT}/usr/lib -L${ROOT}/lib -Wl,-rpath=${ROOT}/lib\""
    ;;
...
  NetBSD)
    case `uname -p` in
      i386|x86_64)
        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 $./bootstrap-prefix.sh $EPREFIX/tmp make
user $./bootstrap-prefix.sh $EPREFIX/tmp wget
user $./bootstrap-prefix.sh $EPREFIX/tmp sed
user $./bootstrap-prefix.sh $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 $./bootstrap-prefix.sh $EPREFIX/tmp m4
user $

./bootstrap-prefix.sh $EPREFIX/tmp bison

Now we can go ahead and bootstrap bash

user $./bootstrap-bash.sh $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 $./bootstrap-prefix.sh $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 $./bootstrap-prefix.sh $EPREFIX/tmp findutils
user $./bootstrap-prefix.sh $EPREFIX/tmp tar
user $./bootstrap-prefix.sh $EPREFIX/tmp patch
user $./bootstrap-prefix.sh $EPREFIX/tmp grep
user $./bootstrap-prefix.sh $EPREFIX/tmp gawk
user $./bootstrap-prefix.sh $EPREFIX/tmp bash
user $./bootstrap-prefix.sh $EPREFIX/tmp zlib
user $./bootstrap-prefix.sh $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 $./bootstrap-prefix.sh $EPREFIX latest_tree
user $./bootstrap-prefix.sh $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"