[darwinbuild-changes] [221] trunk/darwinbuild/darwinbuild.common
source_changes at macosforge.org
source_changes at macosforge.org
Wed Oct 4 01:58:48 PDT 2006
Revision: 221
http://trac.macosforge.org/projects/darwinbuild/changeset/221
Author: ssen
Date: 2006-10-04 01:58:48 -0700 (Wed, 04 Oct 2006)
Log Message:
-----------
Implement InstallHeader fully using new receipt management
code and registration. At all steps, if a header
root is not available, use a full root.
Add IsDirectoryEmpty() helper to check for empty
DSTROOTs
Modified Paths:
--------------
trunk/darwinbuild/darwinbuild.common
Modified: trunk/darwinbuild/darwinbuild.common
===================================================================
--- trunk/darwinbuild/darwinbuild.common 2005-09-05 06:11:32 UTC (rev 220)
+++ trunk/darwinbuild/darwinbuild.common 2006-10-04 08:58:48 UTC (rev 221)
@@ -231,52 +231,144 @@
}
###
-### Installs a headers root into the BuildRoot. Checks for a
-### receipt file to avoid duplicate installs. Falls back on
-### InstallRoot if no headers root is available.
-### Relies on the DARWIN_BUILDROOT environment variable.
+### Installs a header root into the BuildRoot. Mediates between
+### receipts, pre-built roots, and self-built roots, so that
+### the build root is "up to date"
+### Relies on the DARWIN_BUILDROOT and CACHEDIR and DARWINXREF
+### and dbfile globals.
###
-function InstallHeaders() {
+function InstallHeader() {
local BuildRoot="$1"
- local X="$2"
+ local Project="$2"
local dbuild="$3"
- local receipts="$BuildRoot/usr/local/darwinbuild/receipts"
- if [ ! -e "$receipts/$X.hdrs" -a ! -e "$receipts/$X" ]; then
- bv=$(GetBuildVersion $DARWIN_BUILDROOT/Headers/${X/-*}/$X.hdrs*)
- if [ -d $DARWIN_BUILDROOT/Headers/${X/-*}/$X.hdrs~$bv ]; then
- echo "Copying $X ..."
- ditto $DARWIN_BUILDROOT/Headers/${X/-*}/$X.hdrs~$bv $BuildRoot
- "$DARWINXREF" register "$X" $DARWIN_BUILDROOT/Headers/${X/-*}/$X.hdrs~$bv > /dev/null
+ local SelfBuiltRoot=""
+ local SelfBuiltHeader=""
+ local InstallSelfBuiltRoot=0
+ local InstallSelfBuiltHeader=0
+ local InstallPreBuiltRoot=0
+
+ ###
+ ### There will be duplication between the bash dependencies and the
+ ### project's dependencies. Therefore don't install something that
+ ### has already been installed. (Test for the presence of a receipt).
+ ###
+ if [ -d "$DARWIN_BUILDROOT/Roots/$Project" ]; then
+ ProjectAndVersion=$($DARWINXREF $dbfile version "$Project")
+ bv=$(GetBuildVersion $DARWIN_BUILDROOT/Roots/$Project/$ProjectAndVersion.root*)
+ if [ -n "$bv" ]; then
+ SelfBuiltRoot="$DARWIN_BUILDROOT/Roots/$Project/$ProjectAndVersion.root~$bv"
+ fi
+ fi
+
+ if [ -d "$DARWIN_BUILDROOT/Headers/$Project" ]; then
+ ProjectAndVersion=$($DARWINXREF $dbfile version "$Project")
+ bv=$(GetBuildVersion $DARWIN_BUILDROOT/Headers/$Project/$ProjectAndVersion.hdrs*)
+ if [ -n "$bv" ]; then
+ SelfBuiltHeader="$DARWIN_BUILDROOT/Headers/$Project/$ProjectAndVersion.hdrs~$bv"
+ fi
+ fi
+
+ CheckForReceipt "$BuildRoot" "$Project" "hdrs"
+ if [ $? -eq 0 ]; then
+ # receipt is present. But do we have a newer local build?
+ CheckIfNewerThanReceipt "$BuildRoot" "$Project" "hdrs" "$SelfBuiltHeader"
+ if [ $? -eq 0 ]; then
+ # we're newer Headers. Load us
+ InstallSelfBuiltHeader=1
+ else
+ CheckIfNewerThanReceipt "$BuildRoot" "$Project" "hdrs" "$SelfBuiltRoot"
+ if [ $? -eq 0 ]; then
+ # we're newer Root. Load us
+ InstallSelfBuiltRoot=1
+ fi
+
+ fi
else
-
- # install a pre-built root
- sites=$($DARWINXREF $dbfile -b $dbuild binary_sites "$X")
- Download "$CACHEDIR/Headers/$dbuild" \
- "$X.hdrs.tar.gz" \
- "$sites"
- if [ -f $CACHEDIR/Headers/$dbuild/$X.hdrs.tar.gz ]; then
- cd "$BuildRoot"
- tar xzf $CACHEDIR/Headers/$dbuild/$X.hdrs.tar.gz
- if [ "$?" == "0" ]; then
- tar tzf $CACHEDIR/Headers/$dbuild/$X.hdrs.tar.gz | \
- "$DARWINXREF" register -stdin "$X" "$BuildRoot" \
- > /dev/null
- SHA1=$(openssl dgst -sha1 < $CACHEDIR/Headers/$dbuild/$X.hdrs.tar.gz)
- touch "$receipts/$SHA1"
- ln -sf "$SHA1" "$receipts/$X"
- break
- fi
+ # there wasn't a Headers receipt. look for Roots
+ CheckForReceipt "$BuildRoot" "$Project" "root"
+ if [ $? -eq 0 ]; then
+ CheckIfNewerThanReceipt "$BuildRoot" "$Project" "root" "$SelfBuiltRoot"
+ if [ $? -eq 0 ]; then
+ # we're newer Root. Load us
+ InstallSelfBuiltRoot=1
+ fi
+ else
+ # there wasn't any receipt. but if we have a self-built root, we should use it
+ if [ -n "$SelfBuiltHeader" ]; then
+ InstallSelfBuiltHeader=1
else
- InstallRoot "$BuildRoot" "$X" "$dbuild"
+ if [ -n "$SelfBuiltRoot" ]; then
+ InstallSelfBuiltRoot=1
+ else
+ InstallPreBuiltRoot=1
+ fi
fi
+ fi
+ fi
- # XXX some may think this is buggy. If you fail to find
- # a header root for the first build, normal roots
- # are searched for along the build chain. Secondary
- # builds are never consulted for header roots
+ # install a self-built root, or a prebuilt root, or nothing
+ if [ $InstallSelfBuiltHeader -eq 1 ]; then
+ echo "Copying $Project from $SelfBuiltHeader ..."
+ ditto "$SelfBuiltHeader" "$BuildRoot"
+ "$DARWINXREF" register "$Project" "$SelfBuiltHeader" > /dev/null
+ TouchReceipt "$BuildRoot" "$Project" "hdrs"
+ return 0
+ elif [ $InstallSelfBuiltRoot -eq 1 ]; then
+ echo "Copying $Project from $SelfBuiltRoot ..."
+ ditto "$SelfBuiltRoot" "$BuildRoot"
+ "$DARWINXREF" register "$Project" "$SelfBuiltRoot" > /dev/null
+ TouchReceipt "$BuildRoot" "$Project" "root"
+ return 0
+ elif [ $InstallPreBuiltRoot -eq 1 ]; then
+ # install a pre-built root, in inheritance order
+ while [ "$dbuild" != "" ]; do
+ sites=$($DARWINXREF $dbfile -b $dbuild binary_sites "$X")
+ Download "$CACHEDIR/Roots/$dbuild" \
+ "$Project.hdrs.tar.gz" \
+ "$sites"
+ if [ -f $CACHEDIR/Roots/$dbuild/$Project.hdrs.tar.gz ]; then
+ cd "$BuildRoot"
+ tar xzf $CACHEDIR/Roots/$dbuild/$Project.hdrs.tar.gz
+ if [ $? -eq 0 ]; then
+ tar tzf $CACHEDIR/Roots/$dbuild/$Project.hdrs.tar.gz | \
+ "$DARWINXREF" register -stdin "$Project" "$BuildRoot" \
+ > /dev/null
+ echo | CreateReceipt "$BuildRoot" "$Project" "hdrs" \
+ "$CACHEDIR/Roots/$dbuild/$Project.hdrs.tar.gz"
+ return 0
+ fi
+ else
+ # if we couldnt' download a header root for a given build,
+ # try the full root
+ Download "$CACHEDIR/Roots/$dbuild" \
+ "$Project.root.tar.gz" \
+ "$sites"
+ if [ -f $CACHEDIR/Roots/$dbuild/$Project.root.tar.gz ]; then
+ cd "$BuildRoot"
+ tar xzf $CACHEDIR/Roots/$dbuild/$Project.root.tar.gz
+ if [ $? -eq 0 ]; then
+ tar tzf $CACHEDIR/Roots/$dbuild/$Project.root.tar.gz | \
+ "$DARWINXREF" register -stdin "$Project" "$BuildRoot" \
+ > /dev/null
+ echo | CreateReceipt "$BuildRoot" "$Project" "root" \
+ "$CACHEDIR/Roots/$dbuild/$Project.root.tar.gz"
+ return 0
+ fi
+ else
+ dbuild=$($DARWINXREF $dbfile -b $dbuild inherits)
+ fi
+ fi
+
+ # if we didn't find the root for this build, keep looking in the next build
+ done
+ # we look through all inherited builds and couldn't actually install anything
+ echo "ERROR: could not find root: $X" 1>&2
+ exit 1
fi
- fi
+
+ # we had a receipt, so nothing was request
+ return 0
}
RECEIPTDIR=/usr/local/darwinbuild/receipts
@@ -391,3 +483,17 @@
return 0
}
+# If a directory is empty, return 0 (success)
+function IsDirectoryEmpty() {
+ local Directory="$1"
+
+ local output=$(find "$Directory" -maxdepth 0 \! -empty )
+
+ if [ -n "$output" ]; then
+ # not empty
+ return 1
+ else
+ return 0
+ fi
+}
+
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/darwinbuild-changes/attachments/20061004/f78cce64/attachment-0001.html
More information about the darwinbuild-changes
mailing list