Compile Programs on the NAS

From NAS-2000.org

Jump to: navigation, search

This HowTo will explain how to create a buildroot on your NAS in order to compile "any" program you want.

You could ask why should I compile a program on the NAS and not cross compile which will be 50 times faster?

Well, because sometimes the Makefile for the program you want to compile can't handle/ isn't made for crosscompiling etc.

I'm using a Gentoo stage3 file as buildroot because it has everything I need and because it's gentoo the best linux distribution I know :)

OK lets get started.

first connect to your NAS with ssh and then create a directory for all the files needed for the buidroot

  ssh root@<nas-2000>
  cd /mnt/IDE1/public
  mkdir -p gentoo/new_root
  cd gentoo

Now you have to download the stage3 file (Note: If the mirror is down or the file is gone choose an other mirror from gentoo.org/mirror)

  wget http://ftp.uni-erlangen.de/pub/mirrors/gentoo/experimental/arm/stages/armv4l/stage3-armv4l-2005.1.tar.bz2
  cd new_root
  tar -xjvpf ../stage3-armv4l-2005.1.tar.bz2

If you really feel the need of extracting the archive on the NAS you can download this archive. It is the same as the one above but every root-directory is packed seperate in its own archive.

Note: If you have trouble to extract the archiv mount the NAS via NFS and extract the tbz2 file from you computer(Linux :)) to the NAS.

Note: One problem that occurs if unpacking is done on the NAS, is that the tar command will fail because the built-in tar doesn't support some GNU extensions that the archive is created with. But before it fails, it will have already unpacked the gentoo tar, so just retry the command using ./bin/tar and it will succeed this time.

Almost done now you only have to edit the ./etc/make.conf change it to something like this:

  # Please consult /etc/make.conf.example for a more detailed example
  CFLAGS="-Os -pipe -mcpu=strongarm110"
  CHOST="armv4l-unknown-linux-gnu"
  CXXFLAGS="-Os -pipe -mcpu=strongarm110"
  USE="pam -bitmap-fonts -truetype-fonts -type1-fonts -expat"
  PORTAGE_RSYNC_EXTRA_OPTS="--exclude-from=/etc/portage/rsync_excludes"
  RSYNC_TIMEOUT=500
  FEATURES="-noman -noinfo -nodoc buildpkg ccache"

For compiling to work, you need to set portage profile:

  ln -s /usr/portage/profiles/default-linux/arm/2007.0/ /etc/make.profile
  (note: this line has been recently updated by a visitor, plz check if correct )

get ready to enter your new buildroot:

  mount -t proc none ./proc   

and enter the buildroot

  chroot ./ /bin/bash

First of all you should check if your time is set correct type date. Have a look here for more detailed information about the time on linux systems. If the time is correct skip this step if not do the following:

   rm -f /etc/localtime
   ln -s /usr/share/zoneinfo/your/timezone /etc/localtime

the first thing you have to do now is update the portage-tree this may take some time (45-60 minutes)

   emerge --sync

(note: If your internet connection doesn't work it is probably due to the /etc/resolv.conf create a resolv.conf like this and try again)

   search lan
   nameserver 192.168.1.1 #or whatever you use as nameserver (normally the router ip)

I don't like nano so the first thing I would do is install vi :)


   emerge -av vim

and ccache

   emerge -av ccache

Note: This can take a long time to compile. (Around 45 minutes for this example!)

That was it. You can now compile everything you want in this buildroot. Some small programs you can even "emerge". To make it easier compile/emerge the progs static. Because gentoo is maybe a new world to you I can really recomment the Gentoo-Handbook

To make live easier you can create a simple script that takes care about mount proc etc. and entering the chroot. Don't forget to make it executible by chmod +x enter_chroot


 #!/bin/sh
 CWD=`pwd`
 cd /mnt/IDE1/public/gentoo/new_root
 mount -t proc none ./proc
 mount -t sysfs none ./sys
 mount -t usbfs none ./proc/bus/usb
 chroot . /bin/bash
 cd $CWD

ah to leave the buildroot enter exit

  exit
Personal tools