haiku/build/scripts/build_haiku_image
Ingo Weinhold afed18de79 New build system feature to shorten the turn-around times when working
with image files. E.g.

  jam -q update-image libbe.so kernel_x86

will only build libbe.so and the kernel (if necessary) and copy them
onto the already existing Haiku image. The MIME DB will not be
reinstalled, and only those source directories will be copied for which
the AddSourceDirectoryToHaikuImage rule is given a second argument
(e.g. "1"). The image will otherwise remain unchanged.

The "update-vmware-image" and "update-install" work similarly for the
VMWare image and the directory installation respectively. Note that, due
to the way the VMWare image is created (prepending a header to the
standard image), the file itself is fully rebuilt, i.e. changes made
during the emulation will be lost after updating the VMWare image.

The feature requires Haiku's jam. With other jam versions a similar
effect can be reached by accordingly setting the HAIKU_IMAGE_UPDATE_ONLY
and HAIKU_INCLUDE_IN_IMAGE in the UserBuildConfig file.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20602 a95241bf-73f2-0310-859d-f6bbb57e9c96
2007-04-06 21:13:35 +00:00

170 lines
3.7 KiB
Bash
Executable File

#!/bin/sh
# The first argument is the shell script that initializes the variables:
# sourceDir
# outputDir
# tmpDir
# installDir
# isImage
# imagePath
# imageSize
# addBuildCompatibilityLibDir
# sourceDirsToCopy
# updateOnly
#
# bfsShell
# copyattr
# fsShellCommand
# makebootable
# resattr
# rc
#
if [ $# -gt 0 ]; then
. $1
shift
fi
# this adds the build library dir to LD_LIBRARY_PATH
eval "$addBuildCompatibilityLibDir"
# map the shell commands
if [ $isImage ]; then
sPrefix=:
tPrefix=/myfs/
cd="$fsShellCommand cd"
scd="$fsShellCommand cd"
cp="$fsShellCommand cp"
ln="$fsShellCommand ln"
mkdir="$fsShellCommand mkdir"
rm="$fsShellCommand rm"
mkindex="$fsShellCommand mkindex"
else
sPrefix=
# TODO: This should come from the environment.
tPrefix="$installDir/"
cd=cd
scd=:
cp="$copyattr -d"
ln=ln
mkdir=mkdir
rm=rm
mkindex=mkindex
fi
# create the image and mount it
if [ $isImage ]; then
echo
if [ ! $updateOnly ]; then
echo "Creating image ..."
dd if=/dev/zero of=$imagePath bs=1M count=$imageSize
$bfsShell --initialize $imagePath Haiku
$makebootable $imagePath
fi
$bfsShell -n $imagePath > /dev/null &
sleep 1
fi
# create BEOS:APP_SIG index -- needed to launch apps via signature
if [ ! $updateOnly ]; then
$mkindex BEOS:APP_SIG
fi
echo "Populating image ..."
while [ $# -gt 0 ]; do
. $1
shift
done
# install MIME database
# TODO: It should be possible to do that in the build system too.
if [ ! $updateOnly ]; then
mimeDBSource=$sourceDir/src/data/beos_mime
mimeDBDest=${tPrefix}home/config/settings/beos_mime
echo "Deleting old MIME database ..."
$rm -rf $mimeDBDest
$mkdir -p $mimeDBDest
mkdir -p $tmpDir
mimeTmpDir=$tmpDir/mime
mimeTmpIndex=0
# create tmp dir for the MIME conversion stuff
mkdir -p $mimeTmpDir
echo "Installing MIME database ..."
for inSuperFile in $mimeDBSource/*.super; do
superType=$(basename $inSuperFile .super)
outSuperDir=$mimeDBDest/$superType
# compile rdef to rsrc file and the rsrc file to attributes
mimeTmpIndex=$(($mimeTmpIndex + 1))
tmpFile=$mimeTmpDir/mimedb$$_${mimeTmpIndex}.rsrc
tmpFile2=$mimeTmpDir/mimedb$$_${mimeTmpIndex}.mime
$rc -o $tmpFile $inSuperFile
mkdir -p $tmpFile2
$resattr -O -o $tmpFile2 $tmpFile
$cp -r ${sPrefix}$tmpFile2 $outSuperDir
# 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 2>&1 ; then
subType=$(basename $inSubFile)
outSubFile=$outSuperDir/$subType
# compile rdef to rsrc file and the rsrc file to attributes
mimeTmpIndex=$(($mimeTmpIndex + 1))
tmpFile=$mimeTmpDir/mimedb$$_${mimeTmpIndex}.rsrc
tmpFile2=$mimeTmpDir/mimedb$$_${mimeTmpIndex}.mime
$rc -o $tmpFile $inSubFile
$resattr -O -o $tmpFile2 $tmpFile
$cp ${sPrefix}$tmpFile2 $outSubFile
fi
done
done
# cleanup tmp dir
rm -rf $mimeTmpDir
fi # ! updateOnly
# install sources
sourcesDest=${tPrefix}home/HaikuSources
# create sources directory
if [ -n "${sourceDirsToCopy}" ]; then
echo "Installing Haiku Sources ..."
$mkdir -p ${sourcesDest}
fi
for sourcesDir in ${sourceDirsToCopy}; do
echo " sources dir: ${sourcesDir}"
# create all subdirectories
subDirs=$(find ${sourcesDir} -type d | grep -v '.svn' |
sed -e "s@^${sourceDir}@${sourcesDest}@")
$mkdir -p ${subDirs}
# get all files and copy each one individually
sourceFiles=$(find $sourcesDir -type f | grep -v '.svn')
for sourceFile in $sourceFiles; do
destSourceFile=$(echo $sourceFile |
sed -e "s@^${sourceDir}@${sourcesDest}@")
$cp ${sPrefix}$sourceFile $destSourceFile
done
done
# unmount
if [ $isImage ]; then
echo "Unmounting ..."
$fsShellCommand sync
$fsShellCommand quit
fi