All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robert Yang <liezhi.yang@windriver.com>
To: <bitbake-devel@lists.openembedded.org>
Subject: [PATCH 1/5] fetch2/git: Fix clean to remove clonedir
Date: Thu, 14 Mar 2019 17:28:17 +0800	[thread overview]
Message-ID: <bb7358f27955d4b020dd9a7dfce2d49e457a2faa.1552555629.git.liezhi.yang@windriver.com> (raw)
In-Reply-To: <cover.1552555629.git.liezhi.yang@windriver.com>

The localpath is a symlink to clonedir when it is cloned from a mirror, for
example:
$ bitbake systemtap-native -cfetch
$ ls downloads/git2
sourceware.org.git.systemtap.git -> /path/to/downloads/git2/mirror.path.git.sourceware.org.git.systemtap.git
mirror.path.git.sourceware.org.git.systemtap.git

There are both sourceware.org.git.systemtap.git and
mirror.path.git.sourceware.org.git.systemtap.git in DL_DIR/git2, the symlink
sourceware.org.git.systemtap.git is created by try_mirror_url(), but
do_cleanall" only removed the symlink, didn't remove the real dir
mirror.path.git.sourceware.org.git.systemtap.git, this may cause confusions,
for example, I assumed that do_cleanall removed everything, but it didn't, and
it would the re-used next time when do_fetch. This patch fixes the problem.

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
 bitbake/lib/bb/fetch2/git.py | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py
index 1a8ebe3..cf8bee7 100644
--- a/bitbake/lib/bb/fetch2/git.py
+++ b/bitbake/lib/bb/fetch2/git.py
@@ -522,9 +522,17 @@ class Git(FetchMethod):
     def clean(self, ud, d):
         """ clean the git directory """
 
-        bb.utils.remove(ud.localpath, True)
-        bb.utils.remove(ud.fullmirror)
-        bb.utils.remove(ud.fullmirror + ".done")
+        to_remove = [ud.localpath, ud.fullmirror, ud.fullmirror + ".done"]
+        # The localpath is a symlink to clonedir when it is cloned from a
+        # mirror, so remove both of them.
+        if os.path.islink(ud.localpath):
+            clonedir = os.path.realpath(ud.localpath)
+            to_remove.append(clonedir)
+
+        for r in to_remove:
+            if os.path.exists(r):
+                bb.note('Removing %s' % r)
+                bb.utils.remove(r, True)
 
     def supports_srcrev(self):
         return True
-- 
2.7.4



  reply	other threads:[~2019-03-14  9:09 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-14  9:28 [PATCH 0/5] fetch2: Fixes for git and gitsm Robert Yang
2019-03-14  9:28 ` Robert Yang [this message]
2019-03-14  9:28 ` [PATCH 2/5] fetch2: Add get_mirrorname() Robert Yang
2019-03-21 23:42   ` Richard Purdie
2019-03-22  3:51     ` Robert Yang
2019-03-14  9:28 ` [PATCH 3/5] fetch2: Print SCMs list when SRCREV_FORMAT is not set Robert Yang
2019-03-14  9:28 ` [PATCH 4/5] fetch2/gitsm: Add clean function Robert Yang
2019-03-14 12:34   ` Lisicki, Raphael
2019-03-15  2:50     ` Robert Yang
2019-03-15 15:44       ` Mark Hatle
2019-03-19  6:41         ` Robert Yang
2019-03-14 14:41   ` Mark Hatle
2019-03-15  2:52     ` Robert Yang
2019-03-15 15:46       ` Mark Hatle
2019-03-15  3:48     ` Robert Yang
2019-03-14  9:28 ` [PATCH 5/5] fetch2: Add gitsm's function process_submodules() Robert Yang
2019-03-14 14:46   ` Mark Hatle
2019-03-15  3:37     ` Robert Yang
2019-03-15 15:55       ` Mark Hatle
2019-03-19  3:47         ` Robert Yang

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=bb7358f27955d4b020dd9a7dfce2d49e457a2faa.1552555629.git.liezhi.yang@windriver.com \
    --to=liezhi.yang@windriver.com \
    --cc=bitbake-devel@lists.openembedded.org \
    /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.