2004-11-16 04:45:22 +03:00
#!/bin/sh
2004-11-25 21:38:24 +03:00
# Usage: makehdimage [image path/target dir]
#
2004-11-16 05:25:16 +03:00
# This script will compile all files needed to create a bootable Haiku image,
# create such an image, and copy the files to the correct location.
#
# If you don't specify the image, $sourceDir/haiku.image will be used. In
# the current default configuration, you have to start this script in the
2005-03-06 03:15:26 +03:00
# "current" directory of the Haiku tree. A 60 MB image will be created there.
2004-11-16 05:25:16 +03:00
#
2004-11-25 21:38:24 +03:00
# If you specify a target directory, no image is going to be created at
2005-03-06 03:15:26 +03:00
# all.
#
# The image is populated using the bfs_shell which is created from the sources.
# The bfs_shell emulates a mini-kernel evironment with a mounted BFS. The
# program fs_shell_command is used to deliver commands to it. Due to this
# setup a few things need to be kept in mind, if you intend to modify the
# script and want it to still work.
#
# All commands that modify the target (directory or image) are to be called
# through variables (defined after the jam invocation block). This ensures
# that both applications (creating and image and just installing the stuff in
# a target directory) do still work. Additionally there's a variable `sPrefix'
# defined, which has to be prepended to every source path, when passing the
# path to such a command.
2004-11-25 21:38:24 +03:00
#
2005-03-06 03:15:26 +03:00
# A further particularity to consider is changing the current working
# directory. When the shell command `cd' is invoked here, it affects only
# the shell which executes this script; the bfs_shell will know nothing of
# it. Hence, if you want the bfs_shell to know of a changed directory, you
# must tell it. There are two commands bound to variables: `$cd' should be
# used, when you want to change into a target directory, `$scd' when the
# source directory shall be changed. In the latter case you usually invoke
# first a normal shell `cd' and then the `$scd', so that both, the shell and
# the bfs_shell know about the new dir (depending on what you intend to do
# one may be enough, though).
2004-11-16 05:25:16 +03:00
2004-11-16 04:45:22 +03:00
# path of the checked out Haiku sources
2004-11-16 05:25:16 +03:00
sourceDir=.
2004-11-25 06:15:18 +03:00
alreadyMounted=
targetDir=/haiku
2004-11-16 04:45:22 +03:00
# disk image path, size in MB
2004-11-25 06:15:18 +03:00
if [ -d "$1" ]; then
alreadyMounted=true
targetDir=$1
elif [ "$1" == "" ]; then
2004-11-16 05:25:16 +03:00
imagePath=$sourceDir/haiku.image
else
imagePath=$1
fi
2005-03-01 02:42:11 +03:00
imageSize=60
# Bochs parameters:
# 40 MB: cylinders=82, heads=16, spt=63
# 60 MB: cylinders=122, heads=16, spt=63
# 100 MB: cylinders=204, heads=16, spt=63
2005-02-16 07:19:57 +03:00
2005-03-06 03:15:26 +03:00
# the architecture; ToDo: set correctly (using uname?)
arch=x86
2004-11-16 04:45:22 +03:00
# build everything needed
2004-11-16 05:25:16 +03:00
previousDir=`pwd`
2004-11-16 04:45:22 +03:00
cd $sourceDir
2004-11-16 05:25:16 +03:00
sourceDir=`pwd`
# we accept relative source directories as well
2004-11-25 06:15:18 +03:00
if [ $alreadyMounted ]; then
echo "Building binaries and copy them to $targetDir"
else
echo "Building $imageSize MB image at $imagePath..."
fi
2004-11-16 05:25:16 +03:00
2005-01-17 04:33:24 +03:00
# paths of helper commands
2005-03-06 03:15:26 +03:00
rc=$sourceDir/distro/${arch}.R1/beos/bin/rc
resattr=$sourceDir/objects/${arch}.R1/tools/resattr/resattr
fsShellCommand=$sourceDir/objects/${arch}.R1/tests/add-ons/kernel/file_systems/fs_shell/fs_shell_command
bfsShell=$sourceDir/objects/${arch}.R1/tests/add-ons/kernel/file_systems/bfs/bfs_shell/bfs_shell
2005-01-17 04:33:24 +03:00
2005-01-14 18:31:02 +03:00
export RUN_WITHOUT_APP_SERVER=1
2005-01-26 02:29:06 +03:00
export TARGET_PLATFORM=haiku
2004-11-16 05:25:16 +03:00
2004-11-25 06:15:18 +03:00
BEOS_BIN="touch sync ln listarea listattr listsem listport \
2004-11-23 07:47:19 +03:00
true false ls df mount unmount cp mv ps sh mkdir sleep \
2004-11-30 18:11:07 +03:00
grep cat less clockconfig du rm date find locate xargs \
2004-12-02 13:50:26 +03:00
isvolume shutdown safemode sysinfo kill diff cmp more \
2005-01-14 22:44:21 +03:00
renice rmattr addattr listdev pwd chmod chown chgrp dd \
2005-01-15 07:42:22 +03:00
tee md5sum catattr query lsindex mkindex roster listimage \
2005-02-10 06:08:46 +03:00
quit open translate setvolume waitfor uname iroster keymap \
2005-02-16 07:19:57 +03:00
strace rmdir error"
2004-11-16 05:25:16 +03:00
2005-01-15 07:42:22 +03:00
BEOS_SYSTEM_LIB="libbe.so libstdc++.r4.so libnet.so libmedia.so \
libtranslation.so libbind.so libnetapi.so libsocket.so"
2004-11-16 05:25:16 +03:00
2005-02-25 17:38:13 +03:00
BEOS_SYSTEM_SERVERS="registrar debug_server syslog_daemon media_server \
media_addon_server input_server"
2005-01-25 00:27:38 +03:00
BEOS_ADD_ONS_TRANSLATORS="STXTTranslator RTF-Translator"
2005-01-26 02:29:06 +03:00
BEOS_ADD_ONS_MEDIA="mixer.media_addon legacy.media_addon multi_audio.media_addon"
2005-02-08 03:25:38 +03:00
BEOS_ADD_ONS_INPUT_DEVICES="<input>keyboard"
2005-01-14 02:52:59 +03:00
2005-01-19 05:09:20 +03:00
echo "Building executables and libraries..."
2005-02-18 04:17:45 +03:00
jam -j$(sysinfo -cpu | head -c 2) -q rc resattr kernel boot_loader config_manager \
pci isa ide scsi ide_isa bfs blkman fast_log ide_adapter locked_pool \
2004-11-16 05:25:16 +03:00
scsi_periph intel keyboard scsi_dsk scsi_cd \
rld.so kernel_fortune consoled \
2005-01-14 02:52:59 +03:00
$BEOS_BIN $BEOS_SYSTEM_LIB $BEOS_SYSTEM_SERVERS \
2005-02-08 03:25:38 +03:00
$BEOS_ADD_ONS_TRANSLATORS $BEOS_ADD_ONS_MEDIA $BEOS_ADD_ONS_INPUT_DEVICES\
2005-02-15 04:15:08 +03:00
libnet.so dprintf null zero random ps2_hid \<driver\>tty console \
\<driver\>config vga_text timezone_files keymap_files \
2005-03-06 03:15:26 +03:00
bfs_shell fs_shell_command \
2005-01-25 00:27:38 +03:00
|| { echo "*** Build failed!" 1>&2 ; exit 1; }
2004-11-16 04:45:22 +03:00
2005-03-06 03:15:26 +03:00
# map the shell commands
if [ $alreadyMounted ]; then
sPrefix=
cd=cd
scd=:
cp="copyattr -d"
ln=ln
mkdir=mkdir
rm=rm
else
sPrefix=:
cd="$fsShellCommand cd"
scd="$fsShellCommand cd"
cp="$fsShellCommand xcp"
ln="$fsShellCommand ln"
mkdir="$fsShellCommand mkdir"
rm="$fsShellCommand rm"
fi
2004-11-16 04:45:22 +03:00
# create the image and the directory structure
2004-11-25 06:15:18 +03:00
if [ ! $alreadyMounted ]; then
2005-01-19 05:09:20 +03:00
echo
echo "Creating image..."
2004-11-25 06:15:18 +03:00
dd if=/dev/zero of=$imagePath bs=1M count=$imageSize
2005-01-25 00:27:38 +03:00
mkbfs $imagePath Haiku >/dev/null
2005-03-06 03:15:26 +03:00
targetDir=/myfs
$bfsShell -n $imagePath > /dev/null &
sleep 1
2004-11-25 06:15:18 +03:00
fi
2004-11-16 04:45:22 +03:00
2005-03-06 03:15:26 +03:00
$cd $targetDir
2004-12-04 01:32:58 +03:00
2005-01-19 05:09:20 +03:00
echo
echo "Creating directory structure..."
2005-03-06 03:15:26 +03:00
$mkdir -p beos/bin
$mkdir -p beos/etc
$mkdir -p beos/system/add-ons/kernel/boot
$mkdir -p beos/system/add-ons/kernel/bus_managers
$mkdir -p beos/system/add-ons/kernel/busses/ide
$mkdir -p beos/system/add-ons/kernel/drivers/bin
$mkdir -p beos/system/add-ons/kernel/drivers/dev/disk/scsi
$mkdir -p beos/system/add-ons/kernel/drivers/dev/input
$mkdir -p beos/system/add-ons/kernel/drivers/dev/misc
$mkdir -p beos/system/add-ons/kernel/file_systems
$mkdir -p beos/system/add-ons/kernel/console
$mkdir -p beos/system/add-ons/kernel/generic
$mkdir -p beos/system/add-ons/kernel/partitioning_systems
$mkdir -p beos/system/add-ons/Translators
$mkdir -p beos/system/add-ons/media
$mkdir -p beos/system/add-ons/input_server/devices
$mkdir -p beos/system/boot
$mkdir -p beos/system/lib
$mkdir -p beos/system/servers
$mkdir -p home/config
$mkdir -p home/config/settings/kernel/drivers
$mkdir -p var/tmp
2004-11-16 04:45:22 +03:00
# modules
2005-01-19 05:09:20 +03:00
echo "Installing kernel modules..."
2005-03-06 03:15:26 +03:00
cd $sourceDir/distro/${arch}.R1/beos/system/add-ons/kernel
$scd ${sPrefix}$sourceDir/distro/${arch}.R1/beos/system/add-ons/kernel
2004-11-16 04:45:22 +03:00
for f in bus_managers/isa bus_managers/ide bus_managers/scsi busses/ide/ide_isa \
file_systems/bfs generic/blkman generic/fast_log generic/ide_adapter \
2005-02-15 04:15:08 +03:00
generic/locked_pool generic/scsi_periph partitioning_systems/intel \
2005-03-01 02:42:11 +03:00
console/vga_text bus_managers/pci; do
2005-03-06 03:15:26 +03:00
$cp ${sPrefix}$f $targetDir/beos/system/add-ons/kernel/$f
2004-11-16 04:45:22 +03:00
done
for f in drivers/dev/disk/scsi/scsi_dsk drivers/dev/disk/scsi/scsi_cd; do
name=drivers/bin/$(basename $f)
2005-03-06 03:15:26 +03:00
$cp ${sPrefix}$name $targetDir/beos/system/add-ons/kernel/$name
2004-11-16 04:45:22 +03:00
done
2005-03-06 03:15:26 +03:00
cd $sourceDir/objects/${arch}.R1/add-ons/kernel
$scd ${sPrefix}$sourceDir/objects/${arch}.R1/add-ons/kernel
2004-11-16 04:45:22 +03:00
2005-03-01 02:42:11 +03:00
for f in bus_managers/config_manager; do
2004-11-16 04:45:22 +03:00
name=$(basename $f)
2005-03-06 03:15:26 +03:00
$cp ${sPrefix}$f/$name $targetDir/beos/system/add-ons/kernel/$f
2004-11-16 04:45:22 +03:00
done
2005-01-25 00:27:38 +03:00
2004-11-16 04:45:22 +03:00
# drivers
2005-03-06 03:15:26 +03:00
for f in drivers/arch/${arch}/keyboard/keyboard; do
$cp ${sPrefix}$f $targetDir/beos/system/add-ons/kernel/drivers/bin
2004-11-16 04:45:22 +03:00
done
2005-03-06 03:15:26 +03:00
cd $sourceDir/distro/${arch}.R1/beos/system/add-ons/kernel/drivers/bin
$scd ${sPrefix}$sourceDir/distro/${arch}.R1/beos/system/add-ons/kernel/drivers/bin
2005-02-08 03:25:38 +03:00
for f in ps2_hid; do
2005-03-06 03:15:26 +03:00
$cp ${sPrefix}$f $targetDir/beos/system/add-ons/kernel/drivers/bin
2005-02-08 03:25:38 +03:00
done
2005-03-06 03:15:26 +03:00
cd $sourceDir/distro/${arch}.R1/beos/system/add-ons/kernel/drivers/dev
$scd ${sPrefix}$sourceDir/distro/${arch}.R1/beos/system/add-ons/kernel/drivers/dev
2005-02-15 04:15:08 +03:00
for f in misc/config console tty random dprintf null zero; do
2005-03-06 03:15:26 +03:00
$cp ${sPrefix}$f $targetDir/beos/system/add-ons/kernel/drivers/bin
2004-11-16 04:45:22 +03:00
done
# kernel
2005-01-19 05:09:20 +03:00
echo "Installing kernel..."
2005-03-06 03:15:26 +03:00
$cp ${sPrefix}$sourceDir/objects/${arch}.R1/kernel/kernel $targetDir/beos/system/kernel_${arch}
2004-11-16 04:45:22 +03:00
# libs
2005-01-19 05:09:20 +03:00
echo "Installing libraries..."
2005-03-06 03:15:26 +03:00
cd $sourceDir/distro/${arch}.R1/beos/system/lib
$scd ${sPrefix}$sourceDir/distro/${arch}.R1/beos/system/lib
for f in $BEOS_SYSTEM_LIB; do
$cp ${sPrefix}$f $targetDir/beos/system/lib/
done
cd $sourceDir/objects/${arch}.R1/kernel/
$scd ${sPrefix}$sourceDir/objects/${arch}.R1/kernel/
$cp ${sPrefix}rld.so ${sPrefix}libroot.so $targetDir/beos/system/lib/
2004-11-16 04:45:22 +03:00
2005-01-14 02:52:59 +03:00
# servers
2005-01-19 05:09:20 +03:00
echo "Installing servers..."
2005-03-06 03:15:26 +03:00
cd $sourceDir/distro/${arch}.R1/beos/system/servers
$scd ${sPrefix}$sourceDir/distro/${arch}.R1/beos/system/servers
for f in $BEOS_SYSTEM_SERVERS; do
$cp ${sPrefix}$f $targetDir/beos/system/servers/
done
2005-01-14 02:52:59 +03:00
2004-11-16 04:45:22 +03:00
# apps
2005-01-19 05:09:20 +03:00
echo "Installing apps..."
2005-03-06 03:15:26 +03:00
cd $sourceDir/objects/${arch}.R1/kernel
$scd ${sPrefix}$sourceDir/objects/${arch}.R1/kernel
2005-02-08 03:25:38 +03:00
for f in fortune; do
2005-03-06 03:15:26 +03:00
$cp ${sPrefix}kernel_$f $targetDir/beos/bin/$f
2004-11-16 04:45:22 +03:00
done
2005-03-06 03:15:26 +03:00
cd $sourceDir/distro/${arch}.R1/beos/bin
$scd ${sPrefix}$sourceDir/distro/${arch}.R1/beos/bin
for f in ../apps/consoled $BEOS_BIN; do
$cp ${sPrefix}$f $targetDir/beos/bin/
done
$cd $targetDir/beos/bin
2004-11-16 05:25:16 +03:00
2005-01-25 00:27:38 +03:00
2004-11-16 05:25:16 +03:00
# scripts and data files
2005-01-19 05:09:20 +03:00
echo "Installing scripts and data files..."
2004-11-16 05:25:16 +03:00
cd $sourceDir
2005-03-06 03:15:26 +03:00
$scd ${sPrefix}$sourceDir
$cp ${sPrefix}data/system/boot/Bootscript \
${sPrefix}data/system/boot/SetupEnvironment $targetDir/beos/system/boot/
$cp ${sPrefix}data/etc/profile ${sPrefix}data/etc/termcap $targetDir/beos/etc/
$cp ${sPrefix}src/kernel/apps/fortune/fortunes $targetDir/beos/etc/
$cp -r ${sPrefix}distro/${arch}.R1/beos/etc $targetDir/beos/
$cp ${sPrefix}data/settings/kernel/drivers/kernel \
$targetDir/home/config/settings/kernel/drivers/
$ln -sf /boot/beos/etc/timezones/Europe/Paris \
$targetDir/home/config/settings/timezone
$cp ${sPrefix}distro/${arch}.R1/beos/etc/Keymap/US-International \
$targetDir/home/config/settings/Key_map
2004-11-16 04:45:22 +03:00
2005-01-25 00:27:38 +03:00
2004-11-16 04:45:22 +03:00
# boot loader
2005-01-19 05:09:20 +03:00
echo "Installing boot loader..."
2005-03-06 03:15:26 +03:00
cd $sourceDir/objects/${arch}.R1/kernel/
rm -f zbeos
objcopy -O binary boot_loader zbeos
$cd $targetDir/beos/system
$cp ${sPrefix}$sourceDir/objects/${arch}.R1/kernel/zbeos .
2004-11-16 04:45:22 +03:00
# boot module links
2005-01-19 05:09:20 +03:00
echo "Creating boot module links..."
2005-03-06 03:15:26 +03:00
$cd $targetDir/beos/system/add-ons/kernel/boot
2004-11-16 04:45:22 +03:00
for f in bus_managers/config_manager bus_managers/pci bus_managers/isa bus_managers/ide bus_managers/scsi busses/ide/ide_isa file_systems/bfs generic/blkman generic/fast_log generic/ide_adapter generic/locked_pool generic/scsi_periph partitioning_systems/intel; do
2005-03-06 03:15:26 +03:00
$ln -fs /boot/beos/system/add-ons/kernel/$f $(basename $f)
2004-11-16 04:45:22 +03:00
done
for f in drivers/dev/disk/scsi/scsi_dsk drivers/dev/disk/scsi/scsi_cd; do
2005-03-06 03:15:26 +03:00
$ln -fs /boot/beos/system/add-ons/kernel/drivers/bin/$(basename $f) .
2004-11-16 04:45:22 +03:00
done
# driver links
2005-01-19 05:09:20 +03:00
echo "Creating driver links..."
2005-03-06 03:15:26 +03:00
$cd $targetDir/beos/system/add-ons/kernel
2005-01-16 00:33:33 +03:00
for f in drivers/dev/dprintf drivers/dev/keyboard drivers/dev/null \
drivers/dev/misc/config drivers/dev/tty drivers/dev/zero \
drivers/dev/disk/scsi/scsi_dsk drivers/dev/disk/scsi/scsi_cd \
2005-03-06 03:15:26 +03:00
drivers/dev/misc/config drivers/dev/input/ps2_hid \
drivers/dev/console; do
2004-11-16 04:45:22 +03:00
relName=$(echo $f | sed -e s@drivers/dev/@@)
linkName=bin/$(basename $f)
while [ $relName != . ]; do
relName=$(dirname $relName)
linkName=../$linkName
done
2005-03-06 03:15:26 +03:00
$ln -fs $linkName $(dirname $f)
2004-11-16 04:45:22 +03:00
done
2005-01-25 00:27:38 +03:00
# add-ons
echo "Copying add-ons..."
2005-03-06 03:15:26 +03:00
cd $sourceDir/distro/${arch}.R1/beos/system/add-ons/Translators
$scd ${sPrefix}$sourceDir/distro/${arch}.R1/beos/system/add-ons/Translators
2005-01-25 00:27:38 +03:00
for f in $BEOS_ADD_ONS_TRANSLATORS; do
2005-03-06 03:15:26 +03:00
$cp ${sPrefix}$f $targetDir/beos/system/add-ons/Translators/
2005-01-25 00:27:38 +03:00
done
2005-03-06 03:15:26 +03:00
cd $sourceDir/distro/${arch}.R1/beos/system/add-ons/media
$scd ${sPrefix}$sourceDir/distro/${arch}.R1/beos/system/add-ons/media
2005-01-25 00:27:38 +03:00
for f in $BEOS_ADD_ONS_MEDIA; do
2005-03-06 03:15:26 +03:00
$cp ${sPrefix}$f $targetDir/beos/system/add-ons/media/
2005-01-25 00:27:38 +03:00
done
2005-03-06 03:15:26 +03:00
cd $sourceDir/distro/${arch}.R1/beos/system/add-ons/input_server/devices/
$cd ${sPrefix}$sourceDir/distro/${arch}.R1/beos/system/add-ons/input_server/devices/
2005-02-08 03:25:38 +03:00
for f in keyboard; do
2005-03-06 03:15:26 +03:00
$cp ${sPrefix}$f $targetDir/beos/system/add-ons/input_server/devices/
2005-02-08 03:25:38 +03:00
done
2005-01-17 04:33:24 +03:00
# install MIME database
mimeDBSource=$sourceDir/src/data/beos_mime
mimeDBDest=$targetDir/home/config/settings/beos_mime
2005-01-19 05:09:20 +03:00
echo "Deleting old MIME database..."
2005-03-06 03:15:26 +03:00
$rm -rf $mimeDBDest
$mkdir -p $mimeDBDest
2005-01-17 04:33:24 +03:00
2005-01-19 05:09:20 +03:00
echo "Installing MIME database..."
2005-01-17 04:33:24 +03:00
for inSuperFile in $mimeDBSource/*.super; do
superType=$(basename $inSuperFile .super)
outSuperDir=$mimeDBDest/$superType
# compile rdef to rsrc file and the rsrc file to attributes
tmpFile=/tmp/mimedb$$.rsrc
2005-03-06 03:15:26 +03:00
tmpFile2=/tmp/mimedb$$.mime
2005-01-17 04:33:24 +03:00
$rc -o $tmpFile $inSuperFile
2005-03-06 03:15:26 +03:00
mkdir -p $tmpFile2
$resattr -O -o $tmpFile2 $tmpFile
$cp -r ${sPrefix}$tmpFile2 $outSuperDir
rm -rf $tmpFile $tmpFile2
2005-01-17 04:33:24 +03:00
# iterate through the sub types
for inSubFile in $mimeDBSource/$superType/*; do
# check, if the type exists
if test -f $inSubFile && grep META:TYPE $inSubFile &> /dev/null; then
subType=$(basename $inSubFile)
outSubFile=$outSuperDir/$subType
# compile rdef to rsrc file and the rsrc file to attributes
tmpFile=/tmp/mimedb$$.rsrc
2005-03-06 03:15:26 +03:00
tmpFile2=/tmp/mimedb$$.mime
2005-01-17 04:33:24 +03:00
$rc -o $tmpFile $inSubFile
2005-03-06 03:15:26 +03:00
$resattr -O -o $tmpFile2 $tmpFile
$cp ${sPrefix}$tmpFile2 $outSubFile
rm -f $tmpFile $tmpFile2
2005-01-17 04:33:24 +03:00
fi
done
done
2004-11-16 05:25:16 +03:00
cd $previousDir
2004-11-16 04:45:22 +03:00
sync
2004-11-18 23:46:16 +03:00
2004-11-25 06:15:18 +03:00
if [ ! $alreadyMounted ]; then
2005-02-08 03:25:38 +03:00
echo Unmounting ...
2005-03-06 03:15:26 +03:00
$fsShellCommand quit
2004-11-25 06:15:18 +03:00
fi
2004-11-26 13:59:35 +03:00
if [ $archive ]; then
zip haiku.zip $imagePath
fi