1#!/bin/sh 2 3# The first argument is the shell script that initializes the variables: 4# sourceDir 5# outputDir 6# tmpDir 7# installDir 8# isImage 9# imagePath 10# imageSize 11# addBuildCompatibilityLibDir 12# sourceDirsToCopy 13# updateOnly 14# 15# bfsShell 16# copyattr 17# fsShellCommand 18# makebootable 19# resattr 20# rc 21# 22if [ $# -gt 0 ]; then 23 . $1 24 shift 25fi 26 27# this adds the build library dir to LD_LIBRARY_PATH 28eval "$addBuildCompatibilityLibDir" 29 30# map the shell commands 31if [ $isImage ]; then 32 sPrefix=: 33 tPrefix=/myfs/ 34 cd="$fsShellCommand cd" 35 scd="$fsShellCommand cd" 36 cp="$fsShellCommand cp" 37 ln="$fsShellCommand ln" 38 mkdir="$fsShellCommand mkdir" 39 rm="$fsShellCommand rm" 40 mkindex="$fsShellCommand mkindex" 41else 42 sPrefix= 43 # TODO: This should come from the environment. 44 tPrefix="$installDir/" 45 cd=cd 46 scd=: 47 cp="$copyattr -d" 48 ln=ln 49 mkdir=mkdir 50 rm=rm 51 mkindex=mkindex 52fi 53 54# create the image and mount it 55if [ $isImage ]; then 56 echo 57 if [ ! $updateOnly ]; then 58 echo "Creating image ..." 59 dd if=/dev/zero of=$imagePath bs=1048576 count=$imageSize 60 $bfsShell --initialize $imagePath Haiku 61 $makebootable $imagePath 62 fi 63 $bfsShell -n $imagePath > /dev/null & 64 sleep 1 65fi 66 67# create BEOS:APP_SIG index -- needed to launch apps via signature 68if [ ! $updateOnly ]; then 69 $mkindex BEOS:APP_SIG 70fi 71 72echo "Populating image ..." 73while [ $# -gt 0 ]; do 74 . $1 75 shift 76done 77 78 79# install MIME database 80# TODO: It should be possible to do that in the build system too. 81 82if [ ! $updateOnly ]; then 83 mimeDBSource=$sourceDir/src/data/beos_mime 84 mimeDBDest=${tPrefix}home/config/settings/beos_mime 85 86 echo "Deleting old MIME database ..." 87 88 $rm -rf $mimeDBDest 89 $mkdir -p $mimeDBDest 90 mkdir -p $tmpDir 91 mimeTmpDir=$tmpDir/mime 92 mimeTmpIndex=0 93 94 # create tmp dir for the MIME conversion stuff 95 mkdir -p $mimeTmpDir 96 97 echo "Installing MIME database ..." 98 99 for inSuperFile in $mimeDBSource/*.super; do 100 superType=$(basename $inSuperFile .super) 101 outSuperDir=$mimeDBDest/$superType 102 103 # compile rdef to rsrc file and the rsrc file to attributes 104 mimeTmpIndex=$(($mimeTmpIndex + 1)) 105 tmpFile=$mimeTmpDir/mimedb$$_${mimeTmpIndex}.rsrc 106 tmpFile2=$mimeTmpDir/mimedb$$_${mimeTmpIndex}.mime 107 $rc -o $tmpFile $inSuperFile 108 mkdir -p $tmpFile2 109 $resattr -O -o $tmpFile2 $tmpFile 110 $cp -r ${sPrefix}$tmpFile2 $outSuperDir 111 112 # iterate through the sub types 113 for inSubFile in $mimeDBSource/$superType/*; do 114 # check, if the type exists 115 if test -f $inSubFile && grep META:TYPE $inSubFile > /dev/null 2>&1 ; then 116 subType=$(basename $inSubFile) 117 outSubFile=$outSuperDir/$subType 118 119 # compile rdef to rsrc file and the rsrc file to attributes 120 mimeTmpIndex=$(($mimeTmpIndex + 1)) 121 tmpFile=$mimeTmpDir/mimedb$$_${mimeTmpIndex}.rsrc 122 tmpFile2=$mimeTmpDir/mimedb$$_${mimeTmpIndex}.mime 123 $rc -o $tmpFile $inSubFile 124 $resattr -O -o $tmpFile2 $tmpFile 125 $cp ${sPrefix}$tmpFile2 $outSubFile 126 fi 127 done 128 done 129 130 # cleanup tmp dir 131 rm -rf $mimeTmpDir 132fi # ! updateOnly 133 134 135# install sources 136 137sourcesDest=${tPrefix}home/HaikuSources 138 139# create sources directory 140if [ -n "${sourceDirsToCopy}" ]; then 141 echo "Installing Haiku Sources ..." 142 143 $mkdir -p ${sourcesDest} 144fi 145 146for sourcesDir in ${sourceDirsToCopy}; do 147 echo " sources dir: ${sourcesDir}" 148 149 # create all subdirectories 150 subDirs=$(find ${sourcesDir} -type d | grep -v '.svn' | 151 sed -e "s@^${sourceDir}@${sourcesDest}@") 152 $mkdir -p ${subDirs} 153 154 # get all files and copy each one individually 155 sourceFiles=$(find $sourcesDir -type f | grep -v '.svn') 156 for sourceFile in $sourceFiles; do 157 destSourceFile=$(echo $sourceFile | 158 sed -e "s@^${sourceDir}@${sourcesDest}@") 159 $cp ${sPrefix}$sourceFile $destSourceFile 160 done 161done 162 163 164# unmount 165if [ $isImage ]; then 166 echo "Unmounting ..." 167 $fsShellCommand sync 168 $fsShellCommand quit 169fi 170