Scratchbox

From Chumby Wiki
Revision as of 09:16, 8 May 2009 by Nightmedia (Talk | contribs)

Jump to: navigation, search

Description

This is a step-by-step documentation on how to install a Scratchbox development environment for Chumby.

This will allow everybody to create their own dev environment, compile Perl, build and test binaries for Chumby.

We used Ubuntu 8.04 LTS Desktop Edition as the host.

In our environment this runs on a XP box in a VMWare virtual machine. Installing the free VMWare server and Ubuntu should be a pretty easy task.

Setting up the work environment

Installing Scratchbox

Installing a scratchbox environment on Ubuntu. Be sure to uncomment the sources for "universe"

  • add the following to /etc/apt/sources.list
deb http://scratchbox.org/debian stable main
  • Update the local repository cache:
sudo apt-get update
  • Install the scratchbox packages:
sudo apt-get install scratchbox-core scratchbox-libs
  • add yourself to the scratchbox group:
sudo /scratchbox/sbin/sbox_adduser dmaxwell

If you are getting an error showing that the host kernel has vdso support (which is uncompatible with SB), you need to run:

 echo 0 > /proc/sys/vm/vdso_enabled
  • If running on an Ubuntu system, there could be issues with compiled arm binaries resulting in errors like:
 mmap: Permission denied

We found the following hint:

For problems when building packages (mmap: permission denied when building), it’s necessary to reduce the mmap minimum address:

 echo 4096 > /proc/sys/vm/mmap_min_addr


  • logout, login to grok the new group "sbox". If using X, you need to completely restart X for the environment to be set right.
  • You can now enter scratchbox:
 /scratchbox/login
 
 [sbox-: ~] > logout

Set up the HOST target

  • Install the following packages:
 scratchbox-toolchain-host-gcc
 scratchbox-devkit-doctools
 scratchbox-devkit-perl
 scratchbox-devkit-debian
 scratchbox-devkit-cputransp

They can be installed in one call as:

 apt-get install scratchbox-toolchain-host-gcc scratchbox-devkit-doctools \
 scratchbox-devkit-perl scratchbox-devkit-debian scratchbox-devkit-cputransp
  • Allow the sbox group to create/add new compilers. Refer to the Scratchbox Wiki for more information on steps 1-3 on their page.
 chgrp -R sbox /scratchbox/compilers
 chmod -R g+w /scratchbox/compilers
 mkdir /scratchbox/device_tools
 chgrp -R sbox /scratchbox/device_tools
 chmod -R g+w /scratchbox/device_tools


  • Login to scratchbox as a normal user, and run the menu:
 /scratchbox/login
 
 [sbox-: ~] > sb-menu
  • Setup a new target and call it HOST
  • Select the host-gcc compiler
  • Select the debian-etch, perl, and doctools devkits.
  • Select no cpu transparency method.
  • Select "Yes" to installing files, and check /etc and Devkits.
  • Select the target by choosing Yes, observe the shell restarting and placing us in the HOST context:
 Shell restarting...
 [sbox-HOST: ~] >

Install the C compiler

All steps below have to be executed from within the HOST target.

  • Create the arm-chumby compiler directory
 [sbox-HOST: ~] >
 cd /scratchbox/compilers
 mkdir arm-chumby-gcc4.1.2
  • Download the Chumby compiler as specified in the wiki and extract the toolchain:
 [sbox-HOST: ~] >
 wget http://files.chumby.com/toolchain/arm-linux-v4.1.2b.tar.gz
 cd arm-chumby-gcc4.1.2
 tar xvzf ../arm-linux-v4.1.2b.tar.gz
  • We now have to create a number of symbolic links, because the toolchain really doesn't like not living in /usr/arm-linux:
 [sbox-HOST: /scratchbox/compilers/arm-chumby-gcc4.1.2] >
 ln -s /scratchbox/compilers/arm-chumby-gcc4.1.2/usr/bin bin
 ln -s /scratchbox/compilers/arm-chumby-gcc4.1.2/usr/arm-linux/include include
 ln -s /scratchbox/compilers/arm-chumby-gcc4.1.2/usr/include/c++ include/c++
 ln -s /scratchbox/compilers/arm-chumby-gcc4.1.2/usr/arm-linux arm-linux
 ln -s /scratchbox/compilers/arm-chumby-gcc4.1.2/arm-linux /usr/arm-linux



Create the new target

You should be able to switch to the new toolchain now:

  • Run sb-menu.
  • Setup a new target. For this example, we named the target Chumby.
  • Select the new compiler: arm-chumby-gcc4.1.2
  • Select only the cputransp devkit.
  • Choose an ARM emulator. The latest available version is qemu-arm-0.8.2-sb.
  • Do not select a rootstrap (select < No >).
  • Install files. De-select all options except for /etc and C-library
  • Select the new target, observe that it reloads the shell onto the new target:
Shell restarting...
[sbox-Chumby: ~] >

After creating the new environment, we need to re-create a symlink, because the compiler really wants to link to stuff in /usr/arm-linux:

[sbox-Chumby: ~] >
ln -s /scratchbox/compilers/arm-chumby-gcc4.1.2/arm-linux /usr/arm-linux

By default, no libraries are present in the new target. We need to do create links to the files in the Microcross lib directory:

[sbox-Chumby: ~] >
ln -s /scratchbox/compilers/arm-chumby-gcc4.1.2/arm-linux/lib/* /lib

We also need to make sure the include directory exists, so things like errno.h can be found:

[sbox-Chumby: ~] >
ln -s /scratchbox/compilers/arm-chumby-gcc4.1.2/arm-linux/include /usr/include

There are also some extra tools that are not present, and are not yet linked to by Scratchbox, such as getconf. Link these as necessary:

[sbox-Chumby: ~] >
ln -s /scratchbox/compilers/arm-chumby-gcc4.1.2/usr/arm-linux/bin/getconf /usr/bin/getconf


In Scratchbox the C runtime object files reside in /lib. If you plan to install applications that look for the C runtime object files in /usr/lib, like Emacs, you need to reate symlinks to get this working:

[sbox-Chumby: ~] >
ln -s /lib/crt* /usr/lib/


You should also make sure programs inside the environment can do DNS lookups by creating an /etc/resolv.conf file:

 echo nameserver 172.22.1.12 > /etc/resolv.conf
 echo nameserver 65.106.1.196 >> /etc/resolv.conf

Using the Scratchbox environment

Limitations of the Scratchbox environment

The biggest limitation is that pthread support is nonexistent. This means, for example, that any call to pthread_join() will cause the program to silently quit. Practically, this means that threaded perl tests will not run, meaning many perl modules must be installed using force. However, once installed, these programs will run just fine on a real Chumby.

Running Scratchbox

Everytime we start it, we need to do the following as root:

 echo 0 > /proc/sys/vm/vdso_enabled
 echo 4096 > /proc/sys/vm/mmap_min_addr

Compiling and configuring Perl

  • To initialize the CPAN module list in the user home directory, we install YAML in the default Perl:
 [sbox-Chumby: ~] >
 perl -MCPAN -e shell
 
 cpan> 
 install YAML
  • Make a work folder, download and expand the Perl source:
 [sbox-Chumby: ~] >
 mkdir perl
 cd perl
 wget http://www.cpan.org/src/perl-5.10.0.tar.gz
 tar zxf perl-5.10.0.tar.gz
 cd perl-5.10.0
  • Create the following symlink
 ln -s /scratchbox/tools/bin/pwd /bin/pwd
  • Create the target folder for Perl, and start the Configure script:
 [sbox-Chumby: ~/perl/perl-5.10.0] >
 mkdir -p /mnt/usb/usr/local/bin
 ./Configure
 Installation prefix to use? (~name ok) [/opt] /mnt/usb/usr/local
 
 What installation prefix should I use for installing files? (~name ok)
 [/mnt/usb/usr/local]
 
 If this doesn't make any sense to you, just accept the default 'n'.
 Build Perl for SOCKS? [n] 
 
 If this doesn't make any sense to you, just accept the default 'n'.
 Build Perl for SOCKS? [n] 
 
 If this doesn't make any sense to you, just accept the default 'n'.
 Build a threading Perl? [n] y
 
 Use which C compiler? [cc] gcc
 
 Directories to use for library searches? [/lib] 
 
 What is the file extension used for shared libraries? [so] 
 
 Try to use long doubles if available? [n] 
 
 What libraries to use? [-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc] 
 

We need to override here the default since the current toolchain has issues with this flag:

 What optimizer/debugger flag should be used? [-O2] none
 Any additional cc flags?
 [-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -fno-strict-aliasing -pipe] 
 Any additional ld flags (NOT including libraries)? [none] 
 
 Try to use 64-bit integers, if available? [n] 
 
 Try to use maximal 64-bit support, if available? [n] 
 
 What is your architecture name [arm-linux] 
 
 Pathname where the public executables will reside? (~name ok) [/mnt/usb/usr/local/bin] 
 
 If this doesn't make any sense to you, just accept the default 'n'.
 Use relocatable @INC? [n] 
 
 Pathname where the private library files will reside? (~name ok)
 [/mnt/usb/usr/local/lib/perl5/5.10.0] 
 
 Where do you want to put the public architecture-dependent libraries? (~name ok)
 [/mnt/usb/usr/local/lib/perl5/5.10.0/arm-linux-thread-multi] 
 
 Other username to test security of setuid scripts with? [none] 
 
 Does your kernel have *secure* setuid scripts? [n]
 
 Do you want to do setuid/setgid emulation? [n] 
 
 Installation prefix to use for add-on modules and utilities? (~name ok) [/mnt/usb/usr/local]
 
 Pathname for the site-specific library files? (~name ok)
 [/mnt/usb/usr/local/lib/perl5/site_perl/5.10.0] 
 
 List of earlier versions to include in @INC? [none] 
 
 Do you wish to wrap malloc calls to protect against potential overflows? [y] 
 
 Do you wish to attempt to use the malloc that comes with perl5? [n] 
 
 Pathname for the site-specific architecture-dependent library files? (~name ok)
 [/mnt/usb/usr/local/lib/perl5/site_perl/5.10.0/arm-linux-thread-multi] 
 
 Do you want to configure vendor-specific add-on directories? [n] 
 
 Colon-separated list of additional directories for perl to search? [none] 
 
 Install any extra modules (y or n)? [n]
 
 Directory for the main Perl5 html pages? (~name ok) [none] 
 
 Directory for the Perl5 module html pages? (~name ok) [none] 
 
 Shall I use /scratchbox/compilers/bin/nm to extract C symbols from the libraries? [n] 
 
 Do you wish to use dynamic loading? [y] 
 
 Source file to use for dynamic loading [ext/DynaLoader/dl_dlopen.xs] 
 
 Any special flags to pass to gcc -c to compile shared library modules? [-fPIC] 
 
 What command should be used to create dynamic libraries? [gcc]
 
 Any special flags to pass to gcc to create a dynamically loaded library? [-shared  ]
 
 Any special flags to pass to gcc to use dynamic linking? [-Wl,-E] 
 
 Build a shared libperl.so (y/n) [n]
 
 Where do the main Perl5 manual pages (source) go? (~name ok) [none] 
 
 Where do the perl5 library man pages (source) go? (~name ok) [none] 
 
 Your host name appears to be "ubuntu-ws". Right? [y] 
 
 What is your domain name? [.nonet] 
 
 What is your e-mail address? [user@ubuntu-ws.nonet] 
 
 Perl administrator e-mail address [user@ubuntu-ws.nonet] 
 
 Do you want to install only the version-specific parts of perl? [n] 
 
 What shall I put after the #! to start up perl ("none" to not use #!)?
 [/mnt/usb/usr/local/bin/perl] 
 
 Where do you keep publicly executable scripts? (~name ok)
 [/mnt/usb/usr/local/bin] 
 
 Pathname where the add-on public executables should be installed? (~name ok)
 [/mnt/usb/usr/local/bin] 
 
 Pathname where the site-specific html pages should be installed? (~name ok) [none] 
 
 Pathname where the site-specific library html pages should be installed? (~name ok) [none] 
 
 Pathname where the site-specific manual pages should be installed? (~name ok) [none] 
 
 Pathname where the site-specific library manual pages should be installed? (~name ok) [none] 
 
 Pathname where add-on public executable scripts should be installed? (~name ok)
 [/mnt/usb/usr/local/bin] 
 
 Use the "fast stdio" if available? [n] 
 
 Try to understand large files, if available? [y] n
 
 What is the extension of dynamically loaded modules [so]
 
 Shall I ignore gethostname() from now on? [n]
 
 Do you still want to use vfork()? [n] 
 
 Doubles must be aligned on a how-many-byte boundary? [4] 
 
 Use which function to generate random numbers? [drand48] 
 
 What type pointer is the second argument to getgroups() and setgroups()? [gid_t]
 
 Build Perl with MAD? [n] 
 

Accept the following path, even if it does not exist

 What pager is used on your system? [/scratchbox/tools/bin/less] /usr/bin/less
 Which compiler compiler (yacc or bison -y) shall I use? [yacc] 
 
 What extensions do you wish to load dynamically? ...
 
 What extensions do you wish to load statically? [none] 

We use nptl but we don't have the program that detects that it is there. In order to do this, we need to remove the definition of THREADS_HAVE_PIDS from the ccflags and cppflags definitions.

Edit the config.sh file, and remove all instances of -DTHREADS_HAVE_PIDS, and remove all instances of /scratchbox/tools. For example, /scratchbox/tools/bin becomes /bin.

 Press return or use a shell escape to edit config.sh: !vim config.sh
 Run make depend now? [y]


After it completes, we can run

 [sbox-Chumby: ~/perl/perl-5.10.0] >
 make && make install

Perl will be installed in the given path:

 /mnt/usb/usr/local/bin

Installing Expat

The Expat library is required by the XML parsing Perl modules.

  • Download, extract, and install expat:
[sbox-Chumby: ~] >
wget http://downloads.sourceforge.net/expat/expat-2.0.1.tar.gz?modtime=1181083143&big_mirror=0
tar xvzf expat-2.0.1.tar.gz
cd expat-2.0.1
./configure --prefix=/mnt/usb/usr/local
make && make install
cd ~

Installing GD

We need to install GD and some of its dependencies in the /usr too, since some steps in the CPAN install fail if the default library is not found.

We did not add support for the Fontconfig library.


GD needs libpng, libjpeg, and freetype (for GD::Graph).

  • Download, extract, and install zlib (needs to be installed in both targets):
[sbox-Chumby: ~] >
wget http://www.zlib.net/zlib-1.2.3.tar.gz
tar xvzf zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure
make && make install
./configure --prefix=/mnt/usb/usr/local
make && make install
./configure --shared --prefix=/mnt/usb/usr/local
make && make install
cd ~
  • Download, extract, and install libpng:
[sbox-Chumby: ~] >
wget http://prdownloads.sourceforge.net/libpng/libpng-1.2.29.tar.gz?download
tar xvzf libpng-1.2.29.tar.gz
cd libpng-1.2.29
./configure --prefix=/mnt/usb/usr/local
make && make install
cd ~


  • Download, extract, and install libjpeg:
[sbox-Chumby: ~] >
wget http://site.n.ml.org/download/19980327183823/libjpeg/libjpeg-6b.tar.gz
tar xvzf libjpeg-6b.tar.gz
cd jpeg-6b
./configure --enable-shared --prefix=/usr
make && make install
./configure --enable-shared --prefix=/mnt/usb/usr/local
make && make install
cd ~


  • Download, extract, and install freetype:
[sbox-Chumby: ~] >
wget 'http://downloads.sourceforge.net/freetype/freetype-2.3.7.tar.gz?modtime=1214734497&big_mirror=0'
tar xvzf freetype-2.3.7.tar.gz
cd freetype-2.3.7
./configure --prefix=/usr
make && make install
./configure --prefix=/mnt/usb/usr/local
make && make install
cd ~


  • Download, extract, and install GD. We need to install it both in the default /usr location and in the intended target:
[sbox-Chumby: ~] >
wget http://www.libgd.org/releases/gd-2.0.35.tar.gz
tar xvzf gd-2.0.35.tar.gz
cd gd-2.0.35
./configure --prefix=/usr
make && make install
./configure --prefix=/mnt/usb/usr/local
make && make install

Installing CPAN modules in the ARM Perl

Making sure that we did initialize the CPAN module list in the user home directory (see first step), we can now start installing modules in the ARM Perl. For all modules that use threading, you need to force the install.

[sbox-Chumby: ~/perl/perl-5.10.0] >
/mnt/usb/usr/local/bin/perl -MCPAN -e shell
 
cpan>
install Bundle::CPAN
force install LWP::UserAgent
force install Net::Daemon
force install MIME::Lite
force install Bundle::DBI
install DBD::CSV Compress::Bzip2 Test::Pod Test::Pod::Coverage Test::Exception 
install String::CRC32 File::Tail Mail::Sender Time::HiRes Tie::IxHash Log::Log4perl

If planning to use Sys::Info, it has to be forced because of some broken tests

cpan>
force install Linux::Distribution Sys::Info

We can also install some crypt modules.

Math::BigInt is used by most crypt modules. After installing it, it is recommended to upgrade a couple dependencies.

Crypt::DSA needs the Convert::ASN1, that has broken test code, so we need to force install it.

cpan>
force install Math::BigInt Math::BigRat
install Class::ErrorHandler Crypt::DES_EDE3 Convert::PEM
install Term::Gnuplot Math::Pari Math::BigInt::FastCalc
force install Convert::ASN1
force install Crypt::Primes
force install Crypt::DSA
install Crypt::DES Crypt::IDEA Crypt::CBC Crypt::Rijndael Crypt::Twofish Crypt::Blowfish

To install XML modules, we have to first get the XML::Parser. This will not build at first, but it will extract in the .cpan/build. After that, we exit the CPAN shell, and configure it manually:

cpan>
install XML::Parser
exit
[sbox-Chumby: ~/perl/perl-5.10.0] >
cd /home/user/.cpan/build/XML-Parser-2.36-*
/mnt/usb/usr/local/bin/perl Makefile.PL EXPATLIBPATH=/mnt/usb/usr/local/lib EXPATINCPATH=/mnt/usb/usr/local/include
make && make install
cd ~

After installing XML::Parser manually, you can resume installing other XML modules:

[sbox-Chumby: ~] >
/mnt/usb/usr/local/bin/perl -MCPAN -e shell

 cpan>
install IO::Scalar Text::Iconv Unicode::String Unicode::Map8 HTML::TreeBuilder
install XML::SAX XML::SAX::Writer XML::Simple XML::XPath XML::XPathEngine
install XML::Handler::YAWriter XML::Twig XML::DOM XML::Writer

There are also some other modules that could prove useful (some are prerequisites that need to be force-installed):

 cpan>
force install Test::Differences SQL::Translator Graph::Directed Bit::Vector Image::ExifTool
install Spreadsheet::ParseExcel SQL::Translator::Parser::Excel Spreadsheet::WriteExcelXML 
install CGI Date::Calc ExtUtils::ParseXS ExtUtils::ModuleMaker
install Text::RecordParser File::Find::Rule File::Find::Rule::MP3Info MP3::Tag MP3::Find 
install WebService::FreeDB MusicBrainz::Client AudioFile::Identify::MusicBrainz
install GD GD::Thumbnail GD::Graph

Install ImageMagick

  • Download, extract, and configure. This will also install the Perl module in the target build.
[sbox-Chumby: ~] >
wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz
tar xvzf ImageMagick.tar.gz
cd ImageMagick-6.4.2
./configure --prefix=/mnt/usb/usr/local --with-perl=/mnt/usb/usr/local/bin/perl

At the end of configure, you should be seeing:

Options used to compile and link:
 PREFIX          = /mnt/usb/usr/local
 EXEC-PREFIX     = /mnt/usb/usr/local
 VERSION         = 6.4.2
 CC              = gcc
 CFLAGS          = -g -O2 -Wall -W -pthread
 MAGICK_CFLAGS   = -g -O2 -Wall -W -pthread
 CPPFLAGS        = -I/mnt/usb/usr/local/include/ImageMagick
 PCFLAGS         = 
 DEFS            = -DHAVE_CONFIG_H
 LDFLAGS         = -lfreetype -lz
 MAGICK_LDFLAGS  = -L/mnt/usb/usr/local/lib -lfreetype -lz
 LIBS            = -lMagickCore -lfreetype -ljpeg -lz -lm -lpthread 
 CXX             = g++
 CXXFLAGS        = -g -O2 -Wall -W -pthread

Now run make and install:

[sbox-Chumby: ~/ImageMagick-6.4.2] >
make && make install
NOTE: The ImageMagick binaries (convert) return currently a stack overflow. 
      We are currently looking into why this happens.

Installing id3v2

  • Change to your home directory
  • Download and extract id3v2:
 [sbox-Chumby: ~] >
 wget http://softlayer.dl.sourceforge.net/sourceforge/id3lib/id3lib-3.8.3.tar.gz
 tar xvzf id3lib-3.8.3.tar.gz
 cd id3lib-3.8.3
  • Patch the following files:

configure

Look for iomanip.h, replace it with iomanip


In all the modules listed below, look for the following line:

 int main( unsigned int argc, char * const argv[])

replace it with:

 int main( int argc, char * const argv[])

Also, you need to add before the specified methods a prototype:

examples/demo_convert.cpp

void PrintUsage(const char *sName);
void PrintVersion(const char *sName);

examples/demo_copy.cpp

void PrintUsage(const char *sName);
void PrintVersion(const char *sName);
void DisplayTags(ostream &os, luint nTags);

examples/demo_info.cpp

void PrintUsage(const char *sName);
void PrintVersion(const char *sName);
void PrintInformation(const ID3_Tag &myTag);

examples/demo_tag.cpp

void PrintUsage(const char *sName);
void PrintVersion(const char *sName);
void DisplayTags(ostream &os, luint nTags);


Some other edits:

include/id3/id3lib_strings.h

Add include:

 #include <string.h>


include/id3/writers.h

Uncomment existing include:

 #include <string.h>


  • Configure and build:
 ./configure --prefix=/mnt/usb/usr/local
 make && make install
 cd ~

Installing vim

  • Change to your home directory
  • Download and extract ncurses:
 [sbox-Chumby: ~] >
 wget http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.6.tar.gz
 tar xvzf ncurses-5.6.tar.gz
  • Change to ncurses directory and configure ncurses, then compile and install it:
 [sbox-Chumby: ~] >
 cd ncurses-5.6
 ./configure --prefix=/mnt/usb/usr/local
 make && make install
  • Change back to home directory, get and extract vim:
 [sbox-Chumby: ~/ncurses-5.6] >
 cd ..
 wget ftp://ftp.vim.org/pub/vim/unix/vim-7.2.tar.bz2
 tar xvjf vim-7.2.tar.bz2
  • Change to vim directory and configure vim:
 [sbox-Chumby: ~] >
 cd vim72
 CFLAGS="-I/mnt/usb/usr/local/include" LDFLAGS="-L/mnt/usb/usr/local/lib" \
 ./configure --prefix=/mnt/usb/usr/local --with-tlib=ncurses
  • Compile and install vim:
 [sbox-Chumby: ~/vim72] >
 make && make install


Install command-line id3v2 tool

  • Change to your home directory
  • Download and extract id3v2:
 [sbox-Chumby: ~] >
 wget http://softlayer.dl.sourceforge.net/sourceforge/id3v2/id3v2-0.1.11.tar.gz
 tar xvzf id3v2-0.1.11.tar.gz
 cd id3v2-0.1.11
 make PREFIX=/mnt/usb/usr/local
 cd ~

To test the built binary:

 LD_LIBRARY_PATH=/mnt/usb/usr/local/lib ./id3v2

Installing vim

  • Change to your home directory
  • Download and extract ctags:
 [sbox-Chumby: ~] >
 wget http://prdownloads.sourceforge.net/ctags/ctags-5.7.tar.gz
 tar xvzf ctags-5.7.tar.gz
  • Change to ctags directory and configure ctags, then compile and install it:
 [sbox-Chumby: ~] >
 cd ctags-5.7
 ./configure --prefix=/mnt/usb/usr/local
 make && make install
 cd ~
  • Download and extract ncurses:
 [sbox-Chumby: ~] >
 wget http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.6.tar.gz
 tar xvzf ncurses-5.6.tar.gz
  • Change to ncurses directory and configure ncurses, then compile and install it in both local and staging:
 [sbox-Chumby: ~] >
 cd ncurses-5.6
 ./configure --prefix=/usr/local
 make && make install
 ./configure --prefix=/mnt/usb/usr/local
 make && make install
  • Change back to home directory, get and extract vim:
 [sbox-Chumby: ~/ncurses-5.6] >
 cd ..
 wget ftp://ftp.vim.org/pub/vim/unix/vim-7.2.tar.bz2
 tar xvjf vim-7.2.tar.bz2
  • Change to vim directory and configure vim:
 [sbox-Chumby: ~] >
 cd vim72
 CFLAGS="-I/mnt/usb/usr/local/include" LDFLAGS="-L/mnt/usb/usr/local/lib" \
 ./configure --prefix=/mnt/usb/usr/local --with-tlib=ncurses
  • Compile and install vim:
 [sbox-Chumby: ~/vim72] >
 make && make install


If you want reasonable defaults for vim, try putting these files into a file called vimrc on the root of the flash drive. This will be a template file that will be used by the Chumby evironment setup script to copy it in the home directory:


if $TERM == "vt100"
  set term=vt220
endif
set background=dark "A background for darkness, as all of my windows are blue"
if has("gui_running")
  set background=dark
endif
if has("syntax")
  exec "syntax on"
  augroup syntax  " doesnt work right now - need to find out from archives
  au  BufNewFile,BufReadPost * hi link Todo Error
  augroup END
endif
set cindent
set autoindent
set expandtab
set ignorecase
set ruler
set tabstop=4       "Make an indentation level every four columns"
set expandtab       "Convert all tabs typed into spaces"
set shiftwidth=4    "Indent/Outdent by four columns"
set shiftround      "Always indent/outdent to the nearest tabstop"
set laststatus=2    "Have two lines of status, including current filename"
set tw=75           "Automatically wrap at 75 characters"
set cinkeys=0{,0},!^F,o,O,e "default is: 0{,0},0),:,0#,!^F,o,O,e"   "This fixes perl comments"
set incsearch

Installing gdb

  • Change to your home directory
  • Download and extract gdb:
 [sbox-Chumby: ~] >
 wget ftp://mirrors.kernel.org/gnu/gdb/gdb-6.8.tar.gz
 tar xvzf gdb-6.8.tar.gz
  • Change to gdb directory and configure gdb, then compile and install it:
 [sbox-Chumby: ~] >
 cd gdb-6.8
 ./configure --prefix=/mnt/usb/usr/local
 make && make install
 cd ~
  • If we are getting errors pointing to XML components, we should re-install expat, then retry:
 [sbox-Chumby: ~] >
 cd ../expat-2.0.1
 ./configure --prefix=/mnt/usb/usr/local
 make && make install
 cd ../gdb-6.8
 ./configure --prefix=/mnt/usb/usr/local
 make && make install
 cd ~


Installing Emacs

In the interest of fairness, Emacs is also relatively easy to compile on the Chumby.

  • Download and extract Emacs:
 [sbox-Chumby: ~] >
 wget http://mirrors.usc.edu/pub/gnu/emacs/emacs-22.2.tar.gz
 tar xvzf emacs-22.2.tar.gz
  • Change to emacs directory and configure Emacs:
 [sbox-Chumby: ~] >
 cd emacs-22.2
 ./configure --prefix=/mnt/usb/usr/local
  • Emacs looks for the C runtime object files in /usr/lib/, but in Scratchbox they reside in /lib/. Create symlinks to get this working:
 [sbox-Chumby: ~/emacs-22.2] >
 ln -s /lib/crt* /usr/lib/
  • Compile and install Emacs:
 [sbox-Chumby: ~/emacs-22.2] >
 make && make install

Installing Subversion

To begin with, make sure you have expat installed, as mentioned in the steps for installing the Expat perl module.

  • Download and unpack zlib:
 [sbox-Chumby: ~] >
 wget http://www.zlib.net/zlib-1.2.3.tar.gz
 tar xvzf zlib-1.2.3.tar.gz
  • Configure zlib:
 [sbox-Chumby: ~] >
 cd zlib-1.2.3
 ./configure --prefix=/usr
  • Compile and install zlib:
 [sbox-Chumby: ~/zlib-1.2.3] >
 make && make install
 cd ..
  • Download and unpack openssl:
 [sbox-Chumby: ~] >
 wget http://www.openssl.org/source/openssl-0.9.8h.tar.gz
 tar xvzf openssl-0.9.8h.tar.gz
  • Configure openssl:
 [sbox-Chumby: ~] >
 cd openssl-0.9.8h
 PERL=/mnt/usb/usr/local/bin/perl ./config --prefix=/usr
  • Compile and install openssl:
 [sbox-Chumby: ~/openssl-0.9.8h] >
 make && make install
  • Subversion uses mawk, which doesn't exist. Create a shortcut to awk:
 ln -s /scratchbox/tools/bin/awk /bin/mawk
  • Download and unpack the subversion source:
 [sbox-Chumby: ~] >
 wget http://subversion.tigris.org/downloads/subversion-1.5.1.tar.gz
 tar xvzf subversion-1.5.1.tar.gz
 cd subversion-1.5.1
  • In the host, check out the latest versions of apr and apr-util:
 user@ubuntu:~$
 cd /scratchbox/users/user/home/user/subversion-1.5.1/
 svn co http://svn.apache.org/repos/asf/apr/apr/branches/0.9.x apr
 svn co http://svn.apache.org/repos/asf/apr/apr-util/branches/0.9.x apr-util

  • Back in the target, configure tha apr and apr-util:
 [sbox-Chumby: ~/subversion-1.5.1] >
 cd apr
 ./buildconf
 cd ..
 cd apr-util
 ./buildconf
 cd ..
  • Get neon, which is used to access http and https servers:
 [sbox-Chumby: ~/subversion-1.5.1] >
 wget http://www.webdav.org/neon/neon-0.28.1.tar.gz
 tar xvzf neon-0.28.1.tar.gz
 mv neon-0.28.1 neon
  • Configure, compile, and install subversion:
 [sbox-Chumby: ~/subversion-1.5.1] >
 ./configure --prefix=/mnt/usb/usr/local --with-ssl
 make && make install

Installing GNU Screen

The process of getting gnu screen installed is almost identical to the process of getting vim working:

  • Change to your home directory
  • Download and extract ncurses:
 [sbox-Chumby: ~] >
 wget http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.6.tar.gz
 tar xvzf ncurses-5.6.tar.gz
  • Change to ncurses directory and configure ncurses, then compile and install it:
 [sbox-Chumby: ~] >
 cd ncurses-5.6
 ./configure --prefix=/mnt/usb/usr/local
 make && make install
  • Change back to home directory, get and extract screen:
 [sbox-Chumby: ~/ncurses-5.6] >
 cd ..
 wget http://ftp.gnu.org/gnu/screen/screen-4.0.3.tar.gz 
 tar xvzf screen-4.0.3.tar.gz 
  • Change to screen directory and configure screen:
 [sbox-Chumby: ~] >
 cd screen-4.0.3
 CFLAGS="-I/mnt/usb/usr/local/include" LDFLAGS="-L/mnt/usb/usr/local/lib" \
 ./configure --prefix=/mnt/usb/usr/local --with-tlib=ncurses
  • Compile and install screen:
 [sbox-Chumby: ~/screen-4.0.3] >
 make && make install
 mkdir -p /mnt/usb/usr/local/etc
 cp ./etc/etcscreenrc /mnt/usb/usr/local/etc/screenrc
 # NOTE: termcap entry (./terminfo/screencap) should be installed manually.


Installing tcpdump

  • Configure and compile pcap:
  [sbox-Chumby: ~] >
wget http://www.tcpdump.org/release/libpcap-1.0.0.tar.gz
tar xvzf libpcap-1.0.0.tar.gz
cd libpcap-1.0.0
./configure --with-pcap=linux --prefix=/mnt/usb/usr/local
make && make install
  • Configure, compile, and install tcpdump:
   [sbox-Chumby: ~] >
wget http://www.tcpdump.org/release/tcpdump-4.0.0.tar.gz
tar xvzf tcpdump-4.0.0.tar.gz
cd tcpdump-4.0.0
LDFLAGS="-ldl" ./configure --prefix=/mnt/usb/usr/local
make && make install

Installing GNU Netcat

The device already has Netcat, this is provided as an alternative.

http://www.catonmat.net/blog/unix-utilities-netcat/

  • Configure, compile, and install netcat:
   [sbox-Chumby: ~] >
wget http://internap.dl.sourceforge.net/sourceforge/netcat/netcat-0.7.1.tar.gz
tar xvzf netcat-0.7.1.tar.gz
cd netcat-0.7.1
./configure --prefix=/mnt/usb/usr/local
make && make install

Installing Pipe Viewer

http://www.catonmat.net/blog/unix-utilities-pipe-viewer/

wget http://pipeviewer.googlecode.com/files/pv-1.1.4.tar.bz2
bunzip2 pv-1.1.4.tar.bz2
tar xf pv-1.1.4.tar
cd pv-1.1.4
./configure --prefix=/mnt/usb/usr/local
make && make install


Sychronizing the local environment with the staging

  • Make a copy of the package config, to make the package config database work.

This should be performed after installing any package, to make the local copy aware of the installed packages.

 [sbox-Chumby: ~] >
 mkdir -p /usr/local/lib/pkgconfig
 cp /mnt/usb/usr/local/lib/pkgconfig/* /usr/local/lib/pkgconfig

Transferring applications and data to your Chumby

Packing Data in Scratchbox

After compiling all tools, we can tar/gz the /mnt/usb/usr and copy it to target.

Since the USB drives are FAT32, we tar it so as to resolve symlinks to real files. This will indeed result in a larger archive.

 [sbox-Chumby: ~] >
 cd /mnt/usb
 tar -zchf usr_arm.tgz usr

Unpacking Data on Chumby

Since the USB drives are FAT32, the symlinks will not be created. Make sure it was packed with the h param. There will be files instead of the symlinks in the tar file:

 tar -zxf usr_arm.tgz

Environment setup script

Here is a simple script that can be used to give you a rather nice development environment on the Chumby. Put this into a file called 'setup_chumby.sh', and then execute it. If you have a vimrc file, put it in the root of the flash drive. We named the file vimrc with no leading dot because cp would skip it:

#!/bin/sh
mkdir /tmp/home
export HOME=/tmp/home
export PATH=/mnt/usb/sbin:/mnt/usb/usr/sbin:/mnt/usb/usr/local/sbin:/mnt/usb/bin:/mnt/usb/usr/bin:/mnt/usb/usr/local/bin:$PATH
#export PS1='[chumby: \w] > '
export PS1="\[\e[36;1m\]\u\[\e[33;1m\]:\[\e[0m\]\w\[\e[32;1m\] > \[\e[0m\]"
export TERM='ansi'
if [ -e /mnt/usb/vimrc ]
  then cp /mnt/usb/vimrc /tmp/home/.vimrc
fi
exec /mnt/usb/usr/local/bin/bash