Tuesday 31 August 2010

LAP - Workbench 3.1 HDD Installation

The start of this installation is much easier. With the 3.1 rom and Workbench 3.1, you can easily format the disk. Start the procedure in exactly the same way as with 1.3. This time you get to name it first. Call it System again, in the New Volume Name box. You also want to tick the Trashcan, Fast File System and Directory Cache boxes. The international mode one will select itself. This is OK. Hit format a couple of times and it will get started.

Now run the Installation utility on the install disk. It should auto detect your System: hard disk and choose to install there. That's what we are after. Don't bother with printers and choose your language and keyboard appropriately.

It will then prompt you to insert the other disks in turn.

The most efficient way to install Workbench is to use all 4 drives (we set the config file to allow us to do this). You want to load the disks as follows:

df0:Install
df1:Workbench
df2:Locale
df3:Extras

When it asks for 'Fonts', use the GUI to change the drives to the following:

df0:Install
df1:Fonts
df2:Storage

Technically, we could now stop, and say that we have installed Workbench 3.1. After all we have reached the same point as Workbench 1.3. However, Workbench 3.1 can support a replacement graphics drivers, so lets install that now as well. The drivers let us use higher screen resolutions that the standard Amiga - hopefully native to our display.

As has become customary there are some dependencies, and we need to download these. Very basically, they are a program for uncompressing the downloaded archives and one for installing software.

umount -v /media/amiga
sudo mkdir /media/lfs 
sudo mount -v -t ext3 /dev/disk/by-label/amiga /media/lfs 
cd /media/lfs/sources/amiga

wget http://aminet.net/util/arc/lha.run
wget http://uk.aminet.net/util/misc/Installer-43_3.lha
#wget http://aminet.net/driver/video/Picasso96.lha
wget http://guide.abime.net/wb3.1/files/Picasso96.lha

You may need to retry a couple of those. The aminet system is not always available. Once these are downloaded boot to the Amiga Key and shift them to the ~/amiga/shared folder:

cd /sources/amiga
mv *.lha ~/amiga/shared
mv *.run ~/amiga/shared

Now, run the Amiga 1200HD:
uae -G -f ~/amiga/A1200HD.uaerc
And open a shell window. I should point out at this stage that I am mostly following the excellently presented and written guide here. You should absolutely follow those instructions, which have been painstakingly researched, and carefully presented with step by step illustrations of every possible dialogue box that you may face. Contrast with with my instructions herein which mostly consist of copying and pasting text from LFS and BLFS while making puerile comments about package names, and raging incoherently as a result of my own, painful, limitations. What follows is but a summary of the Green Amiga Alien's excellent advice.

lha is the main amiga archiving program. Think 'tar'. Install it as follows:
protect Shared:lha.run +e
Shared:lha.run ram:
The first command changes the settings of the program lha.run which is on the Shared: device to allow us to [e]xecute it. The second executes the file. It directs the output to ram:, which is the ramdisk.
Copy ram:lha_68020 C:lha 
A number of programs pop out, compiled for particular CPUs. We are using a 68020, so copy that one to [C:] (where system programs live) and call it [lha]. Next we are going to use the new lha to uncompress and install the installer program. This will let us install the other packages that are following shortly.
lha x Shared:Installer-43_3.lha ram:
Copy ram:Installer43_3/Installer C: 
Picasso, as mentioned, is the native Amiga driver for the graphics card we are emulating. After it is installed we should get loads of new graphical modes to suit our modern screen.
lha x Shared:picasso96.lha ram: 
We are finished with the shell for a little while. if you now double click on the ramdisk you should see the Picasso folder. Open it up and run the setup program. You can answer 'yes' to most stuff. When asked about where to put the support files, choose system:storage. You then go to System->Prefs->ScreenMode, NOT Picasso96Mode. Choose a uaegfx: mode that suits your monitor's resolution.

This worked, but I got pointer trails which stuck around on the screen. I re-formatted the hard disk, reinstalled Workbench and installed the version of Picasso96 from the Green Amiga Alien's guide. I didn't get any trails with that version. I am not sure what the difference is, so I have left a command to download the aminet version above, but commented it out so pasting it to the command line will not do anything. Solving why one works and another does not is a an unsolved problem for the time being.

You can also add the A1200HD machine to the Openbox menu in the same way as with the A500HD. Under the menu-id="euae-menu" section we added last time, you would add in:
<item label="A1200HD">
<action name="Execute"><execute>/usr/bin/uae -G -f ~/amiga/A1200HD.uaerc</execute></action>
</item>
Pop this in before the line at the end of the "euae-menu" section:
</menu>

Monday 30 August 2010

LAP - Workbench 1.3 HDD Installation

There is an obvious way to run Workbench 1.3 and that is by simply booting from the floppy disk like the vast majority of A500 users would have had to do. However, we are not so restricted with the emulator, and we have already set up a configuration with a hard disk. So let's install Workbench 1.3 to the hard disk.

This is tricky, because although we are only really copying two disks (the Workbench Disk and the Extras Disk), the a500 does not natively support a hard disk. What happened if you bought a hard disk for an a500 (such as the A590) was that it came with a some ROM software on it which allowed the disk to be recognised.

If you boot the A500HD system that we have configured, you won't see the Hard Disk. There is a work around for this, but it is a bit tricky, so lets take our time. What we are going to do is boot from a Kickstart 2.04 ROM (as found in the A500+) and use that to format the Hard Disk. We are then going to extract a file from the Workbench disk, and put it in our Roms directory. As best as I can guess this file effectively does the job of the ROM chip originally found on the A590.

So, what you need to do is put a Kickstart 2.04 ROM into the ~/amiga/roms directory. You then boot the A500HD...

uae -f ~/amiga/A500HD.uaerc

...but use the GUI to swap from the Workbench 1.3 ROM to the 2.04 ROM. You also need to load the Workbench 1.3 disk into df0:.

Once Workbench has started up, the hard disk should now show up, as an icon with a funny name: "dh0: ndos". You select that and then choose Icon->Format from the top of the screen (hold down the right mouse button, move to the word Icon, move to the option Format in the drop down menu that appears, and let go of the mouse button). Say yes a couple of times, and it should start formatting.

Once you are done, select the new disk (now called "Empty") and choose Icon->Rename at the top and call it System. You can now shutdown the emulator. If you restart the A500HD system now it should revert to the 1.3 ROM, meaning that once again the hard disk will no longer be visible.

Now is the trickiest bit. We need to extract the file system information from the Workbench disk, and store a copy in the ~/amiga/roms directory. To get at the ~/amiga/roms directory from inside the Amiga, we need to mount it. Start up the A500HD system, and in the GUI, go to the Hard Disks tab, and choose 'add'. Then, in the dialogue box that pops up, choose select and navigate INTO the /root/amiga/roms directory. Then click OK. The path box should now show:

/root/amiga/roms

Then in the 'device name' box, put dh1 (the disk we just formatted is set up as dh0). In 'Volume name' put temp. Click OK and start the emulation.

Once it is up and running, double click on the Workbench 1.3 disk, and double click on 'shell' in the window that opens. From there run the following command to copy the file system information to the temporarily linked roms directory:

COPY L:FastFileSystem temp:

This [COPY]s the file [FastFileSystem] from the folder named [L] directory to the folder named [temp]. Note that the Amiga system assigns names to folders. The [L] folder is on df0:, but can be referred to simply as [L]. Equally, we could have (I think) copied to [dh1:] instead of [temp:] and it should not have made a difference. Next, quit the emulator, exit the GUI. Apparently we should now get access to the hard disk using the 1.3 ROM and 1.3 Workbench. Did I get access? Did I fuck.

I restarted the emulation and got no fucking hard disk the first few times. I carefully checked the messages coming from the xterm window from which I had started the emulator. The messages indicated that the emulator was looking for the file "FastFileSystem". I had the file "fastfilesystem". Bugger. I realised I had typed:

COPY L:fastfilesystem temp:

And it turns out that this is very case sensitive. I sorted out my mistake with the following:

mv ~/amiga/roms/fastfilesystem ~/amiga/roms/FastFileSystem 

The next time I booted, I got a shiny new System disk on the desktop. With 1.3 you do not get a fancy HDD icon. To install Workbench, with the Workbench disk in df0: and extras in df1:, open the 'shell' program again, and run:

COPY DF0: System: ALL 
COPY DF1: System: ALL 

Which seems to be perfectly sensible commands to me. Then quit the
shell:

endcli

And reboot. It should boot straight to the Workbench from the HDD. To boot straight to the Workbench 1.3 desktop you would amend the line in .xinitrc to read:

exec /usr/bin/uae -G -f ~/amiga/A500HD.uaerc &

If you want to create a menu entry for openbox (assuming you installed it) you would add the following text to the [~/.config/openbox/menu.xml] file:

<menu id="euae-menu" label="Emulated Amigas">
<item label="A500HD">
<action name="Execute"><execute>/usr/bin/uae -G -f ~/amiga/A500HD.uaerc</execute></action>
</item>
</menu>

I would suggest sticking it between the Multimedia and System sections. You would then add the line...

<menu id="euae-menu"/>

... to the section at the end of the file, again between Multimedia and System.

Friday 27 August 2010

LAP - E-UAE (Configuration)

We now have the Amiga Emulator up and running. We could now do just about everything we want to with the GUI configuration panel. However, a better option is to make configuration files for each different type of Amiga that we are going to be emulating.

First of all we are going to tidy up our /root folder. By now it is probably full of installation scripts. I would delete everything apart from the startx scripts, the compression instructions, and the wifi scripts. I made a new amiga folder to store the new settings and files:
mkdir ~/amiga
mkdir ~/amiga/roms
mkdir ~/amiga/disks
mkdir ~/amiga/harddisks
mkdir ~/amiga/shared

The folder names should give away the nature of the contents. We will store the configuration files in the ~/amiga folder. The [shared] folder is going to be treated like a harddisk by the Amiga, so I can easily pass files to and from the Amiga. I have moved the disk and rom images to the appropriate folder.

I am going to set up four machines, an A500, an A1200 and the same two but with hard disks installed. The first thing I am going to do is to make the files that will be treated as harddisks. TO do this I am going to use linux's [dd] program. The program is used to copy stuff at a very low level. The commands are as follows:

dd if=/dev/zero of=~/amiga/harddisks/A500_hdd.hdf bs=512 count=40960
dd if=/dev/zero of=~/amiga/harddisks/A1200_hdd.hdf bs=512 count=81920 

The commands copy from the [i]nput [f]ile [/dev/zero] (which is obviously blank) to the [o]utput [f]ile named, in 512 [b]yte[s] chunks. For the A500 we use 40960 chunks of 512 bytes, which should get us a 20Mb disk. The A1200 should get a 40Mb file.

First of all, we'll create the simplest machine - the A500. The configuration file is just a text document, and the '#' comment tag works as normal. I am going to structure the file into theme'd sections. I'll start with the Disk drives, as these are the most likely to be changed in an edit. Then we'll have the Amiga hardware to be emulated. Next will be a section which governs the speed or accuracy of the emulator. After that is a section which relates to the hardware of the source system, and finally is a section which sets the default paths to the folders we have made.

The first time we do this, I'll comment on everything, and then on subsequent builds only the changes.

cat > ~/amiga/A500.uaerc << "EOF"
#Disks Files 
floppy0=$(FILE_PATH)/1.3a.adf 
floppy1=$(FILE_PATH)/1.3b.adf

EOF

This loads two disk images. Workbench 1.3 comes on 2 disks, and I have renamed them to a and b. The emulator can handle 4 floppy disk drives, but by default only two work. You can peruse the documentation to see how to activate the other two, if you really want. We can use the [$(FILE_PATH)] instead of the absolute path to the files. We'll define the variable at the end of the file.

cat >> ~/amiga/A500.uaerc << "EOF"
#Amiga Hardware 
cpu_type=68000 
chipset=ecs_agnus 
kickstart_rom_file=$(FILE_PATH)/1.3.rom 
chipmem_size=2 
bogomem_size=0 
fastmem_size=0 
z3mem_size=0 
gfxcard_size=0 

EOF

Note that we are [>>] appending to the file now, not [>] over writing. We are emulating a [68000] cpu for the A500. We are going to use the ecs_agnus chipset present in later A500's as it allows us to use more RAM. We need Kickstart 1.3 for the A500. We also are telling it to use 1Mb of chip ram. It is measured in 512Kb chunks - hence the [2]. We are not using any other types of RAM.

cat >> ~/amiga/A500.uaerc << "EOF"
#Performance 
cpu_speed=real 
cpu_compatible=false 
cpu_cycle_exact=false 
cachesize=0
immediate_blits=false 
collision_level=playfields 
gfx_framerate=1 
sound_latency=100 
x11.low_bandwidth=false 
floppy_speed=100 

EOF

We are asking the machine to simulate the cpu at the normal speed. In other words no matter how powerful your machine the emulation should run at the speed of a real A500. If some software doesn't work you can flip [cpu_compatible] to true, and it will try to be even more exact, but potentially slower as well. If that still doesn't work, then you can flip the [cpu_cycle_exact] to true, which makes the cpu to chipset communications more precise.

The [cachesize] set to 0 diables the JIT system. This only works on 68020 cpu's so we do not need it. [immediate_blits] set to false makes sure the system doesn't cut some corners. Setting this to true may speed up the emulation. [collision_level=playfields] is about how precisely the emulation calculates collisions between objects (the player and a platform in a game for instance). The documentation explains how to change this if necessary.

The [gfx_framerate] tells it to show every frame. If this was 10, it would only show one frame in 10. The [sound_latency] sets the wiggle room the system has to synchronise the sound. [x11.low_bandwidth] if set to true reduces the information exchanged with the X server. It only updates the bits of the video which change from frame to frame. This ends up looking crap - as if you are using the system through VNC down a 56k modem line. [floppy_speed] is in %. You can increase it to as much as 800, but that may cause compatibility problems.

cat >> ~/amiga/A500.uaerc << "EOF"
#Host Hardware 
gfx_width_windowed=720 
gfx_height_windowed=568 
gfx_fullscreen_amiga=true 
hide_cursor=true 
show_leds=true 
sound_output=normal 
sound_bits=16 
sound_frequency=44100 
sound_channels=stereo 
joyport0=mouse 
joyport1=kbd2 
bsdsocket_emu=true 
x11.map_raw_keys=false 

EOF

The [gfx_{width,height}_windowed] options set the size of the window. There are options for fullscreen resolution as well, but the documentation is honest enough to admit that does nothing. We want to boot straight to the Amiga, so we tell it to [fullscreen]. We do not want to see the X cursor - just the Amiga cursor, so we [hide_cursor]. The [show_leds] put a graphical representation of the floppy and HDD activity lights. It also reports the frame rate and cpu usage. The [sound] options are all pretty self explanatory. The Amiga had two ports for mice or joysticks. Here we tell it the mouse is connected to [joyport0]. We tell it [joyport1] has a joystick attached to it which is simulated by the arrow keys and the right CTRL as the fire button [kbd2]. There are other options which are set out in the docs. The [bsdsocket_emu] turns on the network sharing that we enabled back in the compilation of the emulator. The [x11.map_raw_keys] relates to how the keys on your PC are mapped to the keys in the simulated Amiga keyboard.

cat >> ~/amiga/A500.uaerc << "EOF"
#Defaults 
unix.rom_path=~/amiga/roms 
unix.floppy_path=~/amiga/disks 
unix.hardfile_path=~/amiga/harddisks 
unix.savestate_path=~/amiga/saves 
EOF

These settings just tell the emulator the default location for the various file types. That also finishes the configuration file. The A500 can now be emulated by:

uae -G -f ~/amiga/A500.uaerc

This disables the [G]ui so that the emulator will start fullscreen.

Now for the HD version:

cat > ~/amiga/A500HD.uaerc << "EOF"
#Disks Files 
#floppy0=$(FILE_PATH)/1.3a.adf 
#floppy1=$(FILE_PATH)/1.3b.adf
hardfile2=rw,dh0:/root/amiga/harddisks/A500_hdd.hdf,32,1,2,512,1, 

#Amiga Hardware 
cpu_type=68000 
chipset=ecs_agnus 
kickstart_rom_file=$(FILE_PATH)/1.3.rom 
chipmem_size=4
bogomem_size=0 
fastmem_size=8
z3mem_size=0 
gfxcard_size=0 

#Performance 
cpu_speed=real 
cpu_compatible=false 
cpu_cycle_exact=false 
cachesize=0 
immediate_blits=false 
collision_level=playfields 
gfx_framerate=1 
sound_latency=100 
x11.low_bandwidth=false 
floppy_speed=100 

#Host Hardware 
gfx_width_windowed=720 
gfx_height_windowed=568 
gfx_fullscreen_amiga=true 
hide_cursor=true 
show_leds=true 
sound_output=normal 
sound_bits=16 
sound_frequency=44100 
sound_channels=stereo 
joyport0=mouse 
joyport1=kbd2
bsdsocket_emu=true 
x11.map_raw_keys=false 

#Defaults 
unix.rom_path=~/amiga/roms 
unix.floppy_path=~/amiga/disks 
unix.hardfile_path=~/amiga/harddisks 
unix.savestate_path=~/amiga/saves
EOF

We have commented out the floppy so that it boots from the hard disk. It makes it easy to activate the disks to install workbench in the first place. The [hardfile2] activates the file we made as [dh0:]. No real idea what all the settings guff at the end does, but it seems to work. I have also installed 8Mb of fast ram, and upped the chip ram to 2Mb.

cat > ~/amiga/A1200.uaerc << "EOF"
#Disks Files 
#floppy0=$(FILE_PATH)/3.1b.adf 
#floppy1=$(FILE_PATH)/3.1a.adf 

#Amiga Hardware 
cpu_type=68ec020 
chipset=aga 
kickstart_rom_file=$(FILE_PATH)/3.1.rom 
chipmem_size=4 
bogomem_size=0 
fastmem_size=0 
z3mem_size=0 
gfxcard_size=0 

#Performance 
cpu_speed=max 
cpu_compatible=false 
cpu_cycle_exact=false 
cachesize=8192 
immediate_blits=false 
collision_level=playfields 
gfx_framerate=1 
sound_latency=100 
x11.low_bandwidth=false 
floppy_speed=100 

#Host Hardware 
gfx_width_windowed=720 
gfx_height_windowed=568 
gfx_fullscreen_amiga=true 
hide_cursor=true 
show_leds=true 
sound_output=normal 
sound_bits=16 
sound_frequency=44100 
sound_channels=stereo 
joyport0=mouse 
joyport1=kbd2 
bsdsocket_emu=true 
x11.map_raw_keys=true 

#Defaults 
unix.rom_path=~/amiga/roms 
unix.floppy_path=~/amiga/disks 
unix.hardfile_path=~/amiga/harddisks 
unix.savestate_path=~/amiga/saves 
EOF

The Workbench floppies are there as suggestions. The [a] disk is the install for 3.1, and the [b] disk is the normal 'workbench' disk. The CPU type and chipset match the hardware in the A1200. We also use 2Mb [4]x512k of chipram. We switch to Kickstart 3.1. We change CPU speed to [max] because we do not want to be restricted to running at the speed of a A500. We have also changed the [cachesize] to 8192 (meaning 8Mb) which activates the JIT compiler. The rest is the same.

And lastly, the HD version, which is going to be the most powerful.

cat > ~/amiga/A1200HD.uaerc << "EOF"
#Disk Files 
#floppy0=$(FILE_PATH)/3.1b.adf 
#floppy1=$(FILE_PATH)/3.1a.adf
floppy2type=0
floppy3type=0
hardfile2=rw,dh0:/root/amiga/harddisks/A1200_hdd.hdf,32,1,2,512,1, 
filesystem2=rw,dh1:Shared:/root/amiga/shared,0

#Amiga Hardware 
cpu_type=68020 
chipset=aga 
kickstart_rom_file=$(FILE_PATH)/3.1.rom 
chipmem_size=4 
bogomem_size=0 
fastmem_size=0 
z3mem_size=256
gfxcard_size=32

#Performance 
cpu_speed=max 
cpu_compatible=false 
cpu_cycle_exact=false 
cachesize=8192 
immediate_blits=false 
collision_level=playfields 
gfx_framerate=1 
sound_latency=100 
x11.low_bandwidth=false 
floppy_speed=100 

#Host Hardware 
gfx_width_windowed=720 
gfx_height_windowed=568 
gfx_fullscreen_amiga=true 
hide_cursor=true 
show_leds=true 
sound_output=normal 
sound_bits=16 
sound_frequency=44100 
sound_channels=stereo 
joyport0=mouse 
joyport1=kbd2
bsdsocket_emu=true 
x11.map_raw_keys=false

#Defaults 
unix.rom_path=~/amiga/roms 
unix.floppy_path=~/amiga/disks 
unix.hardfile_path=~/amiga/harddisks 
unix.savestate_path=~/amiga/saves 
EOF

The first change is the [floppy{2,3}type] option. By default df2: and df3: are deactivated. By setting their types to '0' we activate them. I know that sounds unintuitive, but a setting of -1 means deactivated. We want as many active floppies as possible for doing stuff like installing Workbench. I have commented out the Workbench disks, as they should not be needed on a regular basis. Best to refer to them though, so we can quickly activate them if the HDD corrupts.

We have had to switch to the 68020 CPU rather than the cut down 68ec020 that is actually in the A1200. The reason is that we need 32 bit memory addressing rather than 24 bit memory addressing
to support the extra memory [z3mem] and [gfxcard] we are going to use. The Z3 memory emulates memory being added in a Zorro III slot. The gfxcard memory is going to be used by the Picasso96 emulated graphics card to get a high resolution desktop. There were expansion cards for the A1200 which supplied a full 68020 and 256Mb of Zorro III ram, so this is historically accurate.

To boot straight into the Amiga, add this to .xinitrc before the openbox-session line:

exec /usr/bin/uae -G -f ~/amiga/[whatever].uaerc &

Thursday 26 August 2010

LAP - E-UAE (Install)

Now, download the disk format library into the /sources/amiga folder by using the LiveCD:

umount -v /media/amiga 
sudo mkdir /media/lfs 
sudo mount -v -t ext3 /dev/disk/by-label/amiga /media/lfs 
cd /media/lfs/sources/amiga
wget -O ipfdevlib_linux.tgz -- http://www.softpres.org/_media/files:ipfdevlib_linux.tgz?id=download&cache=cache

Hit enter to exit the program once 100% download has been reached. We have to use the [O] option which saves the download to the file we name after the [O] because otherwise we get a stupidly named file. The downside is we apparently need to exit the download manually by hitting enter.

In order to test the IPF support, you will obviously need a disk image in IPF format.  One of the best places to legally download these is the Dream 17 website.  Dream 17 have permission from the Amiga developer Team 17 to distribute their games.  You should download these in IPF format - if you can.  I chose to test this with Alien Breed.  Once I had downloaded the images, I uncompressed the archive and copied them into the root folder on the Amiga key with sensible names.

cd /sources/amiga
tar -xzvf ipfdevlib_linux.tgz 

tar -xjvf e-uae-0.8.29-WIP4.tar.bz2 
cd e-uae-0.8.29-WIP4 
./configure --prefix=/usr --enable-jit --enable-natmem \
--enable-autoconfig --enable-threads --with-sdl-gfx \
--enable-aga --disable-scsi-device --enable-bsdsock --with-caps \
--with-caps-prefix=/sources/amiga/ipfdevlib_linux --with-alsa \
--with-x | tee config_report.txt

That is a hell of a lot more options that we have used before. Lets look at the extra ones. [jit] allows the emulator to execute 68020 code natively on your CPU. This speeds up the a1200 operation but does nothing for an a500. [natmem] works alongside [jit] and gives the emulation direct access to your system RAM. [autoconfig] turns out not to be what I thought it was. Instead of autoconfiguring the emulator, this instead autoconfigures the emulated machine to use virtual hardware that you add. Probably didn't need this before.

[threads] lets the emulator make use of any extra cores your CPU may have. [aga] allows emulation of the chipset of the a1200. [scsi-device] gets disabled because I do not intend to emulate any scsi devices AND because it has dependencies that we have not met when building the system. [bsdsock] lets the emulated amiga use the linux network connection. Essential to get internet. [caps] tells it to build in support for the IPF disk format, and [caps-prefix] tells it where to find the files we just downloaded an uncompressed. [alsa] and [x] should be self explanatory.

Lets just check it found the caps/IPF stuff:

cat config_report.txt | grep caps
checking caps/capsimage.h usability... yes
checking caps/capsimage.h presence... yes
checking for caps/capsimage.h... yes 
Well, thats good.

make $CORES_TO_USE
Test it:
./src/uae -r ~/1.3.rom -0 ~/1.3.adf

And test it with the IPF image you chose at the beginning (I went for Alien Breed):
./src/uae -r ~/1.3.rom -0 ~/ab1.ipf

That did not work. I got a warning dialogue and the following message:
Unable to open libcapsimage.so.2
.Failed to load CAPS plug-in.

Right, we must have to install from the IPF source as well as compiling it into e-uae. There is a readme file for the IPF source and it has the instructions for installing the library. No configure/make stuff required. We just copy the library straight to /usr/lib.

cp -v ../ipfdevlib_linux/lib/i686/libcapsimage.so.2.0 /usr/lib/
ldconfig

I then ran the test again and it now works just fine.  Now, finally, install e-uae and copy the documentation:

make install
install -v -d -m755 /usr/share/doc/e-uae
install -v -m644 docs/* /usr/share/doc/e-uae

Now clean up:

cd ..
rm -rvf e-uae-0.8.29-WIP4 
rm -rvf ipfdevlib_linux 

Wednesday 25 August 2010

LAP - SDL

As we discovered earlier, the emulator will not go fullscreen without the SDL package being installed. I'm unclear exactly what SDL does, but it appears to include, amongst other things, a fairly low level interface with the video hardware.

umount -v /media/amiga 
sudo mkdir /media/lfs 
sudo mount -v -t ext3 /dev/disk/by-label/amiga /media/lfs 
cd /media/lfs/sources
mkdir extras
chmod -v a+wt extras
cd extras
wget http://www.libsdl.org/release/SDL-1.2.13.tar.gz

Then from the Amiga Key:

cd /sources/extras 
tar -xzvf SDL-1.2.13.tar.gz
cd SDL-1.2.13
./configure --prefix=/usr
make $CORES_TO_USE
make install
install -v -m755 -d /usr/share/doc/SDL-1.2.13/html
install -v -m644 docs/html/*.html /usr/share/doc/SDL-1.2.13/html
ldconfig
cd ..
rm -rvf SDL-1.2.13

Once I had done all that, I needed to recompile the emulator to build in GTK and SDL functions. I decided to delete the source directory to start from scratch, just in case.

cd /sources/amiga
rm -rvf e-uae-0.8.29-WIP4 
tar -xjvf e-uae-0.8.29-WIP4.tar.bz2 
cd e-uae-0.8.29-WIP4 
./configure --enable-autoconfig --with-sdl-gfx | tee config_report.txt 
make $CORES_TO_USE
And let's test it:
./src/uae -r ~/1.3.rom -0 ~/1.3.adf 

Happily it now starts up with a GUI to let us change settings. We can get this back once the emulator is running by changing back to the GUI window, which does not go away.  We can also hit [F12 + F{1-4}] to get straight to a dialogue to change the mounted disk images. Also, and delightfully, [F12 + S] now gets us fullscreen Amiga action.

Lets just tidy up once more, because next we are going to do a final build of the emulator with the IPF image support and all the other bells and whistles what we may need.

cd ..
rm -rvf e-uae-0.8.29-WIP4

Tuesday 24 August 2010

LAP - Openbox

This, I should point out, is another entirely optional step.  Feel free to skip over it if the shitieness of twm does not irritate you.

twm, which is the window manager that BLFS installs with X, is crap. It generates the crappy green title bars and the left click menu. At least it is small and works, after a fashion. There is an alternative. Actually, there are many, many alternatives, but we are just going to use one of them. Openbox looks much better, and it adds stuff like virtual desktops (CTRL + ALT + left/right arrows to switch desktops). The emulator, and anything else you want to run, will still work fine without Openbox, it will just look greener and crappier. The main requirement for Openbox is GTK, and we have just installed that, so Openbox itself should be a doddle.

The only dependency that we are going to install is libxml2 which is a library for accessing (or parsing) xml files.  I think, although I am far from certain, that Openbox stores its configuration settings in .xml files, whic essentially means that it needs to be able to read xml files to be able to work.

umount -v /media/amiga 
sudo mkdir /media/lfs 
sudo mount -v -t ext3 /dev/disk/by-label/amiga /media/lfs 
cd /media/lfs/sources
mkdir desktop
chmod -v a+wt desktop
cd desktop 
wget http://xmlsoft.org/sources/libxml2-2.7.6.tar.gz 
wget http://openbox.org/dist/openbox/openbox-3.4.11.1.tar.gz 

Then from the Amiga Key:

cd /sources/desktop
tar -xzvf libxml2-2.7.6.tar.gz
cd libxml2-2.7.6
./configure --prefix=/usr
make $CORES_TO_USE
make $CORES_TO_USE check

Screeds and screeds of crap followed by:

Ran 0 tests, no errors 
Total 0 tests, no errors

Makes no sense whatsoever. It also complains about a missing part:

xmlconf/xmlconf.xml is missing
you need to fetch and extract the
latest XML Conformance Test Suites
http://www.w3.org/XML/Test/xmlts20080205.tar.gz
see http://www.w3.org/XML/Test/ for informations
I am ignoring that.
make install
cd ..
rm -rvf libxml2-2.7.6

Now for Openbox itself:
tar -xzvf openbox-3.4.11.1.tar.gz
cd openbox-3.4.11.1
./configure --prefix=/usr --sysconfdir=/etc --disable-startup-notification \
--disable-session-management
make $CORES_TO_USE
make install

I then replaced the existing ~/.xinitrc file with this one. Openbox's menu is accessed on a blank part of the desktop using the right mouse button.
cat > /root/.xinitrc << EOF
# Begin .xinitrc file
#xterm  -g 80x20+0+0   &
#xclock -g 100x100-0+0 &
exec openbox-session
EOF

cd ..
rm -rvf openbox-3.4.11.1

A quick reboot confirmed it is working. Looks MUCH better. Now lets configure openbox so that it fits our system. First of all, Openbox had installed some default configuration files in [/etc/xdg/openbox/]. These are menu.xml which sets up the right click menu, rc.xml which sets up the actual display and operation of the windows themselves, and finally autostart.sh which runs various setup commands prior to Openbox starting. We will just leave autostart.sh and rc.xml alone, as they are doing their jobs fine.

The default menu for Openbox looks bizarre for our system. We have no GUI programs apart from E-UAE and xterm, so what's the point? We'll need to replace the menu.xml with our own version. To do that, first of all make a hidden folder in our home drive, and then copy all the default configuration files into it:

mkdir -p ~/.config/openbox
cp /etc/xdg/openbox/*.* ~/.config/openbox

Then replace the menu.xml with this one:

cat > ~/.config/openbox/menu.xml << "EOF"
<?xml version="1.0" encoding="UTF-8"?>

<openbox_menu xmlns="http://openbox.org/3.4/menu">

<menu id="apps-editors-menu" label="Editors">
<item label="nano">
<action name="Execute">
<command>xterm -e /usr/bin/nano</command>
<startupnotify>
<enabled>yes</enabled>
</startupnotify>
</action>
</item>
</menu>

<menu id="apps-term-menu" label="Terminals">
<item label="Xterm">
<action name="Execute"><command>xterm</command></action>
</item>
</menu>

<menu id="apps-net-menu" label="Internet">
<item label="lynx">
<action name="Execute">
<command>xterm -e /usr/bin/lynx</command>
<startupnotify>
<enabled>yes</enabled>
</startupnotify>
</action>
</item>
</menu>

<menu id="apps-multimedia-menu" label="Multimedia">
<item label="alsamixer">
<action name="Execute">
<command>xterm -e /usr/bin/alsamixer</command>
<startupnotify>
<enabled>yes</enabled>
</startupnotify>
</action>
</item>
</menu>

<menu id="system-menu" label="System">
<item label="Openbox Configuration Manager">
<action name="Execute">
<command>obconf</command>
<startupnotify><enabled>yes</enabled></startupnotify>
</action>
</item>
<separator />
<item label="Reconfigure Openbox">
<action name="Reconfigure" />
</item>
</menu>

<menu id="root-menu" label="Openbox 3">
<separator label="Applications" />
<menu id="apps-editors-menu"/>
<menu id="apps-net-menu"/>
<menu id="apps-multimedia-menu"/>
<menu id="apps-term-menu"/>
<item label="E-UAE Emulator">
<action name="execute"><execute>/usr/bin/uae</execute></action>
</item>
<separator label="System" />
<menu id="system-menu"/>
<separator />
<item label="Log Out">
<action name="Exit">
<prompt>yes</prompt>
</action>
</item>
</menu>

</openbox_menu>
EOF
That all looks quite complicated, but it really isn't. It is split into two sections. The first defines the various submenus, and then the second section actually sets out the menu structure.

Because we have no GUI programs other than xterm and e-uae (which we will install shortly) we need to configure the other programs to be run through xterm. So for instance the [command] to run [alsamixer] is:

xterm -e /usr/bin/alsamixer

That tells the system to run [xterm] and [e]xecute the program [/usr/bin/alsamixer].

Now, if you log out and then back in, you should get a sensible right click menu which will load the applications that we have - either directly or through an xterm window.

Monday 23 August 2010

LAP - GTK

Right, before we can have nice dialogue boxes for UAE to switch disks while it is up and running (the F12 + F1 key combo), we need to install a toolkit. As best as I can gather this is effectively the graphical equivalent of ncurses. It helps build user interfaces. We are going to use GTK, which is the toolkit that Gnome is based on. This is the GTK that e-uae's configure command complained was missing, so hopefully this should sort it out.

GTK is based on three separate packages, Cairo which is a 2d graphics library, Pango which is a library for text display, and ATK which does accessibility stuff like magnifiers. Pango and ATK require Glib2, which is some sort of low level difficult stuff library. It is easy to get confused between Glib2 and Glibc. They have nothing to do with each other; the 'G' in Glib2 stands for Gnome, whereas in Glibc it stands for Gnu. So that's cleared that up then. Glib2 in turn depends upon PCRE, which is a Perl plugin which does regular expression searching and matching.

Cairo needs libpng, pixman and fontconfig, all of which we installed with X. GTK also wants, but does not strictly need, libtiff, which is another graphics library like libpng and libjpeg.

Lets get all that downloaded first:

umount -v /media/amiga
sudo mkdir /media/lfs
sudo mount -v -t ext3 /dev/disk/by-label/amiga /media/lfs
cd /media/lfs/sources
mkdir desktop
chmod -v a+wt desktop
cd desktop
wget http://cairographics.org/releases/cairo-1.8.10.tar.gz 
wget http://downloads.sourceforge.net/pcre/pcre-8.00.tar.bz2 
wget http://ftp.gnome.org/pub/gnome/sources/glib/2.22/glib-2.22.4.tar.bz2
wget http://ftp.gnome.org/pub/gnome/sources/pango/1.26/pango-1.26.2.tar.bz2
wget http://ftp.gnome.org/pub/gnome/sources/atk/1.28/atk-1.28.0.tar.bz2
wget http://download.osgeo.org/libtiff/tiff-3.9.2.tar.gz
wget http://ftp.gnome.org/pub/gnome/sources/gtk+/2.18/gtk+-2.18.7.tar.bz2

Then from xterm in the amiga system run these commands:

cd /sources/desktop
tar -xzvf cairo-1.8.10.tar.gz
cd cairo-1.8.10
./configure --prefix=/usr
make $CORES_TO_USE
make $CORES_TO_USE check
make[5]: Leaving directory `/sources/gtk/cairo-1.8.10/test' 
make[4]: *** [check-am] Error 2 
make[4]: Leaving directory `/sources/gtk/cairo-1.8.10/test' 
make[3]: *** [check-recursive] Error 1 
make[3]: Leaving directory `/sources/gtk/cairo-1.8.10/test' 
make[2]: *** [check] Error 2 
make[2]: Leaving directory `/sources/gtk/cairo-1.8.10/test' 
make[1]: *** [check-recursive] Error 1 
make[1]: Leaving directory `/sources/gtk/cairo-1.8.10' 
make: *** [check] Error 2 

Still, the book said:
Note that as many as 29 of the tests are known to fail for unknown reasons. If you do not have a gs binary in your path, many of the 205 tests will fail.

Shame there wasn't some sort of summary here. Also I do not know what a 'gs' binary is.
make install
cd ..
rm -rvf cairo-1.8.10

tar -xjvf pcre-8.00.tar.bz2
cd pcre-8.00
./configure --prefix=/usr \
--docdir=/usr/share/doc/pcre-8.00 \
--enable-utf8 --enable-unicode-properties \
--enable-pcregrep-libz \
--enable-pcregrep-libbz2

The [utf8] and [unicode-properties] are about text localisation stuff. The [libz] and [libbz2] inform it about the gzip and bzip2 compression software.

You will also have noticed that we are using the [\] character at the end of lines. This appears quite frequently in the LFS and BLFS instructions, but until recently I have not been using it. What is does, simply, is break a command over several lines. Without it, if a command was long enough it could wrap around to another line, and the terminal would interpret the wrapping as the end of one command and the beginning of another. This would cause great confusion.

In my blog I can use text boxes with unlimited width which means commands can be as long as they like. The LFS book cannot do this, because it is designed to be printed and printed books do not have slider bars. However, by this point of the build there is a good chance that you are using the Lynx text browser, or a simple text file containing the commands to copy them to an xterm window. As a result the word wrap problem has returned. For safety of copying and pasting, then, I am retaining the [\] convention in the book. There is a really important point here. The [\] character absolutely must be the last character on the line for the wrap not to be detected as the end of the command. Sometimes in copying and pasting an extra space gets accidentally included. If you have a problem compiling this stuff, look back over your commands, and make sure that no such spaces have crept in.

make $CORES_TO_USE
make $CORES_TO_USE check
================== 
All 5 tests passed 
================== 
Well, that's better.

make install

We need to do a quick move and link, just in case we ever build /usr on another partition.

mv -v /usr/lib/libpcre.so.* /lib/
ln -v -sf ../../lib/libpcre.so.0 /usr/lib/libpcre.so
cd ..
rm -rvf pcre-8.00

tar -xjvf glib-2.22.4.tar.bz2
cd glib-2.22.4
./configure --prefix=/usr --with-pcre=system
make $CORES_TO_USE
make $CORES_TO_USE install

We may want to check this software but we would need to install desktop-file-utils first. We are not going to bother with that for this particular build, but it is worth pointing out anyway. If we wanted to do this, we need to change permissions stuff:

chmod -v 755 /usr/bin/gtester-report
make $CORES_TO_USE check

We also need to set an environmental variable in /etc/profile so that glib2 knows about locale bullshit.

cat > /etc/profile.d/glib2-locale.sh << "EOF"
# Use the current locale charset for filenames
# in applications using GLib
export G_FILENAME_ENCODING=@locale
EOF
cd ..
rm -rvf glib-2.22.4

tar -xjvf pango-1.26.2.tar.bz2
cd pango-1.26.2
./configure --prefix=/usr --sysconfdir=/etc
make $CORES_TO_USE
make $CORES_TO_USE check
============= 
1 test passed 
============= 
Again, much better.

make install
cd ..
rm -rvf pango-1.26.2

tar -xjvf atk-1.28.0.tar.bz2
cd atk-1.28.0
./configure --prefix=/usr
make $CORES_TO_USE
make install
cd ..
rm -rvf atk-1.28.0

tar -xzvf tiff-3.9.2.tar.gz
cd tiff-3.9.2
./configure --prefix=/usr
make $CORES_TO_USE
make $CORES_TO_USE check
================== 
All 4 tests passed 
================== 
Fantastic.

make install
cd ..
rm -rvf tiff-3.9.2

tar -xjvf gtk+-2.18.7.tar.bz2
cd gtk+-2.18.7
./configure --prefix=/usr --sysconfdir=/etc
make $CORES_TO_USE
make $CORES_TO_USE check
Gtk-WARNING **: cannot open display: :101 
aborting... 
FAIL: testing 
Terminated 
Hmm. That does not look good. Lets forge ahead anyway and see what happens. Also, having googled this a little bit it seems to be something to do with the X server accepting remote connections. Which I care not a jot about.

make install
install -v -m755 -d /usr/share/doc/gtk+-2.18.7/{faq,tutorial}
cp -v -R docs/faq/html/* /usr/share/doc/gtk+-2.18.7/faq
cp -v -R docs/tutorial/html/* /usr/share/doc/gtk+-2.18.7/tutorial
install -v -m644 docs/*.txt /usr/share/doc/gtk+-2.18.7
cd ..
rm -rvf gtk+-2.18.7

We could go straight back and recompile e-uae to allow for changing disks, but since we also want to fix the fullscreen issue, and that will require recompiling e-uae also, we'll do SDL first.

I return from the far future to advise the reader that, in fact, that error in the check routine made absolutely no difference to the operation of the GTK+ powered graphical interface for e-uae.

Friday 20 August 2010

LAP - Slim

To boot straight to the graphical interface without facing a login screen will require a login manager. I am trying to keep things simple, so a simple login manager would be ideal. A [S]imple [L]og[I]n [M]anager you say? Hmmm.

We need to download again, so set up the key in the LiveCD:

umount -v /media/amiga
sudo mkdir /media/lfs
sudo mount -v -t ext3 /dev/disk/by-label/amiga /media/lfs
cd /media/lfs/sources

We'll make another download folder for this stuff:

mkdir desktop
chmod -v a+wt desktop
cd desktop
wget http://www.ijg.org/files/jpegsrc.v7.tar.gz
wget http://download.berlios.de/slim/slim-1.3.2.tar.gz

We then reboot to the Amiga Key.  The first package here is a jpeg library.  This gives the system the ability to process jpeg image files.  SLIM depends on this to draw graphical backdrops to the login.  You see, SLIM really does keep it simple.  Ubuntu, or any of the big distro's, have a complicated login screen with drop down menus and lots of different options.  Nothing wrong with that, unless you cannot be arsed and just want a simple way to get straight to a graphical user interface.  SLIM manages the graphical login by just throwing a jpeg image on the screen with some white space in it for the username and password to be entered (which we will not ordinarily see because we will auto login straight past it).

cd /sources/desktop
tar -xzvf jpegsrc.v7.tar.gz
cd jpeg-7
./configure --prefix=/usr --enable-static --enable-shared
make
make test

rm -f testout* 
./djpeg -dct int -ppm -outfile testout.ppm  ./testorig.jpg 
./djpeg -dct int -bmp -colors 256 -outfile testout.bmp  ./testorig.jpg 
./cjpeg -dct int -outfile testout.jpg  ./testimg.ppm 
./djpeg -dct int -ppm -outfile testoutp.ppm ./testprog.jpg 
./cjpeg -dct int -progressive -opt -outfile testoutp.jpg ./testimg.ppm 
./jpegtran -outfile testoutt.jpg ./testprog.jpg 
cmp ./testimg.ppm testout.ppm 
cmp ./testimg.bmp testout.bmp 
cmp ./testimg.jpg testout.jpg 
cmp ./testimg.ppm testoutp.ppm 
cmp ./testimgp.jpg testoutp.jpg 
cmp ./testorig.jpg testoutt.jpg

make install
cd ..
rm -rf jpeg-7
ldconfig
And now for SLIM itself:

tar -xzvf slim-1.3.2.tar.gz 
cd slim-1.3.2 
sed -i -e "s:^MANDIR=.*:MANDIR=/usr/share/man:" -e "s:/usr/X11R6:/usr:" Makefile 
sed -i -e 's#X11R6/##g' -e 's#/usr/bin:##' -e 's/# daemon/daemon/' slim.conf

Also nano slim.conf - before or after install - to make the default user 'root' and uncomment out (remove the '#') auto login. I dare say there is a way to [sed] that command, but I have not studied under a sed master for the last 20 years, so I have no fucking clue what such a command would look like. It would probably have a [#] in it, some [///], a few [$] and possibly a [{] or two.

make $CORES_TO_USE 
make install 
cat >> /etc/inittab << EOF 
x:5:respawn:/usr/bin/slim >& /dev/null 
EOF 
cd .. 
rm -rf slim-1.3.2 

Then nano /etc/inittab and change the number in the first line to 5 instead of 3.  The [cat >> /etc/inittab] command adds a line to tell it what to do when it boots to a graphical login.  It basically runs the [slim] program in [/usr/bin].  It is possible to make slim a daemon (a type of program that runs in the background) but that is complicated and involves boot scripts.  This way is much neater and easier.

Welcome to swift booting straight to the desktop.

Thursday 19 August 2010

LAP - E-UAE (Graphics Test)

Now that we have a GUI, we can try E-UAE again, this time without the highly amusing curses text mode. Actually, what we achieved in the last step was pretty significant. We now have a graphical user interface for our operating system. If we run the command:

xterm & 

In the xterm window, we can open another xterm window. We can also do this by left clicking anywhere on the desktop background and selecting xterm from the menu that pops up. This means that we can copy and paste commands to the command line again, which in turn means no more stupid scripts. Ideally, what you can do now is fire up the Lynx browser in a separate xterm window, and copy and paste directly from the blog posts:
lynx http://justbloodywork.blogspot.com
If you haven't bothered, or been able, to configure networking what you probably want to do is copy and paste this blog post (and the other ones coming up) and save them as text files in the /root folder on the Amiga Key. You then use two xterm windows, one with 'nano' viewing the text file, and the other to paste the commands.

Copying and pasting using xterm is a bit tricky. You highlight the text in the 'nano' window. There is no 'copy' key - as soon as the text is highlighted, it is good to go. You then move the mouse pointer over to the other xterm window and press the middle mouse button (simulated on a track pad by pressing the left and right mouse buttons at the same time) to paste. Note, it pastes at the position of the text entry cursor - NOT the mouse pointer.

So, from the Amiga Key, switch into the amiga source code directory and unpack the code again. Technically, back when we cleaned up after the text test E-UAE we could have just [make clean]ed the source directory. To avoid any possibility of contamination though, I prefer to delete the folder and unpack from scratch.

cd /sources/amiga
tar -xjvf e-uae-0.8.29-WIP4.tar.bz2
cd e-uae-0.8.29-WIP4
./configure --enable-autoconfig | tee config_report.txt 

Note, we have removed the curses option. Next, compile:

make $CORES_TO_USE 

Again, lets not install the software immediately. We are still in the testing phase. Lets try the rom first:

./src/uae -r ~/1.3.rom 

Woo, hoo. It popped up and asked me where to put the window first of all (just like I was running a new xterm), it then fired up the graphical window displaying the Amiga screen looking for a floppy. Lets give it one. According to the documentation for E-UAE you hit [F12 + F1] to insert a disk in drive df0: Did that. Nothing happened. No menu popped up asking for a disk. Also, you are supposed to be able to make it go fullscreen by hitting [F12 + S], which does nothing. Hmm. I quit by clicking in the xterm that I ran the program from, and used [CTRL + C] followed by [quit]. I then ran:
./src/uae -r ~/1.3.rom -0 ~/1.3.adf 

And it actually booted Workbench! Still can't switch disks or go fullscreen though. Lets have a look at the compile log:
nano /sources/amiga/e-uae-0.8.29-WIP4/config_report.txt

I spotted the following text:

checking for sdl-config... no 
checking for SDL - version >= 1.2.0... no 
*** The sdl-config script installed by SDL could not be found 
*** If SDL was installed in PREFIX, make sure PREFIX/bin is in 
*** your path, or set the SDL_CONFIG environment variable to the 
*** full path to sdl-config. 
and

checking for GTK+ - version >= 2.0.0... no 
*** Could not run GTK+ test program, checking why... 
*** The test program failed to compile or link. See the file config.log 
for the 
*** exact error that occured. This usually means GTK+ is incorrectly 
installed. 
checking for gtk-config... no 
checking for GTK - version >= 1.0.0... no 
*** The gtk-config script installed by GTK could not be found 
*** If GTK was installed in PREFIX, make sure PREFIX/bin is in 
*** your path, or set the GTK_CONFIG environment variable to the 
*** full path to gtk-config. 

This suggests that we do not have some things called GTK and SDL. GTK is a toolkit which allows buttons, menus, etc etc to be created. Like menus that let us switch disks while the emulator is running. SDL lets us run in fullscreen, which we also want. So we obviously want those two packages.

Part of my goal is also to boot straight to the Amiga, which requires me to boot straight to the graphical interface. This will require an auto login function. This last requirement simplest, relatively speaking, to fix. So lets do that first. Clean up first:
cd /sources/amiga/
rm -rvf e-uae-0.8.29-WIP4

Wednesday 18 August 2010

LAP - X - Part 8, Drivers And Configuration

The very last theme'd package we install are the X drivers. These are the bits of software that allow the xorg server to speak to your hardware. If you remember we trimmed the install files to just install the stuff we wanted. I have made a couple of comments, but essentially this is the same operation that we applied to the other themes.

sudo cat > inst_6_driver.sh << "ARSE"
cd /sources/xorg/driver
for package in $(grep -v '^#' ../driver-7.5-2.wget)
do
packagedir=${package%.tar.bz2}
tar -xf $package
cd $packagedir
case $packagedir in
xf86-input-evdev-[0-9]* | xf86-video-ati-[0-9]* | xf86-video-fbdev-[0-9]* | xf86-video-glint-[0-9]* | xf86-video-newport-[0-9]* )
sed -i -e "s/\xc3\xb8/\\\\[\/o]/" -e "s/\xc3\xa4/\\\\[:a]/" -e "s/\xc3\x9c/\\\\[:U]/" man/*.man
;;
esac
#
#All we have just done is to say, if the filename matches any of the five examples, then wave some [sed] fairy dust over the documentation files to make sure they will be readable.
#
./configure $XORG_CONFIG --with-xorg-module-dir=$XORG_PREFIX/lib/X11/modules
#
#The [module-dir] was set in the configuration variables of Xserver last time.
#
make $CORES_TO_USE
make install
cd ..
rm -rvf $packagedir
done 2>&1 | tee -a ../driver-7.5-2-compile.log
echo "Next: ~/conf_xorg.sh"
ARSE
chmod +x ./inst_6_driver.sh
sudo mv ./inst_6_driver.sh /media/lfs/root

We also need to run a couple of configuration commands, which I am going to script - you'll see why when you read them. They are both to do with filesystem compatibility. First we have to make a symbolic link to allow older software to still find X, and secondly we need to move soft programs to where FHS says they should be. When BLFS says:
(ensure you modify <$XORG_PREFIX> appropriately)

What it means, for us, is that the '<' and '>' characters need to be removed.

sudo cat > conf_xorg.sh << "ARSE"
ln -vsf $XORG_PREFIX /usr/X11R6
mkdir -p /etc/X11 &&
for file in $XORG_PREFIX/{lib/X11/xinit,share/X11/{app-defaults,twm}}
do
mv -v $file /etc/X11/ 2> /dev/null &&
ln -v -s /etc/X11/$(basename $file) $file
done
echo "Move to home [cd ~]"
echo "Xorg -configure"
echo "X -retro -config ~/xorg.conf.new"
echo "to test the settings.  Assuming they work, setup the X environment by running ~/conf_xorg_files.sh"
ARSE
chmod +x ./conf_xorg.sh
sudo mv ./conf_xorg.sh /media/lfs/root

Now all we should have to do is move to home:

cd ~

and run the configuration script:

Xorg -configure

This should create a new file in ~, called xorg.conf.new. We should now be able to test the installation by running Xorg based on that file:

X -retro -config ~/xorg.conf.new

This did not go well on my first try. The machine I was testing it on uses an nVidia graphics card. Xorg detected this in the configure stage and the [conf] file refered to the 'nv' driver (I had chosen to build it during my first installation by not commenting it out of the .wget file). However, it just crashed with a segmentation fault. I then tried changing the driver manually using 'nano' to vesa. This worked – it created a 1280x1024 display. I also tried fbdev, and this worked with a 1024x768 screen. I could only quit from the displays by holding [CTRL + ALT + F1] to switch back to the first terminal, and then [CTRL + C] to quit the running program.

I suspect what has happened here is the xorg 'nv' driver is shite. I could probably resolve this by installing the closed source nvidia drivers at this point. I think, however, that I will test on the laptop first.

(Sound of laptop testing)

The laptop test went great. The system detected the intel card and it worked first time. On a subsequent build I chose not to install the 'nv' driver, and the step above just used the fbdev driver, which worked fine.

I went back to the desktop machine and downloaded the latest 32bit nvidia drivers for linux. They came in a [.run] file. I downloaded this to my /sources/xorg folder by running these commands from the USB Key:

umount -v /media/amiga
sudo mkdir /media/lfs
sudo mount -v -t ext3 /dev/disk/by-label/amiga /media/lfs
cd /media/lfs/sources/xorg/driver
wget http://uk.download.nvidia.com/XFree86/Linux-x86/256.35/NVIDIA-Linux-x86-256.35.run
cat > ./inst_nv.sh << EOF
./NVIDIA-Linux-x86-256.35.run --x-prefix=/usr --kernel-source-path=/sources/linux-2.6.32.8 --no-precompiled-interface -a
EOF
chmod +x ./inst_nv.sh

The eagle eye'd amongst you will have noticed that I have snuck in a script there. That's the command to install the driver, and it is a bit of a monster, so it's best to script it in. I'll mention when we should run this. I then booted the amiga key. Now the nvidia driver require access to the kernel source code, so we have to decompress it:

cd /sources
cat linux.tar.lzma | lzma -d | tar x
rm -rf linux.tar.lzma

Now we need to make the file we downloaded executable:

cd xorg/driver/
chmod +x NVIDIA-Linux-x86-256.35.run

Finally we need to run it ...

./NVIDIA-Linux-x86-256.35.run --x-prefix=/usr --kernel-source-path=/sources/linux-2.6.32.8 --no-precompiled-interface -a
or
./inst_nv.sh

... if we saved the script I mentioned. You should be asked if you want to write a xorg.conf. Agree to this.

What I was left with was two xorg.conf files. One in /etc/X11/ and one in ~ with a [.new] extension. One worked with my nvidia powered desktop and the other worked with my intel powered compaq netbook. So, I did this:

cp /etc/X11/xorg.conf /etc/X11/xorg.conf.nvidia
mv ~/xorg.conf.new /etc/X11/xorg.conf.intel

If you refused to allow the nvidia installer to create the xorg.conf, or for some reason you need to rebuild an nvidia xorg.conf in the future you would run this command from a machine with nvidia hardware:

nvidia-xconfig --output-xconfig=/etc/X11/xorg.conf.nvidia

And if you want to rebuild the intel xorg.conf, you would run this from a machine with intel hardware:

Xorg -configure
mv ./xorg.conf.new /etc/X11/xorg.conf.intel

I am now able to switch between them, depending on the machine I am using, as follows:

cp --force /etc/X11/xorg.conf.nvidia /etc/X11/xorg.conf
cp --force /etc/X11/xorg.conf.intel /etc/X11/xorg.conf

To make the switching easier, I made the following scripts (run the command to make then using the LiveCD).

sudo cat > ./startx_nvidia.sh << EOF
cp -f /etc/X11/xorg.conf.nvidia /etc/X11/xorg.conf
startx
EOF
sudo chmod +x ./startx_nvidia.sh
sudo mv ./startx_nvidia.sh /media/lfs/root
sudo cat > ./startx_intel.sh << EOF
cp -f /etc/X11/xorg.conf.intel /etc/X11/xorg.conf
startx
EOF
sudo chmod +x ./startx_intel.sh
sudo mv ./startx_intel.sh /media/lfs/root

Predictably this did not properly work. The nvidia driver installation changes around some important files. You still get the correct screen resolution but you do not get hardware acceleration. May not strictly be necessary for an Amiga emulator, but I like to be thorough. After much testing (including attempting to archive and restore the [/usr/lib/X11] folder, I have come to the conclusion that there is no easy way to switch between the nvidia and intel driver without uninstalling and rebuilding the nvidia driver completely each time. This is a pain in the arse, because it is slow, very slow if you compress the kernel source folder. I am putting the commands to handle a compressed kernel source folder in the scripts, but I am going to comment them out. If you are swapping the Amiga Key between intel and nvidia machines, you will want to just leave the sources folder uncompressed for the duration. Remember the compress command can take up to an hour to run.

sudo cat > ./startx_nvidia.sh << EOF
#cd /sources
#cat linux.tar.lzma | lzma -d | tar x
#rm -rf linux.tar.lzma
/sources/xorg/driver/NVIDIA-Linux-x86-256.35.run --x-prefix=/usr --kernel-source-path=/sources/linux-2.6.32.8 --no-precompiled-interface -a --silent
#cd /sources
#tar -c linux-2.6.32.8 | lzma --best > linux.tar.lzma
#rm -rf linux-2.6.32.8
cp -f /etc/X11/xorg.conf.nvidia /etc/X11/xorg.conf
startx
EOF
sudo chmod +x ./startx_nvidia.sh
sudo mv ./startx_nvidia.sh /media/lfs/root
sudo cat > ./startx_intel.sh << EOF
/sources/xorg/driver/NVIDIA-Linux-x86-256.35.run --uninstall --silent
cp -f /etc/X11/xorg.conf.intel /etc/X11/xorg.conf
startx
EOF
sudo chmod +x ./startx_intel.sh
sudo mv ./startx_intel.sh /media/lfs/root

Whatever xorg.conf I use, I need to make sure it realises I am using a UK Keyboard. I need to change this section of the file:

Section "InputDevice" 
Identifier     "Keyboard0" 
Driver         "kbd" 
EndSection

To make it look like this:

Section "InputDevice"
Identifier "Keyboard0"
Driver "kbd"
Option "CoreKeyboard"
Option "XkbRules" "xorg"
Option "XkbModel" "pc105"
Option "XkbLayout" "gb"
EndSection

The X display looks pretty bleak when we run it now, just a grey background and a cross for the mouse pointer. We can sort that out by telling X to auto-start software when it runs. To do so we make a file in the ~ directory called [.xinitrc]:
cat > ~/.xinitrc << "EOF"
# Begin .xinitrc file
xterm  -g 80x20+0+0   &
xclock -g 100x100-0+0 &
twm
EOF

This runs the [xterm] program that we installed earlier, and also the [xclock] program that we installed with the applications theme'd package. I am not entirely sure what the numbering means. The [80x20] I am sure is the number of columns and rows that the [xterm] window has when it runs. Finally it runs [t]oms [w]indow [m]anager - a very basic program for drawing windows on the screen.

We want the xterm, graphical BASH, to use the same prompt as the text mode. I think the best way to do that is to create the following file, which just re-runs the normal profile when logging in.

cat > ~/.bashrc << "EOF"
source /etc/profile
EOF

We will also take this opportunity to add a small performance boost by telling the system to create a temporary file for X each time the machine starts. This stops X having to do this itself, and saves some time. The [createfiles] is picked up by one of the LFS boot scripts that we have already installed. It's name is self explanatory, even if the permissions based binary bullshit in the command is not.
cat >> /etc/sysconfig/createfiles << "EOF"
/tmp/.ICE-unix dir 1777 root root
EOF

Because these commands are a bit tricky, lets script them:

sudo cat > conf_xorg_files.sh << "ARSE"
cat > ~/.xinitrc << "EOF"
# Begin .xinitrc file
xterm  -g 80x20+0+0   &
xclock -g 100x100-0+0 &
twm
EOF
cat > ~/.bashrc << "EOF"
source /etc/profile
EOF
cat >> /etc/sysconfig/createfiles << "EOF"
/tmp/.ICE-unix dir 1777 root root
EOF
ARSE
chmod +x ./conf_xorg_files.sh
sudo mv ./conf_xorg_files.sh /media/lfs/root

You should now be able to run

startx

and you will see a terminal window and a clock - OOOOOh, exciting!

Don't forget to recompress the Kernel Source:

cd /sources
tar -c linux-2.6.32.8 | lzma --best > linux.tar.lzma
rm -rf linux-2.6.32.8

Tuesday 17 August 2010

LAP - X - Part 7, Xserver

OK, we are now heading to install the actual Xserver. There are a number of dependencies that we want to install first. The first one here is a Perl Module. We installed Perl way back when in the main build, and this is an add on that handles XML files. Yes, we did just install expat which was also supposed to do this. No I do not know why we now have two programs doing the same thing. I am going to script this because the perl module has its own way of building.

sudo cat > inst_xml.sh << "ARSE"
cd /sources/xorg 
tar -xzvf XML-Parser-2.36.tar.gz
cd XML-Parser-2.36
perl Makefile.PL
make $CORES_TO_USE
make install
cd ..
rm -rvf XML-Parser-2.36
echo "Next: ~/conf_intl.sh"
ARSE
chmod +x ./inst_xml.sh
sudo mv ./inst_xml.sh /media/lfs/root

Now we can install Intltool, which is another one of these universal translator gizmos – I think it speaks to gettext. We are going to do two scripts here, because we need to pause to confirm the output of the check half way through.

sudo cat > conf_intl.sh << "ARSE"
cd /sources/xorg
tar -xjvf intltool-0.40.6.tar.bz2
cd intltool-0.40.6
./configure --prefix=/usr
make $CORES_TO_USE
make check
echo Look for:
echo ================== 
echo All 1 tests passed 
echo ==================
echo "Now run ~/inst_intl.sh"
ARSE
chmod +x ./conf_intl.sh
sudo mv ./conf_intl.sh /media/lfs/root

The make check output for me was:

================== 
All 1 tests passed 
==================

Which is very promising. And now the second part of the installation of the package. I am putting this in a script because of the documentation install again.

sudo cat > inst_intl.sh << "ARSE"
cd /sources/xorg/intltool-0.40.6
make install
install -v -m644 -D doc/I18N-HOWTO /usr/share/doc/intltool-0.40.6/I18N-HOWTO
cd ..
rm -rvf intltool-0.40.6
echo "Next: ~/inst_xkb.sh"
ARSE
chmod +x ./inst_intl.sh
sudo mv ./inst_intl.sh /media/lfs/root

Now we have installed that tool, we can install the xkeyboard-config package. Go on, guess what this does – just have a guess... We have been building up to this – the last two packages were just to allow this one to be installed. This one is the actual dependency of Xserver. I actually screwed this up when I first ran the script because I have put in the uncompress commands as [xzvf] instead of [xjvf]. It couldn't uncompress the package and then moaned as it tried to execute the other commands. Not harm was done. I realised the mistake, and just used 'nano' to edit the script.

sudo cat > inst_xkb.sh << "ARSE" 
cd /sources/xorg
tar -xjvf xkeyboard-config-1.7.tar.bz2
cd xkeyboard-config-1.7
./configure $XORG_CONFIG --with-xkb-rules-symlink=xorg
#
#[with-xkb-rules-symlink] makes a link between the name of the rules the package installs (base) and the name that Xorg expects it to install [xorg].  Just a small compatibility issue.  I have no fucking clue why this package WHICH IS A LIBRARY FOR XORG is not automatically configured for Xorg in the first place.
#
make $CORES_TO_USE
make install
install -dv -m755 $XORG_PREFIX/share/doc/xkeyboard-config-1.7
install -v -m644 docs/{README,HOWTO}* $XORG_PREFIX/share/doc/xkeyboard-config-1.7
cd ..
rm -rvf xkeyboard-config-1.7
echo "Next: luit with XORG_CONFIG, pixman with --prefix=/usr, and ~/inst_server.sh"
ARSE
chmod +x ./inst_xkb.sh
sudo mv ./inst_xkb.sh /media/lfs/root

Now for another Xserver dependency. This is Luit, which allows us to display UTF-8 characters in text windows. Now sure what that means. I suspect is has something to so with fully supporting normal console outputs when the console is running in a window. So, basically, anything should look the same at the console whether in a text only mode, or running in a window under X. No need to script this, it is straightforwards.

tar -xjvf luit-1.0.4.tar.bz2
cd luit-1.0.4
./configure $XORG_CONFIG
make $CORES_TO_USE
make install
cd ..
rm -rvf luit-1.0.4

The next package is the final dependency we need for the Xserver. It handles real low level [pix]el [man]ipulation matters. The installation is also straighforwards.

tar -xzvf pixman-0.15.20.tar.gz
cd pixman-0.15.20
./configure --prefix=/usr
make $CORES_TO_USE
make install
cd ..
rm -rvf pixman-0.15.20

Finally we come to the Xserver itself. If you are reading along in the BLFS book you will see that I appear to have missed a dependency – Openssl. Well, that was installed to support the Lynx browser we installed to view the documentation, so we do not have to worry about it now. The configure command is complex here, so best to wrap all this up in a script.

sudo cat > inst_server.sh << "ARSE"
cd /sources/xorg
tar -xjvf xorg-server-1.7.1.tar.bz2
cd xorg-server-1.7.1
./configure $XORG_CONFIG --with-module-dir=$XORG_PREFIX/lib/X11/modules --with-xkb-output=/var/lib/xkb --enable-install-setuid --disable-config-hal --disable-config-dbus
#
#OK, lets try to work through this.  [with-module-dir] sets a path for installation of X modules.  I think the [with-xkb-output] just tells it where it will find stuff the [xkeyboard-config] package spits out, but I am not entirely clear and BLFS is silent on the issue.  [enable-install-setuid] makes sure that the program files end up as executable by root only.  Shouldn't be an issue because I am still running as root just now.  I am also disabling [hal] and [dbus] which are hardware management tools that are using by desktop environments like Gnome and KDE.  However, all X is going to do for us is display the Amiga Emulator, so I should not need them.  I may live to regret this.
#
make $CORES_TO_USE
make install
cd ..
rm -rvf xorg-server-1.7.1
echo "Next ~/inst_xterm.sh"
ARSE
chmod +x ./inst_server.sh
sudo mv ./inst_server.sh /media/lfs/root

I am also going to install one last application at this stage. This is xterm, which on completely simplistic level is BASH for X.

sudo cat > inst_xterm.sh << "ARSE"
cd /sources/xorg
tar -xzvf xterm-253.tgz
cd xterm-253
sed -i '/v0/,+1s/new:/new:kb=^?:/' termcap
echo -e '\tkbs=\\177,' >>terminfo
#
#Oh bloody hell would you look at that.  Those both make the backspace key actually work in xterm. Why it wouldn't in the first place is another delightful little mystery.
#
TERMINFO=/usr/lib/terminfo ./configure $XORG_CONFIG --enable-luit --enable-wide-chars --with-app-defaults=$XORG_PREFIX/share/X11/app-defaults
#
#We have to define TERMINFO just incase we din't install to /usr, which we did.  The enables tell it  we have luit, and fat letters.  The [app-defaults] is fairly self explanatory - we just tell it where to find default settings - which we will create in a minute.
#
make $CORES_TO_USE
make install
make install-ti
cat >> $XORG_PREFIX/share/X11/app-defaults/XTerm << "EOF"
*VT100*locale: true
*VT100*faceName: Monospace
*VT100*faceSize: 10
*backarrowKeyIsErase: true
*ptyInitialErase: true
EOF
cd ..
rm -rvf xterm-253
echo "Next: ~/inst_6_driver.sh"
ARSE
chmod +x ./inst_xterm.sh
sudo mv ./inst_xterm.sh /media/lfs/root

As before, once I have made all my scripts, I booted from the Amiga Key and ran the install commands in order, using the scripts where necessary.

Monday 16 August 2010

LAP - X - Part 6, Cursors and Fonts

The next group is Fonts, which requires a theme for the cursor to be installed first.   I am not entirely sure whether or not this is the Mouse cursor or the text entry cursor.  I think mouse, because the file is quite large

tar -xjvf xcursor-themes-1.0.2.tar.bz2
cd xcursor-themes-1.0.2
./configure $XORG_CONFIG
make $CORES_TO_USE
make install
cd ..
rm -rvf xcursor-themes-1.0.2

Not worth bothering with a script for that one. I will, again, has to script the fonts install. The same approach is taken.

sudo cat > inst_5_font.sh << "ARSE" 
cd /sources/xorg/font
for package in $(grep -v '^#' ../font-7.5-2.wget)
do
packagedir=${package%.tar.bz2}
tar -xvf $package
cd $packagedir
./configure $XORG_CONFIG
make $CORES_TO_USE
make install
cd ..
rm -rvf $packagedir
done 2>&1 | tee -a ../font-7.5-2-compile.log
echo "Next: ~/inst_xml.sh"
ARSE
chmod +x ./inst_5_font.sh
sudo mv ./inst_5_font.sh /media/lfs/root

For some bizarre reason the book suggests the command [rm -f $package] after removing the $packagedir. This is stupid. In effect this deletes the font files that have downloaded meaning that you would have to download them all again if you are reinstalling the whole of Xorg. Why would you want to reinstall the whole of Xorg? Well, if for instance you went to bed half way through the installation, and forgot that you had compiled a package but not actually installed it, you would have to go back to that step to start again. It would then be pretty fucking frustrating to discover that the god damned stupid script for Fonts had deleted all of the god damned downloaded fonts.

So I have deleted that line.

Friday 13 August 2010

LAP - X - Part 5, Applications

The next job is to install the Applications files. This contains a number of very useful programs that are actually used quite a lot – for instance 'startx' to actually begin Xorg. We may want OpenGL support, so we have to install MesaLib which brings several dependencies. We also need some graphical packages.

So lets get going with the dependencies, starting with xbitmaps. I think this is just some graphics files which X is going to use.
tar -xjvf xbitmaps-1.1.0.tar.bz2
cd xbitmaps-1.1.0
./configure $XORG_CONFIG
make install
cd ..
rm -rvf xbitmaps-1.1.0

Not scripting that easy install. Next is libpng, which adds support for image files in the PNG format.

sudo cat > conf_libpng.sh << "ARSE" 
cd /sources/xorg
tar -xjvf libpng-1.2.42.tar.bz2
cd libpng-1.2.42
patch -Np1 -i ../libpng-1.2.42-apng-1.patch
./configure --prefix=/usr
make $CORES_TO_USE
make check
echo check for
echo ============= 
echo 1 test passed 
echo ============= 
echo "Now run ~/inst_libpng.sh"
ARSE
chmod +x ./conf_libpng.sh
sudo mv ./conf_libpng.sh /media/lfs/root

I am also going to script the installation phase because the documentation commands are detailed.

sudo cat > inst_libpng.sh << "ARSE" 
cd /sources/xorg/libpng-1.2.42
make install
install -v -m755 -d /usr/share/doc/libpng-1.2.42
install -v -m644    README libpng-1.2.42.txt /usr/share/doc/libpng-1.2.42
cd ..
rm -rvf libpng-1.2.42
echo "Now install libpthread-stubs with --prefix=/usr and then libdrm with  --prefix=XORG_PREFIX, before running  ~/inst_mesa.sh"
ARSE
chmod +x ./inst_libpng.sh
sudo mv ./inst_libpng.sh /media/lfs/root

Next up we have one of those chains, libpthread-stubs supports libdrm which supports MesaLib. What this actually does is a fucking mystery. There is something called pthread, apparently, and this is a stub of it. I think this is connected with some possible functions that libc does not provide. Too simple to script.

tar -jxvf libpthread-stubs-0.1.tar.bz2
cd libpthread-stubs-0.1
./configure --prefix=/usr
make $CORES_TO_USE
make install
cd ..
rm -rvf libpthread-stubs-0.1

Then we have libdrm, which happily is nothing to do with digital restrictions management bollocks. This is actually to allow Xorg to use the Direct Rendering Modules compiled into the Kernel. This, I think, means that we get faster hardware supported video. Again, too simple to script.

tar -jxvf libdrm-2.4.14.tar.bz2
cd libdrm-2.4.14
./configure --prefix=$XORG_PREFIX
make $CORES_TO_USE
make install
cd ..
rm -rvf libdrm-2.4.14

Now we have done the 2D acceleration we also may need 3D acceleration. This is provided by MesaLib. This involves [sed] so scripts-ahoy.

sudo cat > inst_mesa.sh << "ARSE" 
cd /sources/xorg
tar -xjvf MesaLib-7.6.tar.bz2
tar -xjvf MesaDemos-7.6.tar.bz2
#We are installing the Demos which are useful to check everything is working.
cd Mesa-7.6
sed 's@FLAGS=\"-g@FLAGS=\"@' -i configure
#This stops it building the debugging symbols.
./configure $XORG_CONFIG
make $CORES_TO_USE
make -C progs/xdemos glxinfo glxgears
make install
install -v -m755 progs/xdemos/glx{info,gears} ${XORG_PREFIX}/bin
cd ..
rm -rvf Mesa-7.6
echo "Next: ~/inst_4_apps.sh"
ARSE
chmod +x ./inst_mesa.sh
sudo mv ./inst_mesa.sh /media/lfs/root

And finally, we come to the applications themselves.

sudo cat > inst_4_apps.sh << "ARSE" 
cd /sources/xorg/app
for package in $(grep -v '^#' ../app-7.5-2.wget)
do
packagedir=${package%.tar.bz2}
tar -xvf $package
cd $packagedir
./configure $XORG_CONFIG
make $CORES_TO_USE
make install
cd ..
rm -rvf $packagedir
done 2>&1 | tee -a ../app-7.5-2-compile.log
echo "Next:  xcursor-themes with XORG_CONFIG, and then ~/inst_5_font.sh"
ARSE
chmod +x ./inst_4_apps.sh
sudo mv ./inst_4_apps.sh /media/lfs/root

Thursday 12 August 2010

LAP - X - Part 4, Libraries and Dependencies

LAP - X - Part 4, Libraries and Dependencies
The next themed package is Libraries, which contains, surprisingly, libraries which support functions of the xserver. Part of these handle font displays, and we need to install some font packages first. Bizarrely it also claims to need a separate text editor, for what purpose I know not. It also needs a couple of packages which relate to clients accessing the display. Technically the first of these [libXau] is not a dependency of Libraries, but BLFS recommends installing it at this stage.
cd /sources/xorg

The first package is the last I referred to. It is LibXau, and it contains an authentication protocol. The X system has clients and servers, and the servers need to authenticate the clients. None of this is of any interest if you are using one machine like we will be, but it would be of use in a large networked environment. I think we can risk these commands without a script as they are as basic as it gets:

tar -jxvf libXau-1.0.5.tar.bz2
cd libXau-1.0.5
./configure $XORG_CONFIG
make $CORES_TO_USE
make check
1 test passed.
make install
cd ..
rm -rvf libXau-1.0.5

The next package is libXdmcp. This is a library which implements the [X] [D]isplay [M]anager [C]ontrol [P]rotocol. What the Xdmcp actually is, is less clear. BLFS does say that it is useful in letting clients interact with the Display Manager, and that sounds useful. Again, I think we can manage this one without a script.

tar -jxvf libXdmcp-1.0.3.tar.bz2
cd libXdmcp-1.0.3
./configure $XORG_CONFIG
make $CORES_TO_USE
make install
cd ..
rm -rvf libXdmcp-1.0.3

Next up is a small basic text editor, which for some reason the library package depends upon. Let's just get it installed. This is a tiny bit more complicated, so I am going to put it in a script:

sudo cat > inst_ed.sh << "ARSE" 
cd /sources/xorg
tar -xvzf ed-1.4.tar.gz
cd ed-1.4
./configure --prefix=/usr --bindir=/bin
make $CORES_TO_USE
make check
echo cd /sources/xorg/ed-1.4
echo make install
echo cd ..
echo rm -rvf ed-1.4
echo "Next: ~/inst_freetype.sh"
ARSE
chmod +x ./inst_ed.sh
sudo mv ./inst_ed.sh /media/lfs/root
The test out put should be:
tests completed successfully.
Then you need to run the commands which follow the [echo] command. The point of the [echo] is that the test should run, and then print out the last four, simple, commands for you to just type in. Next is Freetype2, which is for rendering TrueType fonts. This is not strictly a dependency of the Library package, but it is of fontconfig, which IS a dependency of Library. Oh, and this involves the madness that is sed, so of course it is going in a script.
sudo cat > inst_freetype.sh << "ARSE" 
cd /sources/xorg
tar -jxvf freetype-2.3.12.tar.bz2
cd freetype-2.3.12
tar -xvf ../freetype-doc-2.3.12.tar.bz2 --strip-components=2 -C docs
#
#That command unpacks some additional documentation which I downloaded.  The [strip-components] option removes the leading [2] characters of the uncompressed filenames.  The other option [C]hanges to the docs directory before unpacking.
#
sed -i -r -e 's:.*(#.*BYTE.*) .*:\1:' -e 's:.*(#.*SUBPIX.*) .*:\1:' include/freetype/config/ftoption.h
#
#Even for [sed] that's fucking insane.  Apparently this turns on a native TrueType function and subpixel rendering for clearer text on LCD displays.  These have patent issues (I think Microsoft have a patent for their ClearType software, which presumably does the same stuff).
#
./configure --prefix=/usr
make $CORES_TO_USE
make install
install -v -m755 -d /usr/share/doc/freetype-2.3.12
cp -v -R docs/*     /usr/share/doc/freetype-2.3.12
cd ..
rm -rvf freetype-2.3.12
echo "Next: ~/inst_expat.sh"
ARSE
chmod +x ./inst_freetype.sh
sudo mv ./inst_freetype.sh /media/lfs/root
Fontconfig also needs software to handle XML. I am going to use expat. It is fairly straightforwards, but does have tricky to type in documentation install commands, so let's just script it.
sudo cat > inst_expat.sh << "ARSE" 
cd /sources/xorg
tar -xzvf expat-2.0.1.tar.gz
cd expat-2.0.1
./configure --prefix=/usr
make $CORES_TO_USE
make install
install -v -m755 -d /usr/share/doc/expat-2.0.1
install -v -m644 doc/*.{html,png,css} /usr/share/doc/expat-2.0.1
cd ..
rm -rvf expat-2.0.1
echo "Next: ~/inst_fontconfig.sh"
ARSE
chmod +x ./inst_expat.sh
sudo mv ./inst_expat.sh /media/lfs/root
Last before the Library install itself is Fontconfig. Clue is in the name really. The configure options are quite lengthy so we'd best script them up.
sudo cat > inst_fontconfig.sh << "ARSE" 
cd /sources/xorg
tar -xzvf fontconfig-2.8.0.tar.gz
cd fontconfig-2.8.0
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --disable-docs --without-add-fonts --with-docdir=/usr/share/doc/fontconfig-2.8.0
make $CORES_TO_USE
make check
echo I got:
echo ============= 
echo 1 test passed 
echo ============= 
echo cd /sources/xorg/fontconfig-2.8.0
echo make install
echo cd ..
echo rm -rvf fontconfig-2.8.0
echo "Next: ~/inst_3_libraries.sh"
ARSE
chmod +x ./inst_fontconfig.sh
sudo mv ./inst_fontconfig.sh /media/lfs/root
The test output should be:
============= 
1 test passed 
============= 
Then just follow the reminders to finish. Finally we come to the libraries themselves. This is one of the bigger packages that form part of the Xorg installation.
sudo cat > inst_3_libraries.sh << "ARSE" 
cd /sources/xorg/lib
for package in $(grep -v '^#' ../lib-7.5-2.wget)
do
packagedir=${package%.tar.bz2}
tar -xvf $package
cd $packagedir
case "$packagedir" in
libX11-1.3.2 )
CONFIGPARAMS="--without-xcb"
esac
./configure $XORG_CONFIG $CONFIGPARAMS
make $CORES_TO_USE
make install
unset CONFIGPARAMS
ldconfig
cd ..
rm -rvf $packagedir
done 2>&1 | tee -a ../lib-7.5-2-compile.log
echo "Next do xbitmaps manually, with the option XORG_CONFIG, and then run ~/conf_libpng.sh"
ARSE
chmod +x ./inst_3_libraries.sh
sudo mv ./inst_3_libraries.sh /media/lfs/root

OK, that is a little bit more complex than the previous multipackage builds. The difference is that one of the packages needs a specific option set - that's the CONFIGPARAMS variable. It is only set for that one package. It doesn't matter that we use $CONFIGPARAMS for each package, because at all other times it is null. That should be that for Libraries.

Wednesday 11 August 2010

LAP - X - Part 3, Protocol Headers & Utils

We'll now move on to the first part of the actual X build, the Protocol headers. I do not exactly know what these are, but I assume they are the same type of thing as the Linux headers which we required to install from the Kernel sources at the beginning of the toolchain and actual builds.

Once we have our Xorg variables set we need to run the following command in the [/sources/xorg/proto] directory:

for package in $(grep -v '^#' ../proto-7.5-2.wget)
do
packagedir=${package%.tar.bz2}
tar -xvf $package
cd $packagedir
./configure $XORG_CONFIG
make install
cd ..
rm -rvf $packagedir
done 2>&1 | tee -a ../proto-7.5-2-compile.log

That looks complicated, but it really isn't. First of all it uses [grep] to search through the [.wget] file for all the filenames that we are going to use. It then assigns each filename in turn to the variable [package]. I presume that the [packagedir] variable is assigned the name of the file without the [tar.bz2] bit at the end. Thankfully none of these packages are gzipped, or uncompress to a stupid folder name, otherwise this would be much harder. We then uncompress and move into the resulting folder. We then run configure using the variable we set before - so the configure command is really short. Apparently there is no make command, we just [make install]. Then we come out of the folder and remove it. All of the output is logged using [tee] to a log file.

Lets make a script for this. I have added the [1] to the name, to remind myself about the install order once I have rebooted to the Amiga Key and am actually running all these scripts:

sudo cat > inst_1_proto.sh << "ARSE" 
cd /sources/xorg/proto
for package in $(grep -v '^#' ../proto-7.5-2.wget)
do
packagedir=${package%.tar.bz2}
tar -xvf $package
cd $packagedir
./configure $XORG_CONFIG
make install
cd ..
rm -rvf $packagedir
done 2>&1 | tee -a ../proto-7.5-2-compile.log
echo "Next: ~/inst_2_util.sh"
ARSE
chmod +x ./inst_1_proto.sh
sudo mv ./inst_1_proto.sh /media/lfs/root

Note that at the beginning of the script it changes into the correct directory, so it does not actually matter where you execute the script from, it will make its way to the proper place before running all the commands.

Now we are going to do exactly the name thing, but for the Utilities package. Surprisingly enough this package contains utilities. Having a browse through the descriptions in BLFS, it seems that these are mostly geared towards the installation of X rather than running it. The command we are going to run is:

for package in $(grep -v '^#' ../util-7.5-2.wget)
do
packagedir=${package%.tar.bz2}
tar -xvf $package
cd $packagedir
./configure $XORG_CONFIG
make $CORES_TO_USE
make install
cd ..
rm -rvf $packagedir
done 2>&1 | tee -a ../util-7.5-2-compile.log

The difference with this command is the addition of a [make] step - otherwise it is just the same (with the obvious substitution of [util] for [proto] of course. Lets script this bad boy up. I have put in an [echo] command at the end to remind myself what to do next.

sudo cat > inst_2_util.sh << "ARSE" 
cd /sources/xorg/util
for package in $(grep -v '^#' ../util-7.5-2.wget)
do
packagedir=${package%.tar.bz2}
tar -xvf $package
cd $packagedir
./configure $XORG_CONFIG
make $CORES_TO_USE
make install
cd ..
rm -rvf $packagedir
done 2>&1 | tee -a ../util-7.5-2-compile.log
echo "Now do libXau and libXdmcp with the configure option XORG_CONFIG.  You can check libXau.  Then run ~/inst_ed.sh"
ARSE
chmod +x ./inst_2_util.sh
sudo mv ./inst_2_util.sh /media/lfs/root

Tuesday 10 August 2010

LAP - X - Part 2, Variables

OK, we have our files downloaded, now it is time to install them. We are going to have to do this via script, because the commands are so damned complicated it would be asking for trouble to have to type them into the command line by hand.

I will write the blog post from the point of view of having actually booted from the Amiga Key, but remember before you run the commands to create the script you need to boot from the LiveCD and run these commands:

umount -v /media/amiga
sudo mkdir /media/lfs
sudo mount -v -t ext3 /dev/disk/by-label/amiga /media/lfs
cd /media/lfs/sources

So, that reminder over, the first thing that we have to do is to set two environment variables. The first tells the system where X is installed, and the second contains a number of [configure] options and will save us from having to type them in each time we configure a package. What I am going to do is set these variables, BUT ALSO add them to the [/etc/profile] file so that they will remain set even if I reboot.

export XORG_PREFIX="/usr"

I have decided to install into [/usr] as with all the other system software. The book did give me the choice between there or [/opt]. DO NOT RUN this command from the LiveCD, it needs to be run from the Amiga Key.

export XORG_CONFIG="--prefix=$XORG_PREFIX --sysconfdir=/etc --mandir=$XORG_PREFIX/share/man --localstatedir=/var"

The actual options that we are setting here are fairly self explanatory.

Now lets have a script for this:

sudo cat > set_0_xorg_stuff.sh << "ARSE" 
cat >> /etc/profile.d/X.sh << "EOF"
# Begin Xorg Variables
export XORG_PREFIX="/usr"
export XORG_CONFIG="--prefix=$XORG_PREFIX --sysconfdir=/etc --mandir=$XORG_PREFIX/share/man --localstatedir=/var"
# End Xorg variables
EOF
echo "Remember to now exit and log back in to allow these changes to take place.  Then run ~/inst_1_proto.sh"
ARSE
chmod +x ./set_0_xorg_stuff.sh
sudo mv ./set_0_xorg_stuff.sh /media/lfs/root

Note in my script I used [>>] to add those commands to /etc/profile.d/X.sh, rather than over writing it entirely. Once you have run the script, log out and log in again and use [echo] to check the [$]variables. I have put a reminder to myself in the last line of the script. When I run it it will end with that message. The idea is that rebooting all the time to make new scripts is a pain in the arse, and it would be most efficient to make all of the Xorg Scripts in one go, reboot to the key and then run them one at a time. That would be tricky if we didn't keep a track in the scripts themselves of which script comes next.

Monday 9 August 2010

LAP - X - Part 1, Download

We now come to one of the trickiest parts of the installation - building the X server, or in other words, creating our graphical interface. If one had hoped that this would be as simple as downloading the 'x' package and installing it, then one is about to be seriously fucking disappointed.

This post will deal solely with downloading all the install files that we are going to need in due course. The software packages come in two varieties. First stand alone packages which achieve one thing, and second groups of packages which are gathered together by the LFS team in 'themes'.

We have to even run a short script just to download the themed packages otherwise we'd be here all fecking day.

Let's just get the stuff downloaded, and I will try to work it all out afterwards.

umount -v /media/amiga
sudo mkdir /media/lfs
sudo mount -v -t ext3 /dev/disk/by-label/amiga /media/lfs
cd /media/lfs/sources

Lets make a new directory for the xorg sources, as there will be so many of them.

mkdir xorg
chmod -v a+wt xorg
cd xorg
wget http://anduin.linuxfromscratch.org/files/BLFS/svn/xorg/proto-7.5-2.wget
wget http://anduin.linuxfromscratch.org/files/BLFS/svn/xorg/proto-7.5-2.md5

What we have just downloaded is a list of files and their md5sums (a way of checking the file has downloaded properly). We are going to make another subdirectory just to store these files.

mkdir proto
cd proto

What we now do is get the [wget] program to automatically process that list of files, downloading each one.
grep -v '^#' ../proto-7.5-2.wget | wget -i- -c -B http://xorg.freedesktop.org/releases/individual/proto/

That command looks nasty but I think that the [grep] bit spits out the file names from the [.wget] file, and [|] pipes them to [wget]. The [-i-] option tells [wget] to expect a list of file names from the other side of the [|] pipe. It is also told to [c]ontinue any partial downloads, and the [B] option means attach the following URL to the filename to download it. It finished with this message for me:

Downloaded: 24 files, 1.7M in 20s (90.4 KB/s)

Lastly we run md5sum to check the downloaded files have arrived properly.

md5sum -c ../proto-7.5-2.md5

Assuming that has worked (lots of 'OK's), move on to the next list, which we deal with in exactly the same way:

cd ..
wget http://anduin.linuxfromscratch.org/files/BLFS/svn/xorg/util-7.5-2.wget
wget http://anduin.linuxfromscratch.org/files/BLFS/svn/xorg/util-7.5-2.md5
mkdir util
cd util
grep -v '^#' ../util-7.5-2.wget | wget -i- -c -B http://xorg.freedesktop.org/releases/individual/util/
md5sum -c ../util-7.5-2.md5

Wait a minute, all that palaver was for two fucking files? It would literally have been less effort to just wget each of them individually.

cd ..

Taking the order BLFS presents these packages, the next two are stand alone:

wget http://xorg.freedesktop.org/releases/individual/lib/libXau-1.0.5.tar.bz2
wget http://xorg.freedesktop.org/releases/individual/lib/libXdmcp-1.0.3.tar.bz2

The next package we are supposed to download is the X Libraries. However, dependency issues raise their head at this point and we are forced into downloading some extra packages first.

wget http://ftp.gnu.org/pub/gnu/ed/ed-1.4.tar.gz
wget http://downloads.sourceforge.net/freetype/freetype-2.3.12.tar.bz2
wget http://downloads.sourceforge.net/freetype/freetype-doc-2.3.12.tar.bz2
wget http://downloads.sourceforge.net/expat/expat-2.0.1.tar.gz
wget http://fontconfig.org/release/fontconfig-2.8.0.tar.gz

Then back to lists:

wget http://anduin.linuxfromscratch.org/files/BLFS/svn/xorg/lib-7.5-2.wget
wget http://anduin.linuxfromscratch.org/files/BLFS/svn/xorg/lib-7.5-2.md5
mkdir lib
cd lib
grep -v '^#' ../lib-7.5-2.wget | wget -i- -c -B http://xorg.freedesktop.org/releases/individual/lib/

Downloaded: 31 files, 10M in 1m 34s (114 KB/s)

md5sum -c ../lib-7.5-2.md5
cd ..

The next few downloads are all dependencies of the next theme'd package.

wget http://xorg.freedesktop.org/releases/individual/data/xbitmaps-1.1.0.tar.bz2
wget http://downloads.sourceforge.net/libpng/libpng-1.2.42.tar.bz2
wget http://anduin.linuxfromscratch.org/sources/BLFS/conglomeration/libpng/libpng-1.2.42-apng-1.patch
wget http://xcb.freedesktop.org/dist/libpthread-stubs-0.1.tar.bz2
wget http://dri.freedesktop.org/libdrm/libdrm-2.4.14.tar.bz2
wget ftp://ftp.freedesktop.org/pub/mesa/7.6/MesaLib-7.6.tar.bz2
wget ftp://ftp.freedesktop.org/pub/mesa/7.6/MesaDemos-7.6.tar.bz2

And another list:

wget http://anduin.linuxfromscratch.org/files/BLFS/svn/xorg/app-7.5-2.wget
wget http://anduin.linuxfromscratch.org/files/BLFS/svn/xorg/app-7.5-2.md5

mkdir app
cd app
grep -v '^#' ../app-7.5-2.wget | wget -i- -c -B http://xorg.freedesktop.org/releases/individual/app/
md5sum -c ../app-7.5-2.md5

Downloaded: 39 files, 4.3M in 1m 3s (69.7 KB/s)

cd ..

Another one off:

wget http://xorg.freedesktop.org/releases/individual/data/xcursor-themes-1.0.2.tar.bz2

And then another list:

wget http://anduin.linuxfromscratch.org/files/BLFS/svn/xorg/font-7.5-2.wget
wget http://anduin.linuxfromscratch.org/files/BLFS/svn/xorg/font-7.5-2.md5
mkdir font
cd font
grep -v '^#' ../font-7.5-2.wget | wget -i- -c -B http://xorg.freedesktop.org/releases/individual/font/

Downloaded: 37 files, 15M in 2m 8s (117 KB/s)

md5sum -c ../font-7.5-2.md5
cd ..

And some dependency stuff before the next package:

wget http://cpan.org/authors/id/M/MS/MSERGEANT/XML-Parser-2.36.tar.gz
wget http://ftp.gnome.org/pub/gnome/sources/intltool/0.40/intltool-0.40.6.tar.bz2

Then a couple of xorg packages:

wget http://xlibs.freedesktop.org/xkbdesc/xkeyboard-config-1.7.tar.bz2
wget http://xorg.freedesktop.org/releases/individual/app/luit-1.0.4.tar.bz2

Followed by another dependency, and the important sounding xorg-server:

wget http://cairographics.org/releases/pixman-0.15.20.tar.gz
wget http://xorg.freedesktop.org/releases/individual/xserver/xorg-server-1.7.1.tar.bz2

The last themed group is the driver files for the hardware you have. This is a bit tricky, but first download the list files:

wget http://anduin.linuxfromscratch.org/files/BLFS/svn/xorg/driver-7.5-2.wget
wget http://anduin.linuxfromscratch.org/files/BLFS/svn/xorg/driver-7.5-2.md5

Now you do not want to download ALL the driver files – only the ones appropriate to your system. I edited the wget file as follows:

nano driver-7.5-2.wget

And I put a '#' to comment out each line apart from
xf86-input-evdev-2.3.0.tar.bz2
xf86-input-joystick-1.4.99.2.tar.bz2 
xf86-input-keyboard-1.4.0.tar.bz2 
xf86-input-mouse-1.5.0.tar.bz2 
xf86-input-synaptics-1.2.0.tar.bz2 
xf86-video-dummy-0.3.2.tar.bz2
xf86-video-fbdev-0.4.1.tar.bz2
xf86-video-intel-2.9.1.tar.bz2
xf86-video-vesa-2.2.1.tar.bz2

And I put the same '#' in the md5sum file by running:

nano driver-7.5-2.md5

I then downloaded and checked the files I have selected:
mkdir driver
cd driver
grep -v '^#' ../driver-7.5-2.wget | wget -i- -c -B http://xorg.freedesktop.org/releases/individual/driver/

Downloaded: 9 files, 2.9M in 16s (181 KB/s)
Downloaded: 7 files, 2.3M in 12s (207 KB/s)

md5sum -c ../driver-7.5-2.md5
cd ..

Finally, download this stand alone program:

wget ftp://invisible-island.net/xterm/xterm-253.tgz

Next time we find out what exactly the fuck all this is for, and what we do with it.