Saturday, May 29, 2010

Building on and for Knoppix


The Knoppix Live CD (http://knopper.net/knoppix/) is an excellent way to try out Linux on any PC with a CD-ROM drive. It won't store anything on your PC (unless you ask it to) and doesn't mess up any existing installations of Linux or Windows.

In this article, I'm going to describe how to build ROLF to run on Linux assuming a PC booted from an unmodified Knoppix 6.2 CD.

When done, you should have a working ROLF desktop being displayed in a window, able to run a few native ROLF programs and even some RISC OS programs, in a limited way. Simply by copying the directory into which you've installed ROLF to some permanent storage (a hard disc or a memory stick, for example), you can use the build again without having to go through the steps I describe.

Set up a build environment

Knoppix, unfortunately, doesn't include all the tools needed to build ROLF, so we have to get them from Debian first. (If your Linux system already includes these tools, you can obviously skip this step.)

First, get the full list of packages that are available:

sudo apt-get update

Then update the compiler to include the C++ compiler, needed to build the Server part of ROLF (the libraries are all plain C, but to build them, you need libtool).

sudo apt-get install build-essentials
sudo apt-get install subversion
sudo apt-get install libtool
sudo apt-get install pkg-config

After that has been done, the compiler will still refuse to compile C++ programs because it can't find cc1plus, for some reason. The simplest way to fix that is to add the path to the (just installed) cc1plus file installed to the PATH environment variable.

export PATH=$PATH:$(dirname $(find /ramdisk/ -name cc1plus 2>/dev/null | head -n 1))

Now, to get the source code:

svn co https://ro-lf.svn.sourceforge.net/svnroot/ro-lf ro-lf

(If you don't expect to make any changes to the code, you can instead use:
svn export https://ro-lf.svn.sourceforge.net/svnroot/ro-lf)

Knoppix (or Debian) have all their shared libraries taged by their version number; to make the files linkable, we need to do this:

mkdir lib
ln -s /usr/lib/libz.so.1 lib/libz.so
ln -s /usr/lib/libjpeg.so.62 lib/libjpeg.so
ln -s /usr/lib/libpng12.so.0 lib/libpng.so
ln -s /usr/lib/libfreetype.so.6 lib/libfreetype.so
ln -s /usr/lib/libstdc++.so.6 lib/libstdc++.so
ln -s /usr/lib/libmagic.so.1 lib/libmagic.so
sed -i 's/CFLAGS.*$/& -L$(CFGDIR)/lib' config.mak


Similarly, the build requires a set of include files [This bit needs an update!]

Specifically, the files needed are:

From zlib:
zlib.h, zconf.h

From libpng:
png.h, pngconf.h

From file:
magic.h

From libjpeg
jpeglib.h, jmorecfg.h, jconfig.h

From freetype 2:
./ft2build.h
./freetype/internal/internal.h
./freetype/fttypes.h
./freetype/ftsystem.h
./freetype/ftmoderr.h
./freetype/ftimage.h
./freetype/fterrors.h
./freetype/fterrdef.h
./freetype/freetype.h
./freetype/config
./freetype/config/ftheader.h
./freetype/config/ftconfig.h
./freetype/config/ftstdlib.h
./freetype/config/ftoption.h

sed -i 's/CFLAGS.*$/& -I$(CFGDIR)/my_includes' config.mak

Change directory into the downloaded code and run configure (not as complicated as a normal configure script) and build ROLF:

cd ro-lf/ROLF/rolf
./configure --appsdir=$HOME/Apps --prefix=$HOME --tarballs=`pwd`/tarballs/
make

Assuming all goes well with the build, the next step is to collect the resources needed in one place.

You will need:

  • Fonts (at least FreeSerif.ttf; the default font)
  • Tool and Icon sprites (I use Chris Wraight's Steel theme, from here: http://www.lym.iconbar.com/downloads/steel.zip)
  • A mimemap.txt file (if you're going to use RISC OS software)
  • and a !Boot file, to load them all (like the one below)


Create a resources directory with subdirectories:


mkdir -p Resources/fonts/{FreeSerif,FreeSans,FreeMono}
ln -s /usr/share/file/ Resources/
cd Resources/fonts
for i in *; do for f in $( find /KNOPPIX/ -name $i*.ttf ); do ln -s $f $i/ ; done ; done 2>/dev/null
# This one is needed for the Terminal application:
cp `find /KNOPPIX/ -name default8x16.psf* 2> /dev/null` .
cd ..
unzip Steel.zip
cd ..
cat > \!Boot <<"EOF"
IconSprites $ROLF_RESOURCES/Steel/Tools
IconSprites $ROLF_RESOURCES/Steel/Icons

LoadPointer $ROLF_RESOURCES/Steel/Icons ptr_default 0 21
LoadPointer $ROLF_RESOURCES/Steel/Icons ptr_double 0 21

# Match up icons with the appropriate mime types
if [ -f $ROLF_RESOURCES/mimemap.txt ] ; then ( grep -v ^# $ROLF_RESOURCES/mimemap.txt | tr -s '\t' | cut -f 1,3 | sort -k 2 | sed 's/\(.*\)\t\(.*\)$/IconSprite file_\2 "file_\1"/' | sh ) ; fi

# Load applications
IconBar
Filer Icon $HOME/Apps 50 romapps Apps
Filer Icon /tmp 40 ramfs ramfs
Filer Icon $HOME 45 homedisc Home
EOF


Now, we just have to run it!


export LD_LIBRARY_PATH=`pwd`/lib
export PATH=$PATH:`pwd`/bin

#Uncomment the next line if you need a log of what's happened (useful for debugging)
# ROLF_WIMP_LOG=/tmp/rolf_wimp_log \
ROLF_RESOURCES=`pwd`/Resources \
ROLF_VNC=1 \
Wimp


That should have the effect of printing:
VNC Server waiting for connections on port 2008.
New file descriptor 3
New Opaque bitmap VNCFrameBuffer, 1024x768


In another terminal window, type:

vncviewer localhost:2008


... and a colourful window with an icon bar and a couple of drive icons should appear!

I will follow this up with some more postings about running RISC OS software on ROLF, as well as implementations of NetSurf and MPlayer.

1 Comments:

Anonymous Calvin F said...

Hello mate, great blog

1:29 pm, June 16, 2022  

Post a Comment

Subscribe to Post Comments [Atom]

<< Home