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.
#
# You need the Userland FS Server package from Ingo Weinhold to successfully
# create the image, and you also need to have the UserlandFSServer running
2004-11-25 21:38:24 +03:00
# in the background when you start the script (as long as you don't use
2004-11-26 17:10:20 +03:00
# the target directory mode). The package is available here:
# http://tfs.cs.tu-berlin.de/~bonefish/download/userlandfs.zip
2004-11-16 05:25:16 +03:00
#
# 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
# "current" directory of the Haiku tree. A 40 MB image will be created there.
#
2004-11-25 21:38:24 +03:00
# If you specify a target directory, no image is going to be created at
# all, and also the Userland FS Server is not needed.
#
2004-11-16 05:25:16 +03:00
# You may want to change it to suit your needs. Have fun!
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
2004-11-16 04:45:22 +03:00
imageSize=40
# ufs_mount path
2004-11-26 13:59:35 +03:00
ufsMount=ufs_mount
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
2004-11-16 04:45:22 +03:00
RUN_WITHOUT_APP_SERVER=1
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 \
renice rmattr addattr listdev pwd chmod chown chgrp dd tee md5sum"
2004-11-16 05:25:16 +03:00
BEOS_SYSTEM_LIB="libbe.so libstdc++.r4.so libnet.so"
2004-11-16 04:45:22 +03:00
jam -q 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 \
$BEOS_BIN $BEOS_SYSTEM_LIB \
2004-12-04 01:32:58 +03:00
kernel_uname libnet.so null zero random \<driver\>tty \<driver\>config \
2004-11-25 06:15:18 +03:00
|| exit 1
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
dd if=/dev/zero of=$imagePath bs=1M count=$imageSize
mkbfs $imagePath Haiku
mkdir -p $targetDir
sync
$ufsMount obfs $imagePath $targetDir || exit 1
fi
2004-11-16 04:45:22 +03:00
2004-11-25 06:15:18 +03:00
cd $targetDir
2004-12-04 01:32:58 +03:00
# this avoids diskspace leaking with our current BFS version
# (because of some unidentified bugs, of course :)
rm -rf beos
2004-11-16 04:45:22 +03:00
mkdir -p beos/system/add-ons/kernel/bus_managers
mkdir -p beos/system/add-ons/kernel/generic
mkdir -p beos/system/add-ons/kernel/file_systems
mkdir -p beos/system/add-ons/kernel/partitioning_systems
mkdir -p beos/system/add-ons/kernel/busses/ide
mkdir -p beos/system/add-ons/kernel/boot
mkdir -p beos/system/add-ons/kernel/drivers/bin
mkdir -p beos/system/add-ons/kernel/drivers/dev/disk/scsi
2004-12-02 13:50:26 +03:00
mkdir -p beos/system/add-ons/kernel/drivers/dev/misc
2004-11-16 04:45:22 +03:00
mkdir -p beos/bin
mkdir -p beos/system/lib
mkdir -p beos/system/boot
mkdir -p beos/etc
2004-11-16 05:25:16 +03:00
mkdir -p home/config
2004-11-26 13:59:35 +03:00
mkdir -p home/config/settings
2004-11-16 04:45:22 +03:00
# modules
cd $sourceDir/distro/x86.R1/beos/system/add-ons/kernel
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 \
generic/locked_pool generic/scsi_periph partitioning_systems/intel; do
2004-11-25 06:15:18 +03:00
cp $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)
2004-11-25 06:15:18 +03:00
cp $name $targetDir/beos/system/add-ons/kernel/$name
2004-11-16 04:45:22 +03:00
done
cd $sourceDir/objects/x86.R1/add-ons/kernel
for f in bus_managers/config_manager bus_managers/pci; do
name=$(basename $f)
2004-11-25 06:15:18 +03:00
cp $f/$name $targetDir/beos/system/add-ons/kernel/$f
2004-11-16 04:45:22 +03:00
done
# drivers
for f in drivers/arch/x86/keyboard/keyboard; do
2004-11-25 06:15:18 +03:00
cp $f $targetDir/beos/system/add-ons/kernel/drivers/bin
2004-11-16 04:45:22 +03:00
done
cd $sourceDir/distro/x86.R1/beos/system/add-ons/kernel/drivers/dev
2004-12-02 13:50:26 +03:00
for f in config tty random null zero; do
2004-11-25 06:15:18 +03:00
cp $f $targetDir/beos/system/add-ons/kernel/drivers/bin
2004-11-16 04:45:22 +03:00
done
# kernel
2004-11-25 06:15:18 +03:00
cp $sourceDir/objects/x86.R1/kernel/kernel $targetDir/beos/system/kernel_x86
2004-11-16 04:45:22 +03:00
# libs
cd $sourceDir/distro/x86.R1/beos/system/lib
2004-11-25 06:15:18 +03:00
cp $BEOS_SYSTEM_LIB $targetDir/beos/system/lib/
2004-11-16 04:45:22 +03:00
cd $sourceDir/objects/x86.R1/kernel/
2004-11-25 06:15:18 +03:00
cp rld.so libroot.so $targetDir/beos/system/lib/
2004-11-16 04:45:22 +03:00
# apps
cd $sourceDir/objects/x86.R1/kernel
2004-11-16 05:25:16 +03:00
for f in fortune uname; do
2004-11-25 06:15:18 +03:00
cp kernel_$f $targetDir/beos/bin/$f
2004-11-16 04:45:22 +03:00
done
2004-11-16 05:25:16 +03:00
cd $sourceDir/distro/x86.R1/beos/bin
2004-11-25 06:15:18 +03:00
cp ../apps/consoled $BEOS_BIN $targetDir/beos/bin/
2004-11-25 21:38:24 +03:00
cd $targetDir/beos/bin
2004-11-16 05:25:16 +03:00
# scripts and data files
cd $sourceDir
2004-11-25 06:15:18 +03:00
cp data/system/boot/Bootscript data/system/boot/SetupEnvironment $targetDir/beos/system/boot/
cp data/etc/profile $targetDir/beos/etc/
cp src/kernel/apps/fortune/fortunes $targetDir/beos/etc/
2004-12-05 03:50:48 +03:00
cp -R distro/x86.R1/beos/etc $targetDir//beos/
ln -sf /boot/beos/etc/timezones/Europe/Paris $targetDir//home/config/settings/timezone
2004-11-16 04:45:22 +03:00
# boot loader
2004-11-25 06:15:18 +03:00
cd $targetDir/beos/system
2004-11-16 04:45:22 +03:00
objcopy -O binary $sourceDir/objects/x86.R1/kernel/boot_loader zbeos
# boot module links
2004-11-25 06:15:18 +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
ln -fs /boot/beos/system/add-ons/kernel/$f $(basename $f)
done
for f in drivers/dev/disk/scsi/scsi_dsk drivers/dev/disk/scsi/scsi_cd; do
ln -fs /boot/beos/system/add-ons/kernel/drivers/bin/$(basename $f) .
done
# driver links
2004-11-25 06:15:18 +03:00
cd $targetDir/beos/system/add-ons/kernel
2004-11-16 04:45:22 +03:00
for f in drivers/dev/keyboard drivers/dev/null drivers/dev/tty drivers/dev/zero \
2004-12-02 13:50:26 +03:00
drivers/dev/disk/scsi/scsi_dsk drivers/dev/disk/scsi/scsi_cd drivers/dev/misc/config; 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
(cd $(dirname $f); ln -fs $linkName .)
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
2004-11-26 13:59:35 +03:00
sleep 1
2004-11-25 06:15:18 +03:00
unmount $targetDir
2004-11-26 13:59:35 +03:00
sleep 1
sync
2004-11-25 06:15:18 +03:00
rmdir $targetDir
2004-11-26 13:59:35 +03:00
sync
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