Mercurial > hg > aboriginal
changeset 1183:61e7e9be8eb4
Add blank_workdir and make setupfor and cleanup use it. This means you can run an entire build.sh with NO_CLEANUP=1 on.
author | Rob Landley <rob@landley.net> |
---|---|
date | Fri, 30 Jul 2010 13:54:10 -0500 |
parents | c5ebf1e353c7 |
children | aa8992b35e15 |
files | sources/functions.sh sources/sections/binutils.build sources/sections/gcc.sh system-image.sh |
diffstat | 4 files changed, 41 insertions(+), 47 deletions(-) [+] |
line wrap: on
line diff
--- a/sources/functions.sh Tue Jul 27 02:35:33 2010 -0500 +++ b/sources/functions.sh Fri Jul 30 13:54:10 2010 -0500 @@ -108,8 +108,7 @@ { PREVIOUS= (cd "$STAGE_DIR" || dienow - # Note $WORK/$PACKAGE != $CURSRC here for renamed packages like gcc-core. - find . -depth -newer "$WORK/$PACKAGE/FWL-TIMESTAMP" \ + find . -depth -newer "$CURSRC/FWL-TIMESTAMP" \ | sed -e 's/^.//' -e 's/^.//' -e '/^$/d' ) | while read i do @@ -151,12 +150,12 @@ # Loop deleting directories cd "$WORK" || dienow - for i in "$PACKAGE" "$@" + for i in $WORKDIR_LIST do - [ -z "$i" ] && continue echo "cleanup $i" rm -rf "$i" || dienow - done + done + WORKDIR_LIST= } # Give filename.tar.ext minus the version number. @@ -390,8 +389,17 @@ done } -# Extract package $1, use out-of-tree build directory $2 (or $1 if no $2) -# Use link directory $3 (or $1 if no $3) +# Create a working directory under TMPDIR, deleting existing contents (if any), +# and tracking created directories so cleanup can delete them automatically. + +blank_workdir() +{ + WORKDIR_LIST="$1 $WORKDIR_LIST" + NO_CLEANUP= blank_tempdir "$WORK/$1" + cd "$WORK/$1" || dienow +} + +# Extract package $1 setupfor() { @@ -413,25 +421,19 @@ # If all we want to do is extract source, bail out now. [ ! -z "$EXTRACT_ONLY" ] && return 0 - # Set CURSRC - CURSRC="$PACKAGE" - if [ ! -z "$3" ] + # Delete old working copy (even in the NO_CLEANUP case) then make a new + # tree of links to the package cache. + + echo "Snapshot '$PACKAGE'..." + + if [ -z "$REUSE_CURSRC" ] then - CURSRC="$3" - is_in_list "$CURSRC" $USE_UNSTABLE && CURSRC=alt-"$CURSRC" + blank_workdir "$PACKAGE" + CURSRC="$(pwd)" fi - export CURSRC="${WORK}/${CURSRC}" [ -z "$SNAPSHOT_SYMLINK" ] && LINKTYPE="l" || LINKTYPE="s" - - echo "Snapshot '$PACKAGE'..." - cd "${WORK}" || dienow - if [ $# -lt 3 ] - then - rm -rf "${CURSRC}" || dienow - fi - mkdir -p "${CURSRC}" && - cp -${LINKTYPE}fR "${SRCTREE}/$PACKAGE/"* "${CURSRC}" + cp -${LINKTYPE}fR "$SRCTREE/$PACKAGE/"* "$CURSRC" if [ $? -ne 0 ] then @@ -439,14 +441,7 @@ dienow fi - # Do we have a separate working directory? - - if [ -z "$2" ] - then - cd "$PACKAGE"* || dienow - else - mkdir -p "$2" && cd "$2" || dienow - fi + cd "$CURSRC" || dienow export WRAPPY_LOGPATH="$BUILD/logs/cmdlines.${ARCH_NAME}.${STAGE_NAME}.$1" # Ugly bug workaround: timestamp granularity in a lot of filesystems is only @@ -455,7 +450,7 @@ if [ ! -z "$BINARY_PACKAGE_TARBALLS" ] then - touch "${CURSRC}/FWL-TIMESTAMP" || dienow + touch "$CURSRC/FWL-TIMESTAMP" || dienow TIME=$(date +%s) while true do
--- a/sources/sections/binutils.build Tue Jul 27 02:35:33 2010 -0500 +++ b/sources/sections/binutils.build Fri Jul 30 13:54:10 2010 -0500 @@ -9,8 +9,7 @@ [ $? -ne 0 ] && dienow } -mkdir ../build-binutils && -cd ../build-binutils || dienow +blank_workdir build-binutils if [ -z "$HOST_ARCH" ] then @@ -41,6 +40,10 @@ # Fix up install mkdir -p "$STAGE_DIR/include" && -cp "$CURSRC/include/libiberty.h" "$STAGE_DIR/include" && -cd .. && -rm -rf build-binutils +cp "$CURSRC/include/libiberty.h" "$STAGE_DIR/include" || dienow + + +if [ -z "$NO_CLEANUP" ] +then + cd .. && rm -rf build-binutils || dienow +fi
--- a/sources/sections/gcc.sh Tue Jul 27 02:35:33 2010 -0500 +++ b/sources/sections/gcc.sh Fri Jul 30 13:54:10 2010 -0500 @@ -4,8 +4,10 @@ # Force gcc to build, largely against its will. -setupfor gcc-core build-gcc -[ -z "$NO_CPLUSPLUS" ] && setupfor gcc-g++ build-gcc gcc-core +setupfor gcc-core +[ -z "$NO_CPLUSPLUS" ] && REUSE_CURSRC=1 setupfor gcc-g++ + +blank_workdir build-gcc # GCC tries to "help out in the kitchen" by screwing up the kernel include # files. Surgery with sed to cut out that horrible idea throw it away. @@ -140,9 +142,6 @@ rm -rf "${STAGE_DIR}"/{lib/gcc,libexec/gcc/install-tools,bin/${ARCH}-unknown-*} -# Little dance so binary package tarball would be called "gcc", not "gcc-core". -if [ -z "$NO_CLEANUP" ] -then - mv "$WORK"/{*gcc-core,gcc} -fi -PACKAGE=gcc cleanup build-gcc +# Call binary package tarball "gcc", not "gcc-core". + +PACKAGE=gcc cleanup
--- a/system-image.sh Tue Jul 27 02:35:33 2010 -0500 +++ b/system-image.sh Fri Jul 30 13:54:10 2010 -0500 @@ -31,9 +31,6 @@ echo "=== Packaging system image from root-filesystem" -mkdir -p "$STAGE_DIR" -blank_tempdir "$WORK" - # The initramfs packaging uses the kernels build infrastructure, so extract # it now.