2005-10-29 20:27:43 +04:00
|
|
|
#!/bin/sh
|
2010-01-19 05:39:03 +03:00
|
|
|
set -o errexit
|
2005-10-29 20:27:43 +04:00
|
|
|
|
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
|
2010-04-11 03:14:42 +04:00
|
|
|
# addBuildCompatibilityLibDir
|
2010-04-24 23:52:36 +04:00
|
|
|
# gccVersion
|
|
|
|
# isHybridBuild
|
2010-04-11 03:14:42 +04:00
|
|
|
# The following are only for image types:
|
2005-10-29 20:27:43 +04:00
|
|
|
# installDir
|
|
|
|
# isImage
|
|
|
|
# imagePath
|
|
|
|
# imageSize
|
2008-09-19 21:32:57 +04:00
|
|
|
# imageLabel
|
2007-04-07 01:13:35 +04:00
|
|
|
# updateOnly
|
2007-10-01 21:27:13 +04:00
|
|
|
# dontClearImage
|
2008-02-17 16:54:32 +03:00
|
|
|
# isVMwareImage
|
2008-05-04 20:06:41 +04:00
|
|
|
# optionalPackageDescriptions
|
2008-08-18 12:39:46 +04:00
|
|
|
#
|
2008-04-19 19:55:54 +04:00
|
|
|
# addattr
|
2005-10-29 20:27:43 +04:00
|
|
|
# copyattr
|
|
|
|
# rc
|
* BuildPlatformMain supports overriding HOST_LIBROOT on the target now,
so one can set it to the static libroot, if desired.
* Generic attribute emulation:
- Added build tool rm_attrs, a simple "rm" replacement, which also
removes the attributes directory for a given file.
- Added build/scripts/rm_attrs shell script, which wraps the
invocation of the rm_attrs tool. If it doesn't exist yet, the
ordinary rm is used.
- The RM jam variable refers to the rm_attrs script now, i.e. whenever
something is removed by the build system, the attributes are removed
too (if the build tool has already been built, that is).
- Removed the shell function attrrmrf() in build_haiku_image. We use
the rm_attrs tool instead, if necessary.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24528 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-03-23 00:05:03 +03:00
|
|
|
# rmAttrs
|
2007-09-05 01:50:00 +04:00
|
|
|
# unzip
|
2010-04-11 03:14:42 +04:00
|
|
|
# The following are only for image types:
|
|
|
|
# bfsShell
|
|
|
|
# fsShellCommand
|
|
|
|
# makebootable
|
|
|
|
# resattr
|
2008-04-04 01:18:18 +04:00
|
|
|
# vmdkimage
|
2010-04-11 03:14:42 +04:00
|
|
|
# The following is only for cd types:
|
|
|
|
# generate_attribute_stores
|
|
|
|
# isCD
|
2005-10-29 20:27:43 +04:00
|
|
|
#
|
|
|
|
if [ $# -gt 0 ]; then
|
|
|
|
. $1
|
|
|
|
shift
|
|
|
|
fi
|
|
|
|
|
2010-04-11 03:14:42 +04:00
|
|
|
if [ ! $isCD ]; then
|
|
|
|
# If the haiku image path is a symlink resolve it now (makebootable needs the
|
|
|
|
# path of the actual device path under Linux).
|
|
|
|
normalizedImagePath=''
|
|
|
|
if readlink -f "$imagePath" > /dev/null 2>&1 ; then
|
|
|
|
normalizedImagePath=$(readlink -f "$imagePath")
|
2010-04-20 07:36:06 +04:00
|
|
|
elif realpath "$imagePath" > /dev/null 2>&1 ; then
|
2010-04-28 00:14:18 +04:00
|
|
|
normalizedImagePath=$(realpath "$imagePath")
|
2010-04-11 03:14:42 +04:00
|
|
|
elif greadlink -f "$imagePath" > /dev/null 2>&1 ; then
|
|
|
|
normalizedImagePath=$(greadlink -f "$imagePath")
|
|
|
|
fi
|
|
|
|
if [ -n "$normalizedImagePath" ]; then
|
|
|
|
imagePath="$normalizedImagePath"
|
|
|
|
fi
|
2008-06-18 17:02:41 +04:00
|
|
|
fi
|
|
|
|
|
2005-10-29 20:27:43 +04:00
|
|
|
# this adds the build library dir to LD_LIBRARY_PATH
|
|
|
|
eval "$addBuildCompatibilityLibDir"
|
|
|
|
|
|
|
|
# map the shell commands
|
2010-04-11 03:14:42 +04:00
|
|
|
if [ $isCD ]; then
|
|
|
|
outputDir=$tmpDir/cdsource
|
|
|
|
|
|
|
|
sPrefix=
|
|
|
|
tPrefix="$outputDir/"
|
|
|
|
cd=cd
|
|
|
|
scd=:
|
|
|
|
cp="$copyattr -d"
|
|
|
|
copyAttrs="$copyattr"
|
|
|
|
ln=ln
|
|
|
|
mkdir=mkdir
|
|
|
|
rm=rm
|
|
|
|
elif [ $isImage ]; then
|
2005-10-29 20:27:43 +04:00
|
|
|
sPrefix=:
|
|
|
|
tPrefix=/myfs/
|
|
|
|
cd="$fsShellCommand cd"
|
|
|
|
scd="$fsShellCommand cd"
|
2008-08-18 12:39:46 +04:00
|
|
|
cp="$fsShellCommand cp -f"
|
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
|
|
|
|
|
2010-04-25 01:32:17 +04:00
|
|
|
|
2010-02-27 20:48:12 +03:00
|
|
|
extractFile()
|
2007-09-05 01:50:00 +04:00
|
|
|
{
|
2010-02-27 20:48:12 +03:00
|
|
|
# extractFile <archive> <directory>
|
|
|
|
archiveFile=$1
|
|
|
|
targetExtractedDir=$2
|
2010-02-27 21:15:47 +03:00
|
|
|
extractedSubDir=$3
|
2010-04-24 23:52:36 +04:00
|
|
|
isGCCAgnostic=$4
|
2010-02-27 20:48:12 +03:00
|
|
|
|
|
|
|
echo "Extracting $archiveFile ..."
|
|
|
|
|
|
|
|
extractDir=$tmpDir/extract
|
|
|
|
$rmAttrs -rf "$extractDir"
|
|
|
|
mkdir -p "$extractDir"
|
2010-04-24 23:52:36 +04:00
|
|
|
|
2010-02-27 20:48:12 +03:00
|
|
|
case "$archiveFile" in
|
|
|
|
*.zip)
|
|
|
|
$unzip -q -d "$extractDir" "$archiveFile"
|
|
|
|
;;
|
|
|
|
*.tgz|*.tar.gz)
|
|
|
|
tar -C "$extractDir" -xf "$archiveFile"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Unhandled archive extension in build_haiku_image extractFile()"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
2010-04-24 23:52:36 +04:00
|
|
|
|
2010-02-27 20:48:12 +03:00
|
|
|
if [ -f $extractDir/.OptionalPackageDescription ]; then
|
|
|
|
cat $extractDir/.OptionalPackageDescription >> $copyrightsFile
|
2008-04-19 19:55:54 +04:00
|
|
|
echo >> $copyrightsFile
|
2010-02-27 20:48:12 +03:00
|
|
|
rm $extractDir/.OptionalPackageDescription
|
2007-09-05 01:50:00 +04:00
|
|
|
fi
|
2008-04-19 19:55:54 +04:00
|
|
|
|
2010-04-25 01:32:17 +04:00
|
|
|
if [ "$isGCCAgnostic" = "true" ] && [ $isHybridBuild ] ; then
|
2010-04-24 23:52:36 +04:00
|
|
|
extractedLibs=`find "$extractDir/$extractedSubDir/" -name "*.so"`
|
|
|
|
moreExtractedLibs=`find "$extractDir/$extractedSubDir/" -name "*.so.*"`
|
2010-07-18 07:11:28 +04:00
|
|
|
staticLibs=`find "$extractDir/$extractedSubDir/" -name "*.a"`
|
|
|
|
#NOTE: should we symlink libtool's *.la files?
|
|
|
|
#laLibs=`find "$extractDir/$extractedSubDir/" -name "*.la"`
|
|
|
|
createSymlinksForHybrid $extractedLibs $moreExtractedLibs $staticLibs
|
2010-04-24 23:52:36 +04:00
|
|
|
fi
|
|
|
|
|
2010-02-27 21:15:47 +03:00
|
|
|
$cp -r "${sPrefix}$extractDir/$extractedSubDir/." "${tPrefix}$targetExtractedDir"
|
2008-04-19 19:55:54 +04:00
|
|
|
|
2010-02-27 20:48:12 +03:00
|
|
|
$rmAttrs -rf "$extractDir"
|
2007-09-05 01:50:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-04-24 23:52:36 +04:00
|
|
|
createSymlinksForHybrid()
|
|
|
|
{
|
|
|
|
# createSymlinksForHybrid <libraries>
|
|
|
|
|
|
|
|
# Determine the alternative gcc subdir.
|
|
|
|
if [ $gccVersion -eq 2 ]; then
|
|
|
|
gccAltDir=gcc4
|
|
|
|
else
|
|
|
|
gccAltDir=gcc2
|
|
|
|
fi
|
2010-04-28 00:14:18 +04:00
|
|
|
|
2010-04-24 23:52:36 +04:00
|
|
|
# Iterate over the library file paths that were passed in.
|
|
|
|
for srcPathLib in $@; do
|
|
|
|
# determine the relative path of the library
|
|
|
|
relPathLib=`echo $srcPathLib | \
|
|
|
|
sed -e "s:${extractDir}/${extractedSubDir}/::"`
|
|
|
|
relPath=`dirname $relPathLib`
|
|
|
|
|
|
|
|
# check if that relative path is one of the standard library paths
|
|
|
|
standardLibPaths="system/lib common/lib home/config/lib"
|
|
|
|
isStandardPath=
|
|
|
|
for stdLibPath in $standardLibPaths; do
|
2010-04-25 01:32:17 +04:00
|
|
|
if [ "$relPath" = "$stdLibPath" ]; then
|
2010-04-24 23:52:36 +04:00
|
|
|
isStandardPath=true
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# create alt gcc symlinks for libs inside standard paths
|
|
|
|
if [ $isStandardPath ]; then
|
|
|
|
srcPath=`dirname $srcPathLib`
|
|
|
|
srcLib=`basename $srcPathLib`
|
|
|
|
destLinkDir="${srcPath}/${gccAltDir}"
|
|
|
|
destLinkTarget="../$srcLib"
|
|
|
|
|
|
|
|
mkdir -p $destLinkDir
|
2010-04-25 08:32:33 +04:00
|
|
|
ln -sf $destLinkTarget $destLinkDir
|
2010-04-24 23:52:36 +04:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-04-19 19:55:54 +04:00
|
|
|
mkdir -p $tmpDir
|
|
|
|
copyrightsFile=$tmpDir/copyrights
|
|
|
|
$rmAttrs -f $copyrightsFile
|
2008-05-04 20:06:41 +04:00
|
|
|
if [ "$optionalPackageDescriptions" ]; then
|
|
|
|
cp "$optionalPackageDescriptions" $copyrightsFile
|
|
|
|
fi
|
2008-04-19 19:55:54 +04:00
|
|
|
|
2010-04-11 03:14:42 +04:00
|
|
|
if [ $isCD ]; then
|
|
|
|
# setup output dir
|
|
|
|
$rmAttrs -rf "$outputDir"
|
|
|
|
mkdir -p "$outputDir"
|
2010-04-28 00:14:18 +04:00
|
|
|
fi
|
2008-04-19 19:55:54 +04:00
|
|
|
|
2005-10-29 20:27:43 +04:00
|
|
|
# create the image and mount it
|
|
|
|
if [ $isImage ]; then
|
|
|
|
echo
|
2008-02-17 16:54:32 +03:00
|
|
|
|
|
|
|
imageOffsetFlags=
|
|
|
|
if [ $isVMwareImage ]; then
|
|
|
|
imageOffsetFlags="--start-offset 65536"
|
|
|
|
fi
|
|
|
|
|
2007-04-07 01:13:35 +04:00
|
|
|
if [ ! $updateOnly ]; then
|
|
|
|
echo "Creating image ..."
|
2008-02-17 16:54:32 +03:00
|
|
|
|
2009-04-12 13:18:18 +04:00
|
|
|
imageFlags="-i${imageSize}M"
|
|
|
|
if [ ! "$dontClearImage" ]; then
|
|
|
|
imageFlags="$imageFlags -c"
|
|
|
|
fi
|
|
|
|
|
2008-02-17 16:54:32 +03:00
|
|
|
if [ $isVMwareImage ]; then
|
2010-01-19 05:39:03 +03:00
|
|
|
$vmdkimage -h 64k $imageFlags "$imagePath"
|
2009-04-12 13:18:18 +04:00
|
|
|
else
|
2010-01-19 05:39:03 +03:00
|
|
|
$createImage $imageFlags "$imagePath"
|
2008-02-17 16:54:32 +03:00
|
|
|
fi
|
|
|
|
|
2008-09-19 21:32:57 +04:00
|
|
|
$bfsShell --initialize $imageOffsetFlags "$imagePath" \
|
2010-01-19 05:39:03 +03:00
|
|
|
"$imageLabel" "block_size 2048"
|
2008-03-28 00:11:04 +03:00
|
|
|
$makebootable $imageOffsetFlags "$imagePath"
|
2007-04-07 01:13:35 +04:00
|
|
|
fi
|
2008-03-28 00:11:04 +03:00
|
|
|
$bfsShell -n $imageOffsetFlags "$imagePath" > /dev/null &
|
2005-10-29 20:27:43 +04:00
|
|
|
sleep 1
|
2008-03-09 20:34:26 +03:00
|
|
|
# bail out, if mounting fails
|
2010-01-19 05:39:03 +03:00
|
|
|
$cd .
|
2005-10-29 20:27:43 +04:00
|
|
|
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.
|
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
|
|
|
|
mimeTmpDir=$tmpDir/mime
|
2008-04-15 19:46:00 +04:00
|
|
|
mimeDBTmpDir=$tmpDir/mime/db
|
2007-04-07 01:13:35 +04:00
|
|
|
mimeTmpIndex=0
|
2008-04-15 19:46:00 +04:00
|
|
|
mimeTmpFile=$mimeTmpDir/mimedb$$.rsrc
|
2007-04-07 01:13:35 +04:00
|
|
|
|
|
|
|
# create tmp dir for the MIME conversion stuff
|
2008-04-15 19:46:00 +04:00
|
|
|
mkdir -p $mimeDBTmpDir
|
2007-04-07 01:13:35 +04:00
|
|
|
|
|
|
|
echo "Installing MIME database ..."
|
|
|
|
|
|
|
|
for inSuperFile in $mimeDBSource/*.super; do
|
|
|
|
superType=$(basename $inSuperFile .super)
|
2008-04-15 19:46:00 +04:00
|
|
|
tmpSuperDir=$mimeDBTmpDir/$superType
|
2007-04-07 01:13:35 +04:00
|
|
|
|
|
|
|
# compile rdef to rsrc file and the rsrc file to attributes
|
2008-04-15 19:46:00 +04:00
|
|
|
$rc -o $mimeTmpFile $inSuperFile
|
|
|
|
mkdir -p $tmpSuperDir
|
|
|
|
$resattr -O -o $tmpSuperDir $mimeTmpFile
|
|
|
|
$rmAttrs $mimeTmpFile
|
2007-04-07 01:13:35 +04:00
|
|
|
|
|
|
|
# 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)
|
2008-04-15 19:46:00 +04:00
|
|
|
tmpSubFile=$mimeDBTmpDir/$superType/$subType
|
2007-04-07 01:13:35 +04:00
|
|
|
|
|
|
|
# compile rdef to rsrc file and the rsrc file to attributes
|
2008-04-15 19:46:00 +04:00
|
|
|
$rc -o $mimeTmpFile $inSubFile
|
|
|
|
$resattr -O -o $tmpSubFile $mimeTmpFile
|
|
|
|
$rmAttrs $mimeTmpFile
|
2007-04-07 01:13:35 +04:00
|
|
|
fi
|
|
|
|
done
|
2005-10-29 20:27:43 +04:00
|
|
|
done
|
|
|
|
|
2008-04-15 19:46:00 +04:00
|
|
|
$cp -r ${sPrefix}$mimeDBTmpDir/. $mimeDBDest
|
|
|
|
|
2007-04-07 01:13:35 +04:00
|
|
|
# cleanup tmp dir
|
* BuildPlatformMain supports overriding HOST_LIBROOT on the target now,
so one can set it to the static libroot, if desired.
* Generic attribute emulation:
- Added build tool rm_attrs, a simple "rm" replacement, which also
removes the attributes directory for a given file.
- Added build/scripts/rm_attrs shell script, which wraps the
invocation of the rm_attrs tool. If it doesn't exist yet, the
ordinary rm is used.
- The RM jam variable refers to the rm_attrs script now, i.e. whenever
something is removed by the build system, the attributes are removed
too (if the build tool has already been built, that is).
- Removed the shell function attrrmrf() in build_haiku_image. We use
the rm_attrs tool instead, if necessary.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24528 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-03-23 00:05:03 +03:00
|
|
|
$rmAttrs -rf $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
|
|
|
|
2008-04-19 19:55:54 +04:00
|
|
|
# add the concatenated copyrights as an attribute to AboutSystem
|
|
|
|
|
|
|
|
if [ ! $updateOnly ]; then
|
|
|
|
if [ -f $copyrightsFile ]; then
|
|
|
|
copyrightAttrs=$tmpDir/copyrightAttrs
|
|
|
|
$rmAttrs -f $copyrightAttrs
|
|
|
|
touch $copyrightAttrs
|
|
|
|
$addattr -f $copyrightsFile COPYRIGHTS $copyrightAttrs
|
2009-04-03 13:02:44 +04:00
|
|
|
$copyAttrs ${sPrefix}$copyrightAttrs ${tPrefix}system/apps/AboutSystem
|
2008-04-19 19:55:54 +04:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2010-04-11 03:14:42 +04:00
|
|
|
if [ $isCD ]; then
|
|
|
|
# generate the attribute stores
|
|
|
|
echo "Generating attribute stores ..."
|
|
|
|
$generate_attribute_stores "$tPrefix"
|
|
|
|
|
|
|
|
echo "Copying boot image ..."
|
|
|
|
$cp "$cdBootFloppy" "$outputDir"
|
|
|
|
|
|
|
|
# build the iso image
|
|
|
|
echo "Building CD image ..."
|
|
|
|
mkisofs -uid 0 -gid 0 -b `basename $cdBootFloppy` -R -V "$cdLabel" -o "$cdImagePath" "$tPrefix"
|
|
|
|
|
|
|
|
# cleanup output dir
|
|
|
|
$rmAttrs -rf "$outputDir"
|
|
|
|
fi
|
2008-04-19 19:55:54 +04:00
|
|
|
|
2005-10-29 20:27:43 +04:00
|
|
|
# unmount
|
|
|
|
if [ $isImage ]; then
|
|
|
|
echo "Unmounting ..."
|
|
|
|
$fsShellCommand sync
|
|
|
|
$fsShellCommand quit
|
|
|
|
fi
|