################################################################# # Document: armedslack/source/scratchbox/SETUP_SCRATCHBOX.txt # Purpose : Describe how to setup Scratchbox to build ARMedslack # on your Slackware 9.1 x86 system # Author..: Stuart Winter # based on information from www.scratchbox.org # Date....: 08-Feb-2004 ################################################################# 1.0 Base installation ----------------- 1.1 Add the user 'build' and group 'sbox' to your Slackware x86 system ``````````````````````````````````````````````````````````````````` Much of ARMedslack references this user 'build', so you need to use the same name. # groupadd sbox # adduser build # Enter 'sbox' as its additional group 1.2 Install Scratchbox: ``````````````````` # for i in *.gz ; do tar zxf $i -C/ ; done 1.2.1 Fix the gcc3 specs file so that it produces code for ARMv3 by default rather than the ARMv4 which does not work correctly on the StrongARM RiscPC ```````````````````````````````````````````````````````````````````````````` perl -pi -e 's?^-D__ARM_ARCH_4T__?-D__ARM_ARCH_3__?;' \ /scratchbox/compilers/arm-linux-glibc/arm-linux/lib/gcc-lib/arm-linux/3.3.2/specs \ /scratchbox/compilers/arm-linux-glibc/lib/gcc-lib/arm-linux/3.3.2/specs \ /scratchbox/compilers/arm-linux-uclibc/lib/gcc-lib/arm-linux/3.3.1/specs 1.3 Start scratchbox: ````````````````` # /scratchbox/run_me_first.sh * Accept defaults *: Do you want to use sudo mode? [yes/no] (no): no Give the name of the scratchbox group (sbox): 1.4 Add the user to scratchbox `````````````````````````` # /scratchbox/sbin/sbox_adduser build 1.5 Login as the 'build' user to the localhost & start scratchbox ````````````````````````````````````````````````````````````` ** You'll want to set the compiler name here -- use sbox-config -lc to view which are the current compilers ** # su - build # /scratchbox/login You are now inside the Scratchbox. # sbox-config -lc # find armv3l compiler, 'armv3l-linux-gcc-3.3_3.3.2ds5-glibc-2.3.2.ds1' [ You can use qemu rather than talking to an ARM box but qemu (at present) has lots of unsupported system calls so I'd rather run my ARM binaries on an ARM box ] -cm sbrsh -cm qemu-arm # ( sbox-config -ct ARM \ -cn arm-linux-gcc-3.3_3.3.2ds5-glibc-2.3.2.ds1 \ -cm qemu-arm \ --devkits=debian sbox-config --select-target=ARM sbox-config -cc sbox-config -cf ) bash won't build if sbrsh is being chatty: # echo 'unset SBOX_CPUTRANSPARENCY_VERBOSE' >> .bashrc # echo 'export SBOX_UNAME_MACHINE=arm' >> .bashrc 1.6 Fix up the header files ``````````````````````` ** I'm not sure if this is necessarry :: FIX ME ** # ( cd /usr/include/asm ; rm -f arch ; ln -s arch-rpc arch ) 1.7 Back to your root console on the __host x86 Slackware system__ ``````````````````````````````````````````````````````````````` Install Slackware's /etc/group & passwd. Note to self: I need to remember to keep these two files uptodate with Slackware's 'etc' package. # ( cd /scratchbox/users/build/home/build/armedslack-current/source/slackdev/installdata cp -fa group passwd shadow /scratchbox/users/build/targets/ARM/etc ) 1.8 Install the Slackware /var/ directories required for package management ``````````````````````````````````````````````````````````````````````` # ( cd /scratchbox/users/build/targets/ARM/var mkdir log mkdir -p log/scripts log/packages log/setup/tmp mkdir -m1777 tmp ) 1.9 Create a '/install' for makepkg to use `````````````````````````````````````` # ( mkdir -p /scratchbox/users/build/targets/ARM/install chown build.users /scratchbox/users/build/targets/ARM/install cd /scratchbox/users/build/targets/links ln -fs /targets/ARM/install . chown build.users install cd /scratchbox/users/build ln -fs /targets/links/install . ) Ensure & relax ownerships # ( chown -R build.users /scratchbox/users/build/targets/ARM /scratchbox/device_tools chmod -R u+rw /scratchbox/users/build/targets/ARM chown build.users /scratchbox/users/build /scratchbox/users/build/home ) 1.8 tar up the clean base Scratchbox/ARMedlack file system `````````````````````````````````````````````````````` This clean file system contains fresh, configured ARM target. Many .build scripts use this to freshen the file system to avoid packaging up files that do not belong to other packages. Within Scratchbox it is possible to clean the target using # sbox-config -rt You can then use the instructions above to re-create the required Slackware directories. You may want to do this if you accidentally delete your clean file system archive. # ( cd /scratchbox/users/build/targets tar pjcf /scratchbox/users/build/home/build/armedslack-current/source/slackdev/cleanfs/cleanfs_SB-0.9.8.tar.bz2 ARM ) 2.0 Installing Slackware utilities into Scratchbox ---------------------------------------------- This section will eventually disappear when I build a Slackware devkit for Scratchbox. 2.1 Install the pkgtools ```````````````````` Become root on your x86 Slackware host. ( cp -a /sbin/*pkg* /scratchbox/tools/bin perl -pi -e 's?TAR=.*?TAR=/scratchbox/tools/bin/tar-1.13?;' /scratchbox/tools/bin/*pkg* ) Fix up installpkg so that it deletes the contents of /install after installing a package. It can't delete the /install dir from within the scratchbox because it's owned by root. Deleting just the contents is fine. # perl -pi -e 's?rm -rf install?rm -rf install/* install?;' /scratchbox/tools/bin/installpkg Install altertrack (this my package building tool for Slackware). You must install it onto your x86 Slackware system first. You can either download it from http://www.interlude.org.uk/unix/slackware or obtain it from the x86 Slackware tree ( slackware-current/extra ) # ( cp -fa /usr/bin/altertrack /scratchbox/tools/bin/ perl -pi -e 's?MAKEPKG=.*?MAKEPKG=/scratchbox/tools/bin/makepkg?;' /scratchbox/tools/bin/altertrack ) 2.2 Compile some tools for use within Scratchbox ```````````````````````````````````````````` We need to build a few additional tools inside scratchbox. Enter into the scratchbox environment (you do not need to be root on x86 Slackware for the following steps). 2.3 Compilie tar-1.13 `````````````````` tar-1.13 is required by Slackware package tools as no other version works correctly. I assume you have a full copy of Slackware-current in your scratchbox user's build directory. This is what I do. ( cd ~/slackware-current/source/a/tar tar zxf tar-1.13.tar.gz -C/tmp CWD=$PWD cd /tmp/tar-1.13 zcat $CWD/bzip2-tar.diff.gz | patch -p1 CC=host-gcc CFLAGS=-O2 ./configure && make ) Now, as root on your x86 Slackware host (not within scratchbox) # mv -f /tmp/tar-1.13/src/tar /scratchbox/tools/bin/tar-1.13 2.4 nano editor ``````````` Inside Scratchbox: # ln -fs /scratchbox/tools/bin/nano /host_usr/bin/pico 2.5 Compile texinfo ```````````````` ** NO LONGER REQUIRED ** makeinfo is required to build info files ( cd ~/armedslack-current/source/ap/texinfo tar jxf texinfo*bz2 -C/tmp cd /tmp/texinfo* CC=host-cc ./configure --prefix=/host_usr && make && make install ) 3.0 Configuring Scratchbox for CPU transparency ------------------------------------------- At this point you need to have ARMedslack installed onto your RiscPC/ARM machine. 3.1 Add NFS export entries to your x86 Slackware host `````````````````````````````````````````````````` The uids should be the uid of the user 'build' and the gid of the group 'sbox'. Note that the anonuid is 1001. This is the UID of my 'build' user on my x86 Slackware system. You need to ensure yours is correct. If you want to be more secure, you should tighten down the exports to a single host. However, I'm not interested in doing this because my LAN is secure. cat << EOF > /etc/exports / 192.168.1.0/255.255.255.0(rw,no_root_squash,sync) /scratchbox/users/build/targets/ARM 192.168.1.0/255.255.255.0(sync,rw,all_squash,anonuid=1001,anongid=100) /scratchbox/users/build/home 192.168.1.0/255.255.255.0(sync,rw,all_squash,anonuid=1001,anongid=100) EOF Restart the services: # /etc/rc.d/rc.portmap restart # /etc/rc.d/rc.nfsd restart 3.2 Installing sbrshd onto your ARM box ``````````````````````````````````` As root on your x86 Slackware host; You'd need 'PermitRootLogin Yes' set in /etc/ssh/sshd_config on your ARM box, so if you don't have that or don't want to set that then copy it to some other user's account or use another way to copy the sbrshd daemon across. # scp /scratchbox/device_tools/arm/sbrshd-1.3.25.glibc-2.3.2 armbox:/bin/sbrshd Add the users and groups to the ARM box. You need to execute the commands below on your ARM box # ( echo "sbox:x:102:build" >> /etc/group echo "build:x:1001:100::/home/build:/bin/bash" >> /etc/passwd echo "build:$1$zrP0J1dd/$9ddsgGUW7xZExpJF8LOaK0:12432:0:99999:7:::" >> /etc/shadow cd /home mkdir build chown -R build.users build ) You need to set the IP address below to the IP of the machine on which scratchbox runs # echo '192.168.1.2 password' > /home/build/.sbrshd Launch the sbrshd server on the ARM box # /bin/sbrshd 3.3 Configuring the password and ARM target server inside Scratchbox As root on your x86 Slackware host; You need to configure the IP addresses. 192.168.1.13 is my ARMedslack RiscPC 192.168.1.2 is my x86 Slackware scratchbox & NFS server # cd /scratchbox/users/build/home/build # cat << EOF > .sbrsh ARM 192.168.1.13 password nfs 192.168.1.2:/scratchbox/users/build/targets/ARM / rw,nolock,noac nfs 192.168.1.2:/scratchbox/users/build/home /home rw,nolock,noac bind /dev /dev bind /proc /proc bind /tmp /tmp EOF # chown -R build.users . 4.0 Finishing up the installation ----------------------------- You may want Scratchbox to start when your system boots. As root on your 86 Slackware host; # cat << EOF >> /etc/rc.d/rc.local # Start scratchbox: /scratchbox/sbin/sbox_ctl start EOF