2005-10-29 20:27:43 +04:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# The first argument is the shell script that initializes the variables.
|
|
|
|
# sourceDir
|
|
|
|
# outputDir
|
|
|
|
# tmpDir
|
|
|
|
# installDir
|
|
|
|
# isImage
|
|
|
|
# imagePath
|
|
|
|
# imageSize
|
|
|
|
# addBuildCompatibilityLibDir
|
|
|
|
#
|
|
|
|
# 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
|
2006-05-05 23:55:49 +04:00
|
|
|
mkindex=
|
2005-10-29 20:27:43 +04:00
|
|
|
fi
|
|
|
|
|
|
|
|
# create the image and mount it
|
|
|
|
if [ $isImage ]; then
|
|
|
|
echo
|
|
|
|
echo "Creating image ..."
|
|
|
|
dd if=/dev/zero of=$imagePath bs=1M count=$imageSize
|
|
|
|
$bfsShell --initialize $imagePath Haiku
|
|
|
|
$makebootable $imagePath
|
|
|
|
$bfsShell -n $imagePath > /dev/null &
|
|
|
|
sleep 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
$mkindex BEOS:APP_SIG
|
|
|
|
# needed to launch apps via signature
|
|
|
|
|
|
|
|
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.
|
|
|
|
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
|
2006-05-08 14:40:51 +04:00
|
|
|
mimeTmpDir=$tmpDir/mime
|
|
|
|
mimeTmpIndex=0
|
|
|
|
|
|
|
|
# create tmp dir for the MIME conversion stuff
|
|
|
|
mkdir -p $mimeTmpDir
|
2005-10-29 20:27:43 +04:00
|
|
|
|
|
|
|
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
|
2006-05-08 14:40:51 +04:00
|
|
|
mimeTmpIndex=$[$mimeTmpIndex + 1]
|
|
|
|
tmpFile=$mimeTmpDir/mimedb$$_${mimeTmpIndex}.rsrc
|
|
|
|
tmpFile2=$mimeTmpDir/mimedb$$_${mimeTmpIndex}.mime
|
2005-10-29 20:27:43 +04:00
|
|
|
$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; then
|
|
|
|
subType=$(basename $inSubFile)
|
|
|
|
outSubFile=$outSuperDir/$subType
|
|
|
|
|
|
|
|
# compile rdef to rsrc file and the rsrc file to attributes
|
2006-05-08 14:40:51 +04:00
|
|
|
mimeTmpIndex=$[$mimeTmpIndex + 1]
|
|
|
|
tmpFile=$mimeTmpDir/mimedb$$_${mimeTmpIndex}.rsrc
|
|
|
|
tmpFile2=$mimeTmpDir/mimedb$$_${mimeTmpIndex}.mime
|
2005-10-29 20:27:43 +04:00
|
|
|
$rc -o $tmpFile $inSubFile
|
|
|
|
$resattr -O -o $tmpFile2 $tmpFile
|
|
|
|
$cp ${sPrefix}$tmpFile2 $outSubFile
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
2006-05-08 14:40:51 +04:00
|
|
|
# cleanup tmp dir
|
|
|
|
rm -rf $mimeTmpDir
|
2005-10-29 20:27:43 +04:00
|
|
|
|
|
|
|
# unmount
|
|
|
|
if [ $isImage ]; then
|
|
|
|
echo "Unmounting ..."
|
|
|
|
$fsShellCommand sync
|
|
|
|
$fsShellCommand quit
|
|
|
|
fi
|