Difference between revisions of "Custom Perl For Chumby"

From Chumby Wiki
Jump to: navigation, search
(Pre-compiled, ready-to-run Perl)
(Pre-compiled, ready-to-run Perl)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
These are the instructions for building Perl to work on the Chumby.
+
The instructions for building Perl to work on the Chumby are found [[Scratchbox|'''Here''']].  
  
Since cross-compiling it would be an extremely tedious task, we found a way to do it on an [http://wiki.chumby.com/mediawiki/index.php/Virtual_Dev_Environment_For_Chumby emulated ARM environment].
+
You will learn how to set up a development environment using Scratchbox, and compile your own Perl and applications.
  
Considering that you followed the instructions on the page linked above, and you have now a fully functional ARM emulator, you can build now Perl on it, then pack it and save it on an USB stick, ready to be used on a Chumby.
 
  
==Building Perl on the emulated ARM platform ==
+
==Pre-compiled, ready-to-run Perl==
  
For that, create a folder /mnt/usb. This will be the same as the base folder for applications that will run on the device. In that folder create the following full path:
+
Download here the Perl, the include libraries, and applications that can be installed on a Chumby USB key or in the Chumby ONE internal storage. They will get unpacked in "usr", which will appear on the Chumby as '''/mnt/usb/usr''' or as '''/mnt/storage/usr'''.
  
  /mnt/usb/usr/local/bin
+
These files will be updated as necessary. They contain a baseline of applications useful when writing hacks for Chumby. Among them are the '''libwww''', '''Mail::Sender''', various XML and crypto packages; the whole list can be seen on the [[Scratchbox|'''How-to page''']].
  
The perl version that needs to be compiled for the Chumby is 5.10.0 or later. Get the Perl source from here:
+
  http://files.chumby.com/resources/usr_arm_ext3_basicperl.tgz
 +
  http://files.chumby.com/resources/usr_arm_ext3.tgz
 +
  http://files.chumby.com/resources/usr_arm_fat32.tgz
  
  http://www.perl.com/download.csp
+
The '''usr_arm_ext3_basicperl.tgz''' contains only basic things as:
  
We have to use the 5.10, because the 5.8.8 threading is broken on ANY debian platform (i386, ARM, or otherwise). The error one gets is a version mismatch of threads.pm (with a required version of 16384), but the actual error is somewhere in the libpthreads system library. There is no workaround for this.
+
Perl 5.10.0 with a lot of CPAN modules installed
 +
id3v2
 +
ImageMagick
 +
vim
  
Even the 5.10 threading is broken on Debian i386, but for some reason it works fine on the ARM platform. If you are trying to run the automation script on a debian i386, you will get a Segfault exception the first time a socket is being opened in a thread. The error occurs on the manager, when the client is opening a connection.
+
The other two contain all the applications listed on the [[Scratchbox|'''How-to page''']], like:
 
+
This segfault does not occur on the emulated ARM platform. Chumby testing is pending, but it should work, since all other low-level perl tests that I have done between the Chumby and the ARM emulator returned similar results.
+
 
+
===Memory usage===
+
The Perl 5.10.0 should not use more memory than the 5.8.8 when tested on windows. From the initial tests run on the ARM emulator, the scripts did not use over 7MB of memory at any time.
+
 
+
It is expected that with a real life test payload, an extra MB or two would be used. When writing a test, if you expect to deal with large amounts of data, it is therefore recommended to persist the data to disk (flash), to minimize the RAM memory usage.
+
 
+
===Build parameters for Perl 5.10.0 (or later)===
+
In general you can use the defaults, but the following have to be entered as specified:
+
 
+
Hard defined installation path:
+
  By default, perl5 will be installed in .../../bin
+
  ...
+
  Installation prefix to use? (~name ok) [.../..] /mnt/usb/usr/local
+
 
+
Installation prefix for files:
+
  What installation prefix should I use for installing files? (~name ok)
+
  [/usr/local] /mnt/usb/usr/local
+
 
+
The perl 5.10 brings a few new things. Among them the relocatable @INC
+
  Would you like to build Perl so that the installation is relocatable
+
  ....
+
  Use relocatable @INC? [n] y
+
  Installation prefix to use? (~name ok) [.../..] /mnt/usb/usr/local
+
 
+
Build threading Perl:
+
  Perl can be built to take advantage of threads on some systems.
+
  ...
+
  Build a threading Perl? [n] y
+
 
+
Setting the path for public executables:
+
  Pathname where the public executables will reside? (~name ok)
+
  [/usr/local/bin] /mnt/usb/usr/local/bin
+
 
+
Extra modules:
+
  Install any extra modules (y or n)? [n] y
+
  Extras? Net::Daemon String::CRC32 File::Path File::Copy IO::Handle
+
 
+
Hard path to the perl installed on USB:
+
  What shall I put after the #! to start up perl ("none" to not use #!)?
+
  [none] /mnt/usb/usr/local/bin/perl
+
 
+
Other installation paths:
+
  Where do you keep publicly executable scripts? (~name ok)
+
  [.../] /mnt/usb/usr/share
+
 
+
  Pathname where the add-on public executables should be installed? (~name ok)
+
  [.../../bin] /mnt/usb/usr/bin
+
 
+
  Pathname where add-on public executable scripts should be installed? (~name ok)
+
  [.../../bin] /mnt/usb/usr/bin
+
 
+
  Pathname where the private library files will reside? (~name ok)
+
  [.../../lib/perl5/5.10.0]
+
 
+
  Installation prefix to use for add-on modules and utilities? (~name ok)
+
  [.../..]
+
 
+
  Pathname for the site-specific library files? (~name ok)
+
  [.../../lib/perl5/site_perl/5.10.0]
+
 
+
  Where do you want to put the public architecture-dependent libraries? (~name ok)
+
  [.../../lib/perl5/5.10.0/i686-linux-thread-multi]
+
 
+
===Extract the compiled Perl===
+
After running make, make test, and make install, you can pack the files under
+
 
+
  /mnt/usb/usr
+
 
+
This is all you need to run custom perl scripts on the chumby.
+
 
+
If you need any extra CPAN modules, you can install them before packing everything, calling perl with the full path to the executable:
+
 
+
  /mnt/usb/usr/local/bin/perl -MCPAN -e shell
+
 
+
This should allow you to compile and install any new CPAN modules directly in the /mnt/usb/usr/local/ path.
+
 
+
==Pre-compiled, ready-to-run Perl==
+
You can download here the Perl 5.10 compiled with threads suppport on the ARM emulator. This is the clean Perl install, with NO installed CPAN modules.
+
Currently threading is not completely compatible with the Chumby, since debian uses libc.2.3.6 and the Chumby uses libc.2.4, so avoid using threading, use forking instead.
+
  http://files.chumby.com/resources/Perl.5.10.threaded.arm.usb.working.tgz
+
  
Download here the Perl and the include libraries as they should be installed on a Chumby USB key. They will get unpacked in "usr", which will appear on the Chumby as /mnt/usb/usr.
+
GNU Debugger
This is the file that will get updated on a regular basis. This build contains some generic CPAN modules that can be useful when writing Perl scripts on the Chumby. Among them are the libwww package and the Mail::Sender package.
+
Subversion
  http://files.chumby.com/resources/Arm.usb.5.10.Chumby.tgz
+
GNU Screen
 +
tcpdump
 +
GNU Netcat
 +
NMap
 +
Pipe Viewer
 +
Lighttpd
 +
Python
  
If you are unpacking this on a FAT/FAT32 USB key, you will have an issue with the symlink to perl - namely the /mnt/usb/usr/local/bin/perl.5.10.0 > perl, that will not be created on a FAT/FAT32. To remedy this, copy the perl binary to the expected name:
+
If you are unpacking this on a FAT/FAT32 USB key, you will have an issue with the symlink to perl - namely the usr/bin/perl.5.10.0 > perl, that will not be created on a FAT/FAT32. To remedy this, copy the perl binary to the expected name:
  
   cd /mnt/usb/usr/local/bin/
+
   cd /mnt/usb
  cp perl.5.10.0 perl
+
  cp usr/bin/perl.5.10.0 /usr/bin/perl
  
 +
You can also use a shell script to set your environment, create the proper symlink in /psp and correct the missing file:
  
 +
#!/bin/sh
 +
if [ ! -e /psp/usr ]; then
 +
  if [ -e /mnt/storage/usr ]; then
 +
    ln -s /mnt/storage/usr /psp/usr
 +
  else
 +
    if [ -e /mnt/usb/usr ]; then
 +
      ln -s /mnt/usb/usr /psp/usr
 +
    else
 +
      echo "Could not find /mnt/storage/usr or /mnt/usb/usr"
 +
      exit 1
 +
    fi
 +
  fi
 +
fi
 +
if [ ! -f /psp/usr/bin/perl ]; then
 +
  if [ -f /psp/usr/bin/perl5.10.0 ]; then
 +
    # We run this from the USB as FAT32 and Perl was not correctly unpacked
 +
    echo "Making a working copy of Perl as /psp/usr/bin/perl"
 +
    cp /psp/usr/bin/perl5.10.0 /psp/usr/bin/perl
 +
    sync
 +
  else
 +
    echo "Could not find perl in /psp/usr/bin"
 +
    exit 1
 +
  fi
 +
fi
 +
if [ ! -e /tmp/home ]; then
 +
  mkdir /tmp/home
 +
fi
 +
export HOME=/tmp/home
 +
export PATH=/psp/usr/sbin:/psp/usr/bin:$PATH
 +
export LD_LIBRARY_PATH=/psp/usr/lib:$LD_LIBRARY_PATH
 +
export PS1="\[\e[36;1m\]\u\[\e[33;1m\]:\[\e[0m\]\w\[\e[32;1m\] > \[\e[0m\]"
 +
export TERM='ansi'
 +
export PERL_PATH=/psp/usr/bin/perl
 +
if [ -e /psp/usr/vimrc ]; then
 +
  cp /psp/usr/vimrc /tmp/home/.vimrc
 +
fi
  
 +
Save this as /mnt/usb/setdev, and invoke the following when you start your session:
  
Download here the packed /lib folder from the QEMU ARM environment.
+
source /mnt/usb/setdev
  http://files.chumby.com/resources/QemuARMLibs.tgz
+

Latest revision as of 11:28, 13 November 2009

The instructions for building Perl to work on the Chumby are found Here.

You will learn how to set up a development environment using Scratchbox, and compile your own Perl and applications.


Pre-compiled, ready-to-run Perl

Download here the Perl, the include libraries, and applications that can be installed on a Chumby USB key or in the Chumby ONE internal storage. They will get unpacked in "usr", which will appear on the Chumby as /mnt/usb/usr or as /mnt/storage/usr.

These files will be updated as necessary. They contain a baseline of applications useful when writing hacks for Chumby. Among them are the libwww, Mail::Sender, various XML and crypto packages; the whole list can be seen on the How-to page.

 http://files.chumby.com/resources/usr_arm_ext3_basicperl.tgz
 http://files.chumby.com/resources/usr_arm_ext3.tgz
 http://files.chumby.com/resources/usr_arm_fat32.tgz

The usr_arm_ext3_basicperl.tgz contains only basic things as:

Perl 5.10.0 with a lot of CPAN modules installed
id3v2
ImageMagick
vim

The other two contain all the applications listed on the How-to page, like:

GNU Debugger
Subversion
GNU Screen
tcpdump
GNU Netcat
NMap
Pipe Viewer
Lighttpd
Python

If you are unpacking this on a FAT/FAT32 USB key, you will have an issue with the symlink to perl - namely the usr/bin/perl.5.10.0 > perl, that will not be created on a FAT/FAT32. To remedy this, copy the perl binary to the expected name:

 cd /mnt/usb
 cp usr/bin/perl.5.10.0 /usr/bin/perl

You can also use a shell script to set your environment, create the proper symlink in /psp and correct the missing file:

#!/bin/sh
if [ ! -e /psp/usr ]; then
  if [ -e /mnt/storage/usr ]; then
    ln -s /mnt/storage/usr /psp/usr
  else
    if [ -e /mnt/usb/usr ]; then
      ln -s /mnt/usb/usr /psp/usr
    else
      echo "Could not find /mnt/storage/usr or /mnt/usb/usr"
      exit 1
    fi
  fi
fi
if [ ! -f /psp/usr/bin/perl ]; then
  if [ -f /psp/usr/bin/perl5.10.0 ]; then
    # We run this from the USB as FAT32 and Perl was not correctly unpacked
    echo "Making a working copy of Perl as /psp/usr/bin/perl"
    cp /psp/usr/bin/perl5.10.0 /psp/usr/bin/perl
    sync
  else
    echo "Could not find perl in /psp/usr/bin"
    exit 1
  fi
fi
if [ ! -e /tmp/home ]; then
  mkdir /tmp/home
fi
export HOME=/tmp/home
export PATH=/psp/usr/sbin:/psp/usr/bin:$PATH
export LD_LIBRARY_PATH=/psp/usr/lib:$LD_LIBRARY_PATH
export PS1="\[\e[36;1m\]\u\[\e[33;1m\]:\[\e[0m\]\w\[\e[32;1m\] > \[\e[0m\]"
export TERM='ansi'
export PERL_PATH=/psp/usr/bin/perl
if [ -e /psp/usr/vimrc ]; then
  cp /psp/usr/vimrc /tmp/home/.vimrc
fi

Save this as /mnt/usb/setdev, and invoke the following when you start your session:

source /mnt/usb/setdev