2005-10-29 20:27:43 +04:00
|
|
|
#!/bin/sh
|
|
|
|
|
2007-04-07 01:13:35 +04:00
|
|
|
# The first argument is the shell script that initializes the variables:
|
2005-10-29 20:27:43 +04:00
|
|
|
# sourceDir
|
|
|
|
# outputDir
|
|
|
|
# tmpDir
|
|
|
|
# installDir
|
|
|
|
# isImage
|
|
|
|
# imagePath
|
|
|
|
# imageSize
|
|
|
|
# addBuildCompatibilityLibDir
|
2007-03-25 03:34:28 +04:00
|
|
|
# sourceDirsToCopy
|
2007-04-07 01:13:35 +04:00
|
|
|
# updateOnly
|
2007-10-01 21:27:13 +04:00
|
|
|
# dontClearImage
|
2005-10-29 20:27:43 +04:00
|
|
|
#
|
|
|
|
# bfsShell
|
|
|
|
# copyattr
|
|
|
|
# fsShellCommand
|
|
|
|
# makebootable
|
|
|
|
# resattr
|
|
|
|
# rc
|
2007-09-05 01:50:00 +04:00
|
|
|
# unzip
|
2005-10-29 20:27:43 +04:00
|
|
|
#
|
|
|
|
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"
|
2007-07-27 03:20:58 +04:00
|
|
|
copyAttrs="$fsShellCommand cp -a"
|
2005-10-29 20:27:43 +04:00
|
|
|
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"
|
2007-07-27 03:20:58 +04:00
|
|
|
copyAttrs="$copyattr"
|
2005-10-29 20:27:43 +04:00
|
|
|
ln=ln
|
|
|
|
mkdir=mkdir
|
|
|
|
rm=rm
|
2006-11-03 12:36:49 +03:00
|
|
|
mkindex=mkindex
|
2005-10-29 20:27:43 +04:00
|
|
|
fi
|
|
|
|
|
2007-09-05 01:50:00 +04:00
|
|
|
|
2007-11-18 01:26:17 +03:00
|
|
|
# attribute-safe rm -rf
|
|
|
|
# This makes sure there are no leftover attribute file before removing each file
|
|
|
|
attrrmrf()
|
|
|
|
{
|
|
|
|
test -e "$1" || return
|
2007-11-19 03:30:00 +03:00
|
|
|
if [ -d "$outputDir/attributes" ]; then
|
|
|
|
find "$1" -print0 | xargs -0 stat -c %i | awk "{ print \"$outputDir/attributes/\" \$1 }" | xargs rm -rf
|
|
|
|
fi
|
2007-11-18 01:26:17 +03:00
|
|
|
rm -rf "$1"
|
|
|
|
}
|
|
|
|
|
2007-09-05 01:50:00 +04:00
|
|
|
unzipFile()
|
|
|
|
{
|
|
|
|
# unzipFile <archive> <directory>
|
|
|
|
zipFile=$1
|
|
|
|
targetUnzipDir=$2
|
|
|
|
|
|
|
|
echo "Unzipping $zipFile ..."
|
|
|
|
|
|
|
|
if [ $isImage ]; then
|
|
|
|
unzipDir=$tmpDir/unzip
|
2007-11-18 01:26:17 +03:00
|
|
|
attrrmrf $unzipDir
|
2007-09-05 01:50:00 +04:00
|
|
|
mkdir -p $unzipDir
|
|
|
|
|
|
|
|
$unzip -q -d $unzipDir $zipFile
|
|
|
|
$cp -r ${sPrefix}$unzipDir/. ${tPrefix}$targetUnzipDir
|
|
|
|
|
2007-11-18 01:26:17 +03:00
|
|
|
attrrmrf $unzipDir
|
2007-09-05 01:50:00 +04:00
|
|
|
else
|
|
|
|
$unzip -q -d ${tPrefix}$targetUnzipDir ${sPrefix}$zipFile
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-10-29 20:27:43 +04:00
|
|
|
# create the image and mount it
|
|
|
|
if [ $isImage ]; then
|
|
|
|
echo
|
2007-04-07 01:13:35 +04:00
|
|
|
if [ ! $updateOnly ]; then
|
|
|
|
echo "Creating image ..."
|
2007-10-01 21:36:52 +04:00
|
|
|
if [ ! -e $imagePath -o ! "$dontClearImage" ]; then
|
2007-10-01 21:27:13 +04:00
|
|
|
dd if=/dev/zero of=$imagePath bs=1048576 count=$imageSize
|
|
|
|
fi
|
2007-04-07 01:13:35 +04:00
|
|
|
$bfsShell --initialize $imagePath Haiku
|
|
|
|
$makebootable $imagePath
|
|
|
|
fi
|
2005-10-29 20:27:43 +04:00
|
|
|
$bfsShell -n $imagePath > /dev/null &
|
|
|
|
sleep 1
|
|
|
|
fi
|
|
|
|
|
2007-04-07 01:13:35 +04:00
|
|
|
# create BEOS:APP_SIG index -- needed to launch apps via signature
|
|
|
|
if [ ! $updateOnly ]; then
|
|
|
|
$mkindex BEOS:APP_SIG
|
|
|
|
fi
|
2005-10-29 20:27:43 +04:00
|
|
|
|
|
|
|
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.
|
2007-04-07 01:13:35 +04:00
|
|
|
|
|
|
|
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
|
2005-10-29 20:27:43 +04:00
|
|
|
done
|
|
|
|
|
2007-04-07 01:13:35 +04:00
|
|
|
# cleanup tmp dir
|
2007-11-18 01:26:17 +03:00
|
|
|
attrrmrf $mimeTmpDir
|
2007-04-07 01:13:35 +04:00
|
|
|
fi # ! updateOnly
|
2005-10-29 20:27:43 +04:00
|
|
|
|
2007-03-25 03:34:28 +04:00
|
|
|
|
|
|
|
# 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
|
|
|
|
|
|
|
|
|
2005-10-29 20:27:43 +04:00
|
|
|
# unmount
|
|
|
|
if [ $isImage ]; then
|
|
|
|
echo "Unmounting ..."
|
|
|
|
$fsShellCommand sync
|
|
|
|
$fsShellCommand quit
|
|
|
|
fi
|