[V2] wipe-sysroots: don't assume TMPDIR is under BUILDDIR

Submitted by Ross Burton on Aug. 14, 2013, 2:13 p.m. | Patch ID: 55611


Message ID 1376489624-30715-1-git-send-email-ross.burton@intel.com
State Accepted
Commit 29491a72acac81ebb7e9ecfbc9392fbeb9a7ea26
Headers show

Commit Message

Ross Burton Aug. 14, 2013, 2:13 p.m.
The previous code used the environment variable BUILDDIR and assumed that TMPDIR
was a subdirectory. This often isn't the case, so instead ask bitbake where the
directories we're about to delete are.

Signed-off-by: Ross Burton <ross.burton@intel.com>
 scripts/wipe-sysroot |   24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

Patch hide | download patch | download mbox

diff --git a/scripts/wipe-sysroot b/scripts/wipe-sysroot
index e751a91..2d2cbea 100755
--- a/scripts/wipe-sysroot
+++ b/scripts/wipe-sysroot
@@ -18,17 +18,27 @@ 
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-if [ -z "$BUILDDIR" ]; then
-    echo >&2 "Error: BUILDDIR is not defined, please initialise the build system."
-    return 1
+set -e
+ENVS=`mktemp --suffix -wipe-sysroot-envs`
+bitbake -p -e > $ENVS
+eval `grep -F STAGING_DIR= $ENVS`
+eval `grep -F STAMPS_DIR= $ENVS`
+rm -f $ENVS
+if [ -z "$SSTATE_MANIFESTS" -o -z "$STAGING_DIR" -o -z "$STAMPS_DIR" ]; then
+    echo "Could not determine SSTATE_MANIFESTS/STAGING_DIR/STAMPS_DIR, check above for errors"
+    exit 1
 # The sysroots themselves
-rm -rf $BUILDDIR/tmp/sysroots/
+rm -rf "$STAGING_DIR"
 # The stamps that said the sysroot was populated
-rm -rf $BUILDDIR/tmp/stamps/*/*/*.do_populate_sysroot.*
-rm -rf $BUILDDIR/tmp/stamps/*/*/*.do_populate_sysroot_setscene.*
+rm -rf "$STAMPS_DIR/*/*/*.do_populate_sysroot.*"
+rm -rf "$STAMPS_DIR/*/*/*.do_populate_sysroot_setscene.*"
 # The sstate manifests
-rm -rf $BUILDDIR/tmp/sstate-control/manifest-*.populate-sysroot
+rm -rf "$SSTATE_MANIFESTS/manifest-*.populate-sysroot"