Stefan Fiedler: simplify tmpfs handling in scripts/Build-Pkg also remove ROCK/src.$xpkg.$id symlink from inside debug.sh --- scripts/Build-Pkg-orig 2006-09-26 09:16:35.000000000 +0200 +++ scripts/Build-Pkg 2006-09-26 09:16:58.000000000 +0200 @@ -189,14 +189,6 @@ mkdir -p "$builddir"; chmod 700 "$builddir" -# This must happen _before_ the FLWRAPPER starts or we get into trouble -# also before $chroot does anything -if [ "$ROCKCFG_SRC_TMPFS" = 1 ]; then - if ! grep -q "src.$xpkg.$id" /proc/mounts ; then - mount -t tmpfs -o $ROCKCFG_SRC_TMPFS_OPT tmpfs "$builddir" - fi -fi - if [ "$chroot" = 1 ] ; then cd "$xroot" || exit 1 @@ -288,9 +280,6 @@ mount --bind $realbase $PWD/ROCK/loop mount --bind $realconf $PWD/ROCK/config mount --bind $realdown $PWD/ROCK/download - if [ "$ROCKCFG_SRC_TMPFS" = 1 ]; then - mount --bind $builddir $PWD/ROCK/loop/src.$xpkg.$id - fi fi if [ ! -f proc/mounts ]; then @@ -324,13 +313,10 @@ mount --bind $realbase $PWD/ROCK/loop mount --bind $realconf $PWD/ROCK/config mount --bind $realdown $PWD/ROCK/download - if [ "$ROCKCFG_SRC_TMPFS" = 1 ]; then - mount --bind $builddir $PWD/ROCK/loop/src.$xpkg.$id - else - ln -s loop/src.$xpkg.$id $PWD/ROCK/src.$xpkg.$id - fi + ln -s loop/src.$xpkg.$id $PWD/ROCK/src.$xpkg.$id fi chroot "$xroot" /bin/bash ROCK/src.$xpkg.$id/debug_x.sh + rm -f $PWD/ROCK/src.$xpkg.$id EOT chmod +x "$builddir/debug.sh" @@ -351,16 +337,11 @@ TZ="/ROCK/localtime" chroot . bin/bash ROCK/src.$xpkg.$id/chroot.sh returncode=$? - if [ "$ROCKCFG_SRC_TMPFS" = 1 ]; then - umount $PWD/ROCK/loop/src.$xpkg.$id - umount $realbase/src.$xpkg.$id - fi umount $PWD/ROCK/loop umount $PWD/ROCK/config umount $PWD/ROCK/download umount $PWD/proc # Only remove $builddir if it is empty. - rm ROCK/src.$xpkg.$id rmdir --ignore-fail-on-non-empty "$realbase/src.$xpkg.$id" exit $returncode @@ -702,6 +683,11 @@ echo_status "Preparing build in src.$xpkg.$id" +if [ "$ROCKCFG_SRC_TMPFS" = 1 ]; then + echo_status "Mounting tmpfs on src.$xpkg.$id" + mount -t tmpfs -o $ROCKCFG_SRC_TMPFS_OPT tmpfs "$builddir" +fi + if [ "$xroot" != "$root" ] ; then for x in $flistroot ; do [ -d $xroot/$x ] || mkdir -p $xroot/$x @@ -1268,16 +1254,14 @@ export LD_PRELOAD="${LD_PRELOAD//${FLWRAPPER}/}" export LD_PRELOAD="${LD_PRELOAD//::/:}" fi + +if [ "$ROCKCFG_SRC_TMPFS" = 1 ]; then + umount -l "$builddir" +fi + if [ -f $root/var/adm/logs/$stagelevel-$xpkg.log ] ; then if [ $clear_src = 1 ] ; then - rm -rf "$builddir"/* - if [ $stagelevel -lt 2 ] ; then -# in stages 2-9 the outer Build-Pkg has a fd open in $builddir - if [ "$ROCKCFG_SRC_TMPFS" = 1 ]; then - umount "$builddir" - fi - rmdir "$builddir" - fi + rm -rf "$builddir"/* "$builddir" else cp $root/var/adm/logs/$stagelevel-$xpkg.out "$builddir/BUILD-LOG" fi @@ -1289,14 +1273,7 @@ exit 0 else if [ $clear_src = 1 -a "$ROCKCFG_ALWAYS_CLEAN" = 1 ] ; then - rm -rf "$builddir"/* - if [ $stagelevel -lt 2 ] ; then -# in stages 2-9 the outer Build-Pkg has a fd open in $builddir - if [ "$ROCKCFG_SRC_TMPFS" = 1 ]; then - umount "$builddir" - fi - rmdir "$builddir" - fi + rm -rf "$builddir"/* "$builddir" else cp $root/var/adm/logs/$stagelevel-$xpkg.out "$builddir/ERROR-LOG" fi