ReferencePlatforms/Linux-scratchbox

From MozillaWiki
Jump to: navigation, search

This page has been created based on our existing steps and the steps used to create the new scratchbox. Because we now deploy scratchbox as a large tarball. This document has information about what is used on our reference Centos 5.0 32bit machine. Any changes to the reference platform should go in the appropriate reference platform document

Scratchbox as of Maemo4

Installing Scratchbox

As root:

wget http://repository.maemo.org/stable/chinook/maemo-scratchbox-install_4.0.1.sh
chmod a+x ./maemo-scratchbox-install_4.0.1.sh
./maemo-scratchbox-install_4.0.1.sh -s /scratchbox
/scratchbox/sbin/sbox_adduser cltbld yes

As cltbld:
Comment out the PYTHONHOME and PATH entries in ~/.bash_profile.

source ~/.bash_profile
wget http://tablets-dev.nokia.com/chinook/maemo-sdk-install_4.0.1.sh
chmod +x maemo-sdk-install_4.0.1.sh
bash maemo-sdk-install_4.0.1.sh
/scratchbox/login
wget http://ftp.gnome.org/pub/gnome/sources/libIDL/0.8/libIDL-0.8.9.tar.gz
tar -xzvf libIDL-0.8.9.tar.gz
cd libIDL-0.8.9
./configure --prefix=/usr
make
make install

Remove the comments from the PYTHONHOME and PATH entries in ~/.bash_profile and source it again.

Fixup Scratchbox Install

On Centos5, need to make the following changes to sysctl.conf

 $ su 
 # vi /etc/sysctl.conf
...and append
vm.vdso_enabled = 0
vm.mmap_min_addr = 4096 
 # 
 # /sbin/sysctl -p
...
vm.vdso_enabled = 0 
vm.mmap_min_addr = 4096
 # exit

...there is no need to reboot.


su -
cd ~ 
wget http://scratchbox.org/download/files/sbox-releases/stable/tarball/scratchbox-toolchain-cs2007q3-glibc2.5-arm6-1.0.7-3-i386.tar.gz
wget http://scratchbox.org/download/files/sbox-releases/stable/tarball/scratchbox-devkit-cputransp-1.0.7-i386.tar.gz
cd /
tar zxvf ~/scratchbox-toolchain-cs2007q3-glibc2.5-arm6-1.0.7-3-i386.tar.gz
tar zxvf ~/scratchbox-devkit-cputransp-1.0.7-i386.tar.gz
cd /scratchbox
wget https://bugzilla.mozilla.org/attachment.cgi?id=334232 
chmod a+x moz_scratchbox

cd /scratchbox/etc
mv resolv.conf resolv.conf.orig
cp /etc/resolv.conf .

# exit from running as root, now back to cltbld account.
/scratchbox/moz_scratchbox

sb-conf setup CHINOOK-ARMEL-2007 -c cs2007q3-glibc2.5-arm6 -d cputransp:debian-etch:doctools:maemo3-tools:perl -t /scratchbox/devkits/cputransp/bin/qemu-arm-cvs-m
sb-conf rootstrap CHINOOK-ARMEL-2007 http://repository.maemo.org/stable/4.0.1/armel/maemo-sdk-rootstrap_4.0.1_armel.tgz
sb-conf install CHINOOK-ARMEL-2007 -cedFGS
sb-conf select CHINOOK-ARMEL-2007

exit

wget http://repository.maemo.org/stable/chinook/maemo-sdk-nokia-binaries_4.0.1.sh
chmod +x maemo-sdk-nokia-binaries_4.0.1.sh
## following line failed out with permission errors
## sh ./maemo-sdk-nokia-binaries_4.0.1.sh 
## so did the following instead:
$ su -
# cd /scratchbox
# sh /home/cltbld/maemo-sdk-nokia-binaries_4.0.1.sh

Note: you'll have to space/more to the end of the EULA, and then enter 'I accept'



/scratchbox/login

wget http://people.mozilla.com/~vladimir/misc/execstack.armel
chmod a+x execstack.armel
fakeroot mv execstack.armel /usr/bin/execstack
execstack -c `find /lib/ -name \*.so.\* -type f`
execstack -c `find /usr/lib/ -name \*.so.\* -type f`
fakeroot echo "deb http://repository.maemo.org/extras-devel chinook free non-free" >> /etc/apt/sources.list
fakeroot echo "deb file:/home/$USER/maemo-sdk-nokia-binaries_4.0.1 chinook explicit" >> /etc/apt/sources.list
fakeroot apt-get update
fakeroot apt-get install libgtk2.0-dev libxaw7-dev libfreetype6-dev libxi-dev libhildonmime-dev libosso-dev libidl-dev liblocation-dev libasound2-dev

exit

Move scratchbox

You should have a /builds drive added to the VM before completing this section. All of this should be run as root.

Move scratchbox off root partition. Scratchbox takes up a non-trivial amount of space and should be moved to a different partition.

  # as root
  /etc/init.d/sbox stop
  umount /scratchbox/users/cltbld/dev/*	
  umount /scratchbox/users/cltbld/*
  mv /scratchbox /builds/scratchbox
  # scratchbox needs this symlink to function properly
  #  
  ln -s /builds/scratchbox /scratchbox
  /etc/init.d/sbox start

To verify that scratchbox is working, do:

$ moz_scratchbox
> ls
...
> exit
$

Update scratchbox mercurial and python

First, fix the DNS in scratchbox.

cp /etc/resolv.conf /scratchbox/users/cltbld/targets/CHINOOK_X86/etc/resolv.conf
cp /etc/resolv.conf /scratchbox/users/cltbld/targets/CHINOOK_ARMEL/etc/resolv.conf
cp /etc/resolv.conf /scratchbox/users/cltbld/targets/CHINOOK-ARMEL-2007/etc/resolv.conf

Allow cltbld to write to the tool areas

su -
chown -R cltbld /scratchbox/devkits/maemo3-tools
exit

Initial setup

/scratchbox/moz_scratchbox
wget http://people.mozilla.org/~asasaki/mercurial-1.1.2.tar.gz
tar zxvf mercurial-1.1.2.tar.gz
echo 'export PYTHONPATH=/usr/lib/python2.5/site-packages:$PYTHONPATH' >> .bashrc

Do the following for CHINOOK_X86, while still running /scratchbox/moz_scratchbox:

sb-conf select CHINOOK_X86
echo 'deb http://repository.maemo.org/extras/ bora free' >> /etc/apt/sources.list
apt-get update
yes | apt-get install python2.5 python2.5-dev python2.5-xml
cd /usr/bin
rm python; ln -s python2.5 python
cd ~/mercurial-1.1.2
python2.5 setup.py install
cd /scratchbox/devkits/maemo3-tools/bin
mv hg hg.old
mv hgmerge hgmerge.old
ln -s /usr/bin/hg .
hg --version

The hg --version should give you no errors.

Repeat for CHINOOK_ARMEL... but I was unsuccessful getting hg 1.1.2 installed/working there.

sb-conf select CHINOOK_ARMEL
echo 'deb http://repository.maemo.org/extras/ bora free' >> /etc/apt/sources.list
apt-get update
yes | apt-get install python2.5 python2.5-dev python2.5-xml
cd /usr/bin
rm python; ln -s python2.5 python

Repeat for CHINOOK-ARMEL-2007.

sb-conf select CHINOOK-ARMEL-2007
echo 'deb http://repository.maemo.org/extras/ bora free' >> /etc/apt/sources.list
apt-get update
yes | apt-get install python2.5 python2.5-dev python2.5-xml
cd /usr/bin
rm python; ln -s python2.5 python
cd ~/mercurial-1.1.2
python2.5 setup.py install
cd
hg --version
rm -rf mercurial-1.1.2*

Install libxdamage-dev and libxcomposite-dev in Scratchbox

/scratchbox/moz_scratchbox
sb-conf select CHINOOK_X86
apt-get install --force-yes -y libxdamage-dev libxcomposite-dev
sb-conf select CHINOOK_ARMEL
apt-get install --force-yes -y libxdamage-dev libxcomposite-dev
sb-conf select CHINOOK-ARMEL-2007
apt-get install --force-yes -y libxdamage-dev libxcomposite-dev

Install libhildon1-dev to scratchbox

/scratchbox/moz_scratchbox
apt-get install --force-yes -y libhildon1-dev

Install libnotify for scratchbox

/scratchbox/moz_scratchbox
apt-get install --force-yes -y libnotify-dev

Fix scratchbox wireless devel

/scratchbox/moz_scratchbox -p 'apt-get install --force-yes -y libiw-dev'

libhildonfm2-dev

Installed inside of scratchbox with the following command:

su - cltbld -c '/scratchbox/moz_scratchbox -p apt-get --yes --force-yes install libhildonfm2-dev

libconic0-dev

Installed inside of scratchbox with the following command:

su - cltbld -c '/scratchbox/moz_scratchbox -p apt-get --yes --force-yes install libconic0-dev'

access keys from within scratchbox

/bin/mount --bind /scratchbox/users/cltbld/home/cltbld/.ssh /home/cltbld/.ssh/

Updates for Maemo5

This update was deployed with Puppet

su -
unset PYTHONHOME
unset PYTHONPATH
export PATH=/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/cltbld/bin
umount /home/cltbld/.ssh #until no longer mounted
umount /builds/slave #might not be mounted
/scratchbox/sbin/sbox stop
/scratchbox/sbin/sbox_umount_all
sh maemo-scratchbox-install_5.0.sh -U -s /scratchbox
/etc/init.d/sbox start
exit
sh maemo-sdk-install_5.0.sh -y -d -s /scratchbox
/scratchbox/login
echo deb http://repository.maemo.org/fremantle/<token> nokia-binaries >> /etc/apt/sources.list
fakeroot apt-get install autoconf2.13 libnotify-dev libIDL-dev libqt4-dev
exit
/scratchbox/moz_scratchbox
sb-conf select FREMANTLE_ARMEL
wget http://www.python.org/ftp/python/2.5.5/Python-2.5.5.tar.bz2
tar jxf Python-2.5.5.tar.bz2
cd Python-2.5.5
make -j4
/scratchbox/moz_scratchbox
openssl md5 openssl-0.9.8m.tar.gz Python-2.5.5.tar.bz2 
#MD5(openssl-0.9.8m.tar.gz)= 898bf125370926d5f692a2201124f8ec
#MD5(Python-2.5.5.tar.bz2)= 1d00e2fb19418e486c30b850df625aa3
tar jxf Python-2.5.5.tar.bz2
tar zxf openssl-0.9.8m.tar.gz
cd openssl-0.9.8m
CC=host-gcc CXX=host-g++ ./config shared --prefix=/usr/local
make -j4
make install
cd Python-2.5.5
CC=host-gcc CXX=host-g++ ./configure --prefix=/usr/local
make -j4
make altinstall
find /usr/local -name "*.so*" -exec ldd {} \; | grep "not found" # should have no output

Host Python for Maemo4

This script will deploy a version of python + hg that is shared between fremantle and chinook

su -
cd /builds/scratchbox/users/cltbld/targets/FREMANTLE_ARMEL
rm -rf usr/local/lib/* usr/local/bin/* usr/local/include/* usr/local/ssl
find /builds/scratchbox/devkits/ -type d -name 'mercurial' -exec rm -rf {} \; 
find /builds/scratchbox/devkits/ -type d -name 'hgext' -exec rm -rf {} \; 
exit

/scratchbox/moz_scratchbox
wget http://mercurial.selenic.com/release/mercurial-1.5.1.tar.gz
wget http://www.python.org/ftp/python/2.5.5/Python-2.5.5.tar.bz2
wget http://www.openssl.org/source/openssl-0.9.8m.tar.gz
wget http://www.bzip.org/1.0.5/bzip2-1.0.5.tar.gz
mkdir jhford-py
cd jhford-py
tar zxf ../mercurial-1.5.1.tar.gz
tar zxf ../bzip2-1.0.5.tar.gz
tar jxf ../Python-2.5.5.tar.bz2
tar zxf ../openssl-0.9.8m.tar.gz

sb-conf select CHINOOK-ARMEL-2007
fakeroot apt-get remove python2.5

sed -i -e 's|export PYTHONPATH=/usr/lib/python2.5/site-packages:$PYTHONPATH||' ~/.bashrc
rm /usr/bin/hg

cd ~/jhford-py
cd openssl-0.9.8m
CC=host-gcc ./config shared --prefix=/host_usr
make -j4
fakeroot make install
cd ../bzip2-1.0.5/
make CC=host-gcc PREFIX=/host_usr install
make CC=host-gcc -f Makefile-libbz2_so
cp libbz2.so.1.0* /host_usr/lib/
cd ../Python-2.5.5
CC=host-gcc CXX=host-g++ ./configure --prefix=/host_usr
make -j4
make install
cd ../mercurial-1.5.1
python2.5 setup.py install --prefix=/host_usr