All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nishanth Menon <nm@ti.com>
To: <denis@denix.org>, <praneeth@ti.com>, <yogeshs@ti.com>
Cc: meta-arago@arago-project.org
Subject: [tisdk-build-scripts PATCH 3/5] config-build-env: Refactor to cleanup messed up build folder
Date: Fri, 9 Jul 2021 13:03:59 -0500	[thread overview]
Message-ID: <20210709180401.2977-4-nm@ti.com> (raw)
In-Reply-To: <20210709180401.2977-1-nm@ti.com>

In some weird, yet unknown cases, the build folder might be messed up.
Lets make sure we clean that up first prior to cloning or updating
the folder. This seems to happen when we force via jenkins to abort a
running job, leaving the system in a weird state on the remote build
machine. It is not clear what specifically is going on in the sequence,
but lets add some diagnostics on if any errant processes are sticking
around in the previous process (VM cleanup etc) that prevented a
proper system cleanup.

Signed-off-by: Nishanth Menon <nm@ti.com>
---
 lib/oesdk/config-build-env | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/lib/oesdk/config-build-env b/lib/oesdk/config-build-env
index 058823562693..885fbcfb50d9 100644
--- a/lib/oesdk/config-build-env
+++ b/lib/oesdk/config-build-env
@@ -15,7 +15,7 @@ fi
 # conditions apply:
 #   1. The checkout creates the final directory of BUILD_ROOT
 #   2. If a git repo already exists then do a git pull
-#   3. If the directory is not empty and is not a git repo then bail
+#   3. If the directory is not empty and is not a git repo, then cleanup if unused
 checkout_layer_scripts() {
     cd `dirname $BUILD_ROOT`
 
@@ -28,18 +28,27 @@ checkout_layer_scripts() {
         exit 1
     fi
 
-    if [ ! -d $name ]
-    then
+    # If the scripts folder exists and is not a git repo, cleanup.
+    if [ -e $name -a ! -d $name/.git ]; then
+        echo "The $BUILD_ROOT directory is present and is not a git repo - attempting to wipe it off"
+        users=`lsof "$BUILD_ROOT"|wc -l`
+        if [ $users -gt 0 ]; then
+           echo "ERROR:: We have users for $BUILD_ROOT folder: Aborting!!!"
+           lsof $BUILD_ROOT
+           pstree -aplG
+           exit 1
+        fi
+        rm -rvf "$BUILD_ROOT" || exit 1
+    fi
+
+
+    if [ ! -d $name ]; then
         git clone "$TI_SDK_OELAYER_SETUP" $name
-    elif [ -d $name/.git ]
-    then
-        #This looks to be a git repo.  Hopefully it is the right one :)
+    else
+        # This looks to be a git repo.  Hopefully it is the right one :)
         cd $BUILD_ROOT
         git fetch
         git reset --hard origin
-    else
-        echo "The $BUILD_ROOT directory is not empty and is not a git repo"
-        exit 1
     fi
 }
 
-- 
2.32.0



  parent reply	other threads:[~2021-07-09 18:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-09 18:03 [tisdk-build-scripts PATCH 0/5] config-build-env: Switch to arago-project git Nishanth Menon
2021-07-09 18:03 ` [tisdk-build-scripts PATCH 1/5] config-build-env: Move the oe-layer-setup to a variable Nishanth Menon
2021-07-09 18:03 ` [tisdk-build-scripts PATCH 2/5] config-build-env: Lets make sure we are really in a build folder Nishanth Menon
2021-07-09 18:03 ` Nishanth Menon [this message]
2021-07-09 18:04 ` [tisdk-build-scripts PATCH 4/5] config-build-env: Make sure that the git url points correctly Nishanth Menon
2021-07-10 13:15   ` Nishanth Menon
2021-07-09 18:04 ` [tisdk-build-scripts PATCH 5/5] config-build-env: Switch arago-project git repo to ti git repo Nishanth Menon
2021-07-13  3:32   ` Denys Dmytriyenko
2021-07-13 13:30     ` Nishanth Menon
2021-07-13  3:34 ` [tisdk-build-scripts PATCH 0/5] config-build-env: Switch to arago-project git Denys Dmytriyenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210709180401.2977-4-nm@ti.com \
    --to=nm@ti.com \
    --cc=denis@denix.org \
    --cc=meta-arago@arago-project.org \
    --cc=praneeth@ti.com \
    --cc=yogeshs@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.