summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorRoss Burton <ross.burton@arm.com>2024-09-10 17:58:04 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2024-09-12 16:17:20 +0100
commitd016d18a9f14871c444a13305f4040f28000a21f (patch)
treede0ed7e2f3569c02a2a97cfa09a6e83853d6a090 /bitbake
parent4d1697fb87fa6395e05201f21279fe5b996be741 (diff)
downloadpoky-d016d18a9f14871c444a13305f4040f28000a21f.tar.gz
bitbake: fetch2/gitsm: use configparser to parse .gitmodules
.gitmodules is basically ini-style, so use configparser instead of manually parsing by hand. (Bitbake rev: a4f42e396e2942fde94b8b4944487c1c45f7a295) Signed-off-by: Ross Burton <ross.burton@arm.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/fetch2/gitsm.py24
1 files changed, 13 insertions, 11 deletions
diff --git a/bitbake/lib/bb/fetch2/gitsm.py b/bitbake/lib/bb/fetch2/gitsm.py
index f7f3af7212..f193ae3c9b 100644
--- a/bitbake/lib/bb/fetch2/gitsm.py
+++ b/bitbake/lib/bb/fetch2/gitsm.py
@@ -47,18 +47,20 @@ class GitSM(Git):
47 subrevision = {} 47 subrevision = {}
48 48
49 def parse_gitmodules(gitmodules): 49 def parse_gitmodules(gitmodules):
50 """
51 Parse .gitmodules and return a dictionary of submodule paths to dictionaries with path and url members.
52 """
53 import configparser
54 cp = configparser.ConfigParser()
55 cp.read_string(gitmodules)
56
50 modules = {} 57 modules = {}
51 module = "" 58 for section in [s for s in cp.sections() if s.startswith("submodule ")]:
52 for line in gitmodules.splitlines(): 59 module = section.split('"')[1]
53 if line.startswith('[submodule'): 60 modules[module] = {
54 module = line.split('"')[1] 61 'path': cp.get(section, 'path'),
55 modules[module] = {} 62 'url': cp.get(section, 'url')
56 elif module and line.strip().startswith('path'): 63 }
57 path = line.split('=')[1].strip()
58 modules[module]['path'] = path
59 elif module and line.strip().startswith('url'):
60 url = line.split('=')[1].strip()
61 modules[module]['url'] = url
62 return modules 64 return modules
63 65
64 # Collect the defined submodules, and their attributes 66 # Collect the defined submodules, and their attributes