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