[bitbake-devel] [PATCH 4/5] fetch2/gitsm: Add clean function

Mark Hatle mark.hatle at windriver.com
Fri Mar 15 15:46:00 UTC 2019


On 3/14/19 9:52 PM, Robert Yang wrote:
> Hi Mark,
> 
> On 3/14/19 10:41 PM, Mark Hatle wrote:
>> On 3/14/19 4:28 AM, Robert Yang wrote:
>>> The git's clean can only remove parent git repo from DL_DIR, but doesn't remove
>>> submodules, this patch fixes the problem.
>>>
>>> Signed-off-by: Robert Yang <liezhi.yang at windriver.com>
>>> ---
>>>   bitbake/lib/bb/fetch2/gitsm.py | 15 +++++++++++++--
>>>   1 file changed, 13 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/bitbake/lib/bb/fetch2/gitsm.py b/bitbake/lib/bb/fetch2/gitsm.py
>>> index b21fed2..bb61093 100644
>>> --- a/bitbake/lib/bb/fetch2/gitsm.py
>>> +++ b/bitbake/lib/bb/fetch2/gitsm.py
>>> @@ -76,8 +76,8 @@ class GitSM(Git):
>>>           for name in ud.names:
>>>               try:
>>>                   gitmodules = runfetchcmd("%s show %s:.gitmodules" % (ud.basecmd, ud.revisions[name]), d, quiet=True, workdir=workdir)
>>> -            except:
>>> -                # No submodules to update
>>> +            except Exception as esc:
>>> +                logger.info("No submodules found: %s" % workdir)
>>
>> We don't want the log message.  git submodules are processed recursively, and
>> the end of the recursion will -always- have 'gitsm' items that have no
>> submodules.  This is also why it was a generic except, because we really don't
>> care WHAT the exception is, only that if one happens -- we know the command
>> failed and to simply ignore it and finish the iteration.
>>
>>                    continue
>>>   
>>>               for m, md in parse_gitmodules(gitmodules).items():
>>> @@ -164,6 +164,17 @@ class GitSM(Git):
>>>           Git.download(self, ud, d)
>>>           self.process_submodules(ud, ud.clonedir, download_submodule, d)
>>>   
>>> +    def clean(self, ud, d):
>>> +        def clean_submodule(ud, url, module, modpath, d):
>>> +            try:
>>> +                newfetch = Fetch([url], d, cache=False)
>>> +                newfetch.clean()
>>> +            except Exception as e:
>>> +                logger.warn('gitsm: submodule clean failed: %s %s' % (type(e).__name__, str(e)))
>>> +
>>> +        self.process_submodules(ud, ud.clonedir, clean_submodule, d)
>>> +        Git.clean(self, ud, d)
>>> +
>>
>> I don't see 'clean_submodule' implemented in this patch.  The process_submodules
>> will simply call that function, if it's not defined it will error or not do
>> anything if it finds a submodule.
> 
> 
> The clean_submodule is inside of 'def clean', right under 'def clean':
> 
> +    def clean(self, ud, d):
> +        def clean_submodule(ud, url, module, modpath, d):

Apparently I'm blind.  :)

--Mark

> // Robert
> 
>>
>>>       def unpack(self, ud, destdir, d):
>>>           def unpack_submodules(ud, url, module, modpath, d):
>>>               url += ";bareclone=1;nobranch=1"
>>>
>>
>>



More information about the bitbake-devel mailing list