summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2021-11-02 11:34:21 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-11-03 10:12:42 +0000
commite177e033202b7845c1113601979331eb6b73c1a0 (patch)
treea7280c0f73632192c6d8f73066540cb8e1cc5db7
parentf57b77ff329d6b51f89a8be3645bcee4bbcfe1d6 (diff)
downloadpoky-e177e033202b7845c1113601979331eb6b73c1a0.tar.gz
scripts/convert-srcuri: Update SRC_URI conversion script to handle github url changes
Github are dropping support for git:// protocol fetching. Update the script to learn about corner cases found in the previous conversion and support remapping the github urls as needed too. (From OE-Core rev: e59fe8279b209f67ff79b9d6dbb69389a64db236) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-xscripts/contrib/convert-srcuri.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/scripts/contrib/convert-srcuri.py b/scripts/contrib/convert-srcuri.py
index 4bf9e3013d..5b362ea2e8 100755
--- a/scripts/contrib/convert-srcuri.py
+++ b/scripts/contrib/convert-srcuri.py
@@ -19,19 +19,33 @@ if len(sys.argv) < 2:
19 sys.exit(1) 19 sys.exit(1)
20 20
21def processfile(fn): 21def processfile(fn):
22 def matchline(line):
23 if "MIRROR" in line or ".*" in line or "GNOME_GIT" in line:
24 return False
25 return True
22 print("processing file '%s'" % fn) 26 print("processing file '%s'" % fn)
23 try: 27 try:
28 if "distro_alias.inc" in fn or "linux-yocto-custom.bb" in fn:
29 return
24 fh, abs_path = tempfile.mkstemp() 30 fh, abs_path = tempfile.mkstemp()
25 modified = False 31 modified = False
26 with os.fdopen(fh, 'w') as new_file: 32 with os.fdopen(fh, 'w') as new_file:
27 with open(fn, "r") as old_file: 33 with open(fn, "r") as old_file:
28 for line in old_file: 34 for line in old_file:
29 if ("git://" in line or "gitsm://" in line) and "branch=" not in line and "MIRROR" not in line and ".*" not in line: 35 if ("git://" in line or "gitsm://" in line) and "branch=" not in line and matchline(line):
30 if line.endswith('"\n'): 36 if line.endswith('"\n'):
31 line = line.replace('"\n', ';branch=master"\n') 37 line = line.replace('"\n', ';branch=master"\n')
32 elif line.endswith(" \\\n"): 38 elif line.endswith(" \\\n"):
33 line = line.replace(' \\\n', ';branch=master \\\n') 39 line = line.replace(' \\\n', ';branch=master \\\n')
34 modified = True 40 modified = True
41 if ("git://" in line or "gitsm://" in line) and "github.com" in line and "protocol=https" not in line and matchline(line):
42 if "protocol=git" in line:
43 line = line.replace('protocol=git', 'protocol=https')
44 elif line.endswith('"\n'):
45 line = line.replace('"\n', ';protocol=https"\n')
46 elif line.endswith(" \\\n"):
47 line = line.replace(' \\\n', ';protocol=https \\\n')
48 modified = True
35 new_file.write(line) 49 new_file.write(line)
36 if modified: 50 if modified:
37 shutil.copymode(fn, abs_path) 51 shutil.copymode(fn, abs_path)