* Added new rule CopyDirectoryToHaikuImage which recursively copies a

directory to the image. It supports exclude patterns.
* Changed Add{Source,Header}DirectoryToHaikuImage to use the
  CopyDirectoryToHaikuImage rule. The special handling in the
  build_haiku_image script is gone now.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24586 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2008-03-26 04:14:25 +00:00
parent baba54f94f
commit 88c4c6627b
5 changed files with 76 additions and 92 deletions

View File

@ -711,10 +711,6 @@ AddTargetVariableToScript $(script) : <build>rc ;
AddTargetVariableToScript $(script) : <build>resattr ;
AddTargetVariableToScript $(script) : <build>unzip ;
AddTargetVariableToScript $(script) : <build>vmdkheader ;
AddVariableToScript $(script) : sourceDirsToCopy
: $(HAIKU_INSTALL_SOURCE_DIRS) ;
AddVariableToScript $(script) : headerDirsToCopy
: $(HAIKU_INSTALL_HEADER_DIRS) ;
if $(HOST_RM_ATTRS_TARGET) {
AddTargetVariableToScript $(script) : $(HOST_RM_ATTRS_TARGET) : rmAttrs ;
} else {

View File

@ -202,6 +202,35 @@ rule AddSymlinkToContainer container : directoryTokens : linkTarget : linkName
SYMLINKS_TO_INSTALL on $(directory) += $(link) ;
}
rule CopyDirectoryToContainer container : directoryTokens : sourceDirectory
: targetDirectoryName : excludePatterns : alwaysUpdate
{
# CopyDirectoryToContainer <container> : <directoryTokens>
# : <sourceDirectory> : <targetDirectoryName> : <excludePatterns>
# : <alwaysUpdate> ;
#
# If the image shall only be updated, we don't copy any directories
if [ on $(container) return $(HAIKU_CONTAINER_UPDATE_ONLY) ]
&& ! $(alwaysUpdate) {
return ;
}
if ! $(targetDirectoryName) {
local path = [ FReverse [ FSplitPath $(sourceDirectory) ] ] ;
targetDirectoryName = $(path[1]) ;
}
local directory = [ AddDirectoryToContainer $(container)
: $(directoryTokens) $(targetDirectoryName) ] ;
local targetDir = $(directory)/-/$(sourceDirectory) ;
EXCLUDE_PATTERNS on $(targetDir) = $(excludePatterns) ;
SOURCE_DIRECTORY on $(targetDir) = $(sourceDirectory) ;
TARGET_DIRECTORY on $(targetDir) = $(directory) ;
DIRECTORIES_TO_INSTALL on $(directory) += $(targetDir) ;
}
rule UnzipArchiveToContainer container : directoryTokens : zipFile
{
# UnzipArchiveToContainer <container> : <directory> : <zipFile> ] ;
@ -432,6 +461,17 @@ rule CreateContainerCopyFilesScript container : script
AddSymlinkToContainerCopyFilesScript $(symlink) : $(initScript) ;
}
local targetDirs = [ on $(dir) return $(DIRECTORIES_TO_INSTALL) ] ;
local targetDir ;
for targetDir in $(targetDirs) {
NotFile $(targetDir) ;
Depends $(script) : $(targetDir) ;
Depends $(targetDir) : $(initScript) ;
AddDirectoryToContainerCopyFilesScript $(targetDir) : $(initScript) ;
}
}
}
@ -451,6 +491,12 @@ actions AddSymlinkToContainerCopyFilesScript
echo \$ln -sfn "\"$(SYMLINK_TARGET)\"" "\"\${tPrefix}$(1:G=)\"" >> $(2[1])
}
actions AddDirectoryToContainerCopyFilesScript
{
echo \$cp -r $(EXCLUDE_PATTERNS) "\"\${sPrefix}$(SOURCE_DIRECTORY)/.\"" \
"\"\${tPrefix}$(TARGET_DIRECTORY:G=)\"" >> $(2[1])
}
rule CreateContainerUnzipFilesScript container : script
{
@ -535,26 +581,30 @@ rule AddSymlinkToHaikuImage directoryTokens : linkTarget : linkName
: $(linkTarget) : $(linkName) ;
}
rule CopyDirectoryToHaikuImage directoryTokens : sourceDirectory
: targetDirectoryName : excludePatterns : alwaysUpdate
{
CopyDirectoryToContainer $(HAIKU_IMAGE_CONTAINER_NAME) : $(directoryTokens)
: $(sourceDirectory) : $(targetDirectoryName) : $(excludePatterns)
: $(alwaysUpdate) ;
}
rule AddSourceDirectoryToHaikuImage dirTokens : alwaysUpdate
{
# AddSourceDirectoryToHaikuImage <dirTokens> : <alwaysUpdate> ;
# If the image shall only be updated, we update sources only, if explicitely
# requested.
if ! [ IsUpdateHaikuImageOnly ] || $(alwaysUpdate) {
HAIKU_INSTALL_SOURCE_DIRS += [ FDirName $(HAIKU_TOP) $(dirTokens) ] ;
}
CopyDirectoryToHaikuImage home HaikuSources
: [ FDirName $(HAIKU_TOP) $(dirTokens) ]
: : -x .svn : $(alwaysUpdate) ;
}
rule AddHeaderDirectoryToHaikuImage dirTokens : alwaysUpdate
{
# AddHeaderDirectoryToHaikuImage <dirTokens> : <alwaysUpdate> ;
# If the image shall only be updated, we update sources only, if explicitely
# requested.
if ! [ IsUpdateHaikuImageOnly ] || $(alwaysUpdate) {
HAIKU_INSTALL_HEADER_DIRS += [ FDirName $(HAIKU_TOP) headers $(dirTokens) ] ;
}
CopyDirectoryToHaikuImage develop headers
: [ FDirName $(HAIKU_TOP) headers $(dirTokens) ]
: : -x .svn : $(alwaysUpdate) ;
}
rule UnzipArchiveToHaikuImage dirTokens : zipFile : alwaysUpdate

View File

@ -100,6 +100,19 @@ AddSymlinkToHaikuImage home config bin : /beos/bin/crashing_app : crash ;
AddSourceDirectoryToHaikuImage src/kits/storage ;
AddSourceDirectoryToHaikuImage src/tests/servers/debug : 1 ;
# Copy the jam sources (assuming they are located ../buildtools/jam relatively
# to your Haiku sources) to the image as /boot/home/Desktop/jam-src, excluding
# any file or directory named ".svn" and any source path that matches the
# pattern "*/jam/./bin.*". Note that the "*" character needs to be escaped with
# two backslashes (one because it goes through a shell and one to quote the
# first one in jam), and that the build system always appends "/." to the source
# path (hence this pattern). Just as AddSourceDirectoryToHaikuImage this rule
# can also take another optional parameter indicating whether the directory shall
# also be copied in update mode.
CopyDirectoryToHaikuImage home Desktop
: $(HAIKU_TOP)/../buildtools/jam
: "jam-src" : -x .svn -X \\*/jam/./bin.\\* ;
# Unzips the given zip archive onto the image under /boot/develop/tools.
UnzipArchiveToHaikuImage develop tools
: /home/bonefish/develop/haiku/misc/gcc-2.95.3-beos-070218/gcc-2.95.3_binutils-2.17_rel-070218.zip ;

View File

@ -23,6 +23,9 @@
#AddFilesToHaikuImage home config settings : <keymap>US-International
# : Key_map ;
# Copy artwork to the image.
#CopyDirectoryToHaikuImage home Desktop : $(HAIKU_TOP)/data/artwork : : -x .svn ;
# Add the optional package WonderBrush to the image.
#AddOptionalHaikuImagePackages WonderBrush ;

View File

@ -9,8 +9,6 @@
# imagePath
# imageSize
# addBuildCompatibilityLibDir
# sourceDirsToCopy
# headerDirsToCopy
# updateOnly
# dontClearImage
# isVMwareImage
@ -183,82 +181,6 @@ if [ ! $updateOnly ]; then
fi # ! updateOnly
# install sources
sourcesDest=${tPrefix}home/HaikuSources
# create sources directory
if [ -n "${sourceDirsToCopy}" ]; then
echo "Installing Haiku Sources ..."
$mkdir -p ${sourcesDest}
fi
# When building in the root of the source directory, sourceDir is "." and
# the source directory are not prefixed, which breaks the sed expressions
# used below. We work around, by adjusting the strings to match and insert.
sourcePathPrefix=$sourceDir
destPathPrefix=$sourcesDest
if [ $sourcePathPrefix = "." ]; then
sourcePathPrefix=""
destPathPrefix="${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@^${sourcePathPrefix}@${destPathPrefix}@")
$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@^${sourcePathPrefix}@${destPathPrefix}@")
$cp ${sPrefix}$sourceFile $destSourceFile
done
done
# install headers
headersDest=${tPrefix}develop
# create headers directory
if [ -n "${headerDirsToCopy}" ]; then
echo "Installing Haiku Headers ..."
$mkdir -p ${headersDest}
fi
# See above (sourceDirs)
sourcePathPrefix=$sourceDir
destPathPrefix=$headersDest
if [ $sourcePathPrefix = "." ]; then
sourcePathPrefix=""
destPathPrefix="${headersDest}/"
fi
for headersDir in ${headerDirsToCopy}; do
echo " header dir: ${headersDir}"
# create all subdirectories
subDirs=$(find ${headersDir} -type d | grep -v '.svn' |
sed -e "s@^${sourcePathPrefix}@${destPathPrefix}@")
$mkdir -p ${subDirs}
# get all files and copy each one individually
headerFiles=$(find $headersDir -type f | grep -v '.svn')
for headerFile in $headerFiles; do
destHeaderFile=$(echo $headerFile |
sed -e "s@^${sourcePathPrefix}@${destPathPrefix}@")
$cp ${sPrefix}$headerFile $destHeaderFile
done
done
# unmount
if [ $isImage ]; then
echo "Unmounting ..."