From 59859bac971f1d95672cefc7e8b7c804c9f55757 Mon Sep 17 00:00:00 2001 From: Anmol Agrawal Date: Thu, 28 Apr 2022 15:18:42 +0530 Subject: [PATCH 01/14] Added code to fetch repos from e gitlab Also moved some code to a new function so that it can be run if repos are not found on e (cherry picked from commit db5dd449dba18fe6bcb89d956a9cc800b300e6ad) --- build/tools/roomservice.py | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/build/tools/roomservice.py b/build/tools/roomservice.py index 95958cc67..fa604540a 100755 --- a/build/tools/roomservice.py +++ b/build/tools/roomservice.py @@ -40,6 +40,7 @@ except ImportError: from xml.etree import ElementTree product = sys.argv[1] +gitlabApiUrl = "https://gitlab.e.foundation/api/v4" if len(sys.argv) > 2: depsonly = sys.argv[2] @@ -52,9 +53,27 @@ except: device = product if not depsonly: - print("Device %s not found. Attempting to retrieve device repository from LineageOS Github (http://github.com/LineageOS)." % device) + print("Device %s not found. Attempting to retrieve device repository from E foundation Gitlab (https://gitlab.e.foundation)." % device) repositories = [] +reposFromE = True + +def getReposFromE(): + searchLink = "{}/projects?search={}".format(gitlabApiUrl, device) + print(searchLink) + gitlabreq = urllib.request.Request(searchLink) + try: + result = json.loads(urllib.request.urlopen(gitlabreq).read().decode()) + for res in result: + repositories.append(res) + except urllib.error.URLError: + print("Failed to search Gitlab") + reposFromE = False + getReposFromLineage() + except ValueError: + print("Failed to parse return data from Gitlab") + reposFromE = False + getReposFromLineage() try: authtuple = netrc.netrc().authenticators("api.github.com") @@ -71,7 +90,9 @@ def add_auth(githubreq): if githubauth: githubreq.add_header("Authorization","Basic %s" % githubauth) -if not depsonly: +def getReposFromLineage(): + print("Device %s not found in e. Attempting to retrieve device repository from LineageOS Github (http://github.com/LineageOS)." % device) + reposFromE = False githubreq = urllib.request.Request("https://api.github.com/search/repositories?q=%s+user:LineageOS+in:name+fork:true" % device) add_auth(githubreq) try: @@ -85,6 +106,11 @@ if not depsonly: for res in result.get('items', []): repositories.append(res) +if not depsonly: + getReposFromE() + if not repositories: + getReposFromLineage() + local_manifests = r'.repo/local_manifests' if not os.path.exists(local_manifests): os.makedirs(local_manifests) -- GitLab From e016584a2480d827772146855a06a25fcbaa4e59 Mon Sep 17 00:00:00 2001 From: Anmol Agrawal Date: Thu, 28 Apr 2022 15:27:15 +0530 Subject: [PATCH 02/14] Added code to search for a repo on e gitlab Also removed some unnecessary print(s) (cherry picked from commit 8857b973eab642eed564b7ac029e0afec0ab8bae) --- build/tools/roomservice.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/build/tools/roomservice.py b/build/tools/roomservice.py index fa604540a..b71b02c38 100755 --- a/build/tools/roomservice.py +++ b/build/tools/roomservice.py @@ -60,7 +60,6 @@ reposFromE = True def getReposFromE(): searchLink = "{}/projects?search={}".format(gitlabApiUrl, device) - print(searchLink) gitlabreq = urllib.request.Request(searchLink) try: result = json.loads(urllib.request.urlopen(gitlabreq).read().decode()) @@ -203,6 +202,21 @@ def is_in_manifest(projectpath): return False +def isOnE(repository): + searchLink = "{}/projects?search={}".format(gitlabApiUrl, repository) + gitlabreq = urllib.request.Request(searchLink) + try: + result = json.loads(urllib.request.urlopen(gitlabreq).read().decode()) + if result: + return True + except urllib.error.URLError: + print("Failed to search Gitlab") + return False + except ValueError: + print("Failed to parse return data from Gitlab") + return False + + def add_to_manifest(repositories, fallback_branch = None): try: lm = ElementTree.parse(".repo/local_manifests/roomservice.xml") -- GitLab From d3e2274c3eadfb7b9ca64f195ef0aba03c6365b1 Mon Sep 17 00:00:00 2001 From: Anmol Agrawal Date: Thu, 28 Apr 2022 15:30:48 +0530 Subject: [PATCH 03/14] Modified getDefaultRevision Because we have a different remote and store it differently as well (cherry picked from commit 34f36ad6a9ac38ae061b7e28ce703ff3a5e30fcb) --- build/tools/roomservice.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build/tools/roomservice.py b/build/tools/roomservice.py index b71b02c38..e6b780614 100755 --- a/build/tools/roomservice.py +++ b/build/tools/roomservice.py @@ -152,6 +152,10 @@ def get_default_revision(): m = ElementTree.parse(get_manifest_path()) d = m.findall('default')[0] r = d.get('revision') + if reposFromE: + for remote in m.findall('remote'): + if 'e' == remote.get('name'): + r = remote.get('revision') return r.replace('refs/heads/', '').replace('refs/tags/', '') def get_from_manifest(devicename): -- GitLab From 19b2726a01d543b590fe35f16092fbfec0c94499 Mon Sep 17 00:00:00 2001 From: Anmol Agrawal Date: Thu, 28 Apr 2022 15:34:49 +0530 Subject: [PATCH 04/14] Search for repo on gitlab and add to roomservice Since we may or may not have the dependencies on our gitlab, lets search for every dependency on gitlab before adding to roomservice.xml (cherry picked from commit 9643e314bff80eb02fd48df468b0c01fe0e13971) --- build/tools/roomservice.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/build/tools/roomservice.py b/build/tools/roomservice.py index e6b780614..5f2143e0d 100755 --- a/build/tools/roomservice.py +++ b/build/tools/roomservice.py @@ -233,12 +233,16 @@ def add_to_manifest(repositories, fallback_branch = None): repo_target = repository['target_path'] print('Checking if %s is fetched from %s' % (repo_target, repo_name)) if is_in_manifest(repo_target): - print('LineageOS/%s already fetched to %s' % (repo_name, repo_target)) + print('%s already fetched to %s' % (repo_name, repo_target)) continue - print('Adding dependency: LineageOS/%s -> %s' % (repo_name, repo_target)) - project = ElementTree.Element("project", attrib = { "path": repo_target, - "remote": "github", "name": "LineageOS/%s" % repo_name }) + print('Adding dependency: %s -> %s' % (repo_name, repo_target)) + if reposFromE and isOnE(repo_name): + project = ElementTree.Element("project", attrib = { "path": repo_target, + "remote": "e", "name": "e/devices/%s" % repo_name }) + else: + project = ElementTree.Element("project", attrib = { "path": repo_target, + "remote": "github", "name": "LineageOS/%s" % repo_name }) if 'branch' in repository: project.set('revision',repository['branch']) -- GitLab From ad6f4b8f3667d475c182b745d018355d93e2cbd2 Mon Sep 17 00:00:00 2001 From: Anmol Agrawal Date: Thu, 28 Apr 2022 15:37:33 +0530 Subject: [PATCH 05/14] Fetch branches from gitlab (cherry picked from commit bd75fd4a46a489cbc71de41a27961b189ded7e58) --- build/tools/roomservice.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/build/tools/roomservice.py b/build/tools/roomservice.py index 5f2143e0d..2cf8e843b 100755 --- a/build/tools/roomservice.py +++ b/build/tools/roomservice.py @@ -322,9 +322,13 @@ else: default_revision = get_default_revision() print("Default revision: %s" % default_revision) print("Checking branch info") - githubreq = urllib.request.Request(repository['branches_url'].replace('{/branch}', '')) - add_auth(githubreq) - result = json.loads(urllib.request.urlopen(githubreq).read().decode()) + if reposFromE: + gitlabreq = urllib.request.Request("{}/projects/{}/repository/branches".format(gitlabApiUrl, repository['id'])) + result = json.loads(urllib.request.urlopen(gitlabreq).read().decode()) + else: + githubreq = urllib.request.Request(repository['branches_url'].replace('{/branch}', '')) + add_auth(githubreq) + result = json.loads(urllib.request.urlopen(githubreq).read().decode()) ## Try tags, too, since that's what releases use if not has_branch(result, default_revision): -- GitLab From 5a7ba8e5eedd7112fa1495bc49fe188774fa9bf0 Mon Sep 17 00:00:00 2001 From: Anmol Agrawal Date: Thu, 5 May 2022 12:51:26 +0530 Subject: [PATCH 06/14] Merged the getRepos functions Cleaning the code a bit --- build/tools/roomservice.py | 56 ++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 32 deletions(-) diff --git a/build/tools/roomservice.py b/build/tools/roomservice.py index 2cf8e843b..3f9c1c649 100755 --- a/build/tools/roomservice.py +++ b/build/tools/roomservice.py @@ -58,7 +58,7 @@ if not depsonly: repositories = [] reposFromE = True -def getReposFromE(): +def getRepos(): searchLink = "{}/projects?search={}".format(gitlabApiUrl, device) gitlabreq = urllib.request.Request(searchLink) try: @@ -68,47 +68,39 @@ def getReposFromE(): except urllib.error.URLError: print("Failed to search Gitlab") reposFromE = False - getReposFromLineage() except ValueError: print("Failed to parse return data from Gitlab") reposFromE = False - getReposFromLineage() - -try: - authtuple = netrc.netrc().authenticators("api.github.com") - - if authtuple: - auth_string = ('%s:%s' % (authtuple[0], authtuple[2])).encode() - githubauth = base64.encodestring(auth_string).decode().replace('\n', '') - else: + try: + authtuple = netrc.netrc().authenticators("api.github.com") + if authtuple: + auth_string = ('%s:%s' % (authtuple[0], authtuple[2])).encode() + githubauth = base64.encodestring(auth_string).decode().replace('\n', '') + else: + githubauth = None + except: githubauth = None -except: - githubauth = None + if not reposFromE: + print("Device %s not found in e. Attempting to retrieve device repository from LineageOS Github (http://github.com/LineageOS)." % device) + githubreq = urllib.request.Request("https://api.github.com/search/repositories?q=%s+user:LineageOS+in:name+fork:true" % device) + add_auth(githubreq) + try: + result = json.loads(urllib.request.urlopen(githubreq).read().decode()) + except urllib.error.URLError: + print("Failed to search GitHub") + sys.exit(1) + except ValueError: + print("Failed to parse return data from GitHub") + sys.exit(1) + for res in result.get('items', []): + repositories.append(res) def add_auth(githubreq): if githubauth: githubreq.add_header("Authorization","Basic %s" % githubauth) -def getReposFromLineage(): - print("Device %s not found in e. Attempting to retrieve device repository from LineageOS Github (http://github.com/LineageOS)." % device) - reposFromE = False - githubreq = urllib.request.Request("https://api.github.com/search/repositories?q=%s+user:LineageOS+in:name+fork:true" % device) - add_auth(githubreq) - try: - result = json.loads(urllib.request.urlopen(githubreq).read().decode()) - except urllib.error.URLError: - print("Failed to search GitHub") - sys.exit(1) - except ValueError: - print("Failed to parse return data from GitHub") - sys.exit(1) - for res in result.get('items', []): - repositories.append(res) - if not depsonly: - getReposFromE() - if not repositories: - getReposFromLineage() + getRepos() local_manifests = r'.repo/local_manifests' if not os.path.exists(local_manifests): os.makedirs(local_manifests) -- GitLab From 299adea4983312d9eaeb90e707c813f02550a4ee Mon Sep 17 00:00:00 2001 From: Anmol Agrawal Date: Thu, 5 May 2022 13:22:22 +0530 Subject: [PATCH 07/14] Added local variable inside function to avoid access errors The variable reposFromE was being accessed before deinition so defined it in function and moved the authorization for github above since it may be needed anyways --- build/tools/roomservice.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/build/tools/roomservice.py b/build/tools/roomservice.py index 3f9c1c649..742cad4c7 100755 --- a/build/tools/roomservice.py +++ b/build/tools/roomservice.py @@ -58,7 +58,18 @@ if not depsonly: repositories = [] reposFromE = True +try: + authtuple = netrc.netrc().authenticators("api.github.com") + if authtuple: + auth_string = ('%s:%s' % (authtuple[0], authtuple[2])).encode() + githubauth = base64.encodestring(auth_string).decode().replace('\n', '') + else: + githubauth = None +except: + githubauth = None + def getRepos(): + reposFromE = True searchLink = "{}/projects?search={}".format(gitlabApiUrl, device) gitlabreq = urllib.request.Request(searchLink) try: @@ -71,15 +82,6 @@ def getRepos(): except ValueError: print("Failed to parse return data from Gitlab") reposFromE = False - try: - authtuple = netrc.netrc().authenticators("api.github.com") - if authtuple: - auth_string = ('%s:%s' % (authtuple[0], authtuple[2])).encode() - githubauth = base64.encodestring(auth_string).decode().replace('\n', '') - else: - githubauth = None - except: - githubauth = None if not reposFromE: print("Device %s not found in e. Attempting to retrieve device repository from LineageOS Github (http://github.com/LineageOS)." % device) githubreq = urllib.request.Request("https://api.github.com/search/repositories?q=%s+user:LineageOS+in:name+fork:true" % device) -- GitLab From 5d49ab936d63c94ce590191cb75f7568f3648636 Mon Sep 17 00:00:00 2001 From: Anmol Agrawal Date: Thu, 5 May 2022 13:26:53 +0530 Subject: [PATCH 08/14] Added code to fetch tags from gitlab Just in case that's required --- build/tools/roomservice.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/build/tools/roomservice.py b/build/tools/roomservice.py index 742cad4c7..9b01c746f 100755 --- a/build/tools/roomservice.py +++ b/build/tools/roomservice.py @@ -326,9 +326,13 @@ else: ## Try tags, too, since that's what releases use if not has_branch(result, default_revision): - githubreq = urllib.request.Request(repository['tags_url'].replace('{/tag}', '')) - add_auth(githubreq) - result.extend (json.loads(urllib.request.urlopen(githubreq).read().decode())) + if reposFromE: + gitlabreq = urllib.request.Request("{}/projects/{}/repository/tags".format(gitlabApiUrl, repository['id'])) + result.extend (json.loads(urllib.request.urlopen(gitlabreq).read().decode())) + else: + githubreq = urllib.request.Request(repository['tags_url'].replace('{/tag}', '')) + add_auth(githubreq) + result.extend (json.loads(urllib.request.urlopen(githubreq).read().decode())) repo_path = "device/%s/%s" % (manufacturer, device) adding = {'repository':repo_name,'target_path':repo_path} -- GitLab From 06a68c7b980e38b64fb14dd4d2b6bee8852aeff9 Mon Sep 17 00:00:00 2001 From: anmol Date: Wed, 11 May 2022 10:39:05 +0000 Subject: [PATCH 09/14] Added fixes to fetch from Lineage Made reposFromE a global variable --- build/tools/roomservice.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/build/tools/roomservice.py b/build/tools/roomservice.py index 9b01c746f..f023af44a 100755 --- a/build/tools/roomservice.py +++ b/build/tools/roomservice.py @@ -56,7 +56,6 @@ if not depsonly: print("Device %s not found. Attempting to retrieve device repository from E foundation Gitlab (https://gitlab.e.foundation)." % device) repositories = [] -reposFromE = True try: authtuple = netrc.netrc().authenticators("api.github.com") @@ -69,6 +68,7 @@ except: githubauth = None def getRepos(): + global reposFromE reposFromE = True searchLink = "{}/projects?search={}".format(gitlabApiUrl, device) gitlabreq = urllib.request.Request(searchLink) @@ -82,12 +82,13 @@ def getRepos(): except ValueError: print("Failed to parse return data from Gitlab") reposFromE = False - if not reposFromE: + if not repositories: print("Device %s not found in e. Attempting to retrieve device repository from LineageOS Github (http://github.com/LineageOS)." % device) githubreq = urllib.request.Request("https://api.github.com/search/repositories?q=%s+user:LineageOS+in:name+fork:true" % device) add_auth(githubreq) try: result = json.loads(urllib.request.urlopen(githubreq).read().decode()) + reposFromE = False except urllib.error.URLError: print("Failed to search GitHub") sys.exit(1) @@ -317,6 +318,7 @@ else: print("Default revision: %s" % default_revision) print("Checking branch info") if reposFromE: + print(reposFromE) gitlabreq = urllib.request.Request("{}/projects/{}/repository/branches".format(gitlabApiUrl, repository['id'])) result = json.loads(urllib.request.urlopen(gitlabreq).read().decode()) else: -- GitLab From ad594f63314762783fcac27b9ab1d7e64ad569f4 Mon Sep 17 00:00:00 2001 From: anmol Date: Thu, 12 May 2022 10:35:11 +0000 Subject: [PATCH 10/14] Added fixes for searching devices and branches Added _ before device and %20device to filter out device repos Added a search for default branch because if a repo has too many branches, then there is a chance that the default branch will not be listed --- build/tools/roomservice.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build/tools/roomservice.py b/build/tools/roomservice.py index f023af44a..8fb327dde 100755 --- a/build/tools/roomservice.py +++ b/build/tools/roomservice.py @@ -70,7 +70,8 @@ except: def getRepos(): global reposFromE reposFromE = True - searchLink = "{}/projects?search={}".format(gitlabApiUrl, device) + searchLink = "{}/projects?search=_{} device".format(gitlabApiUrl, device) + searchLink = searchLink.replace(' ', '%20') gitlabreq = urllib.request.Request(searchLink) try: result = json.loads(urllib.request.urlopen(gitlabreq).read().decode()) @@ -318,8 +319,7 @@ else: print("Default revision: %s" % default_revision) print("Checking branch info") if reposFromE: - print(reposFromE) - gitlabreq = urllib.request.Request("{}/projects/{}/repository/branches".format(gitlabApiUrl, repository['id'])) + gitlabreq = urllib.request.Request("{}/projects/{}/repository/branches?search={}".format(gitlabApiUrl, repository['id'], default_revision)) result = json.loads(urllib.request.urlopen(gitlabreq).read().decode()) else: githubreq = urllib.request.Request(repository['branches_url'].replace('{/branch}', '')) -- GitLab From e86e1beae67331e633b3aa32b7f459c1a1582a4c Mon Sep 17 00:00:00 2001 From: Anmol Agrawal Date: Mon, 23 May 2022 05:59:50 +0000 Subject: [PATCH 11/14] Added copyright Also changed a minor string --- build/tools/roomservice.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/tools/roomservice.py b/build/tools/roomservice.py index 8fb327dde..6674a31de 100755 --- a/build/tools/roomservice.py +++ b/build/tools/roomservice.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # Copyright (C) 2012-2013, The CyanogenMod Project # (C) 2017-2018,2020-2021, The LineageOS Project +# (C) 2022, ECORP SAS # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -53,7 +54,7 @@ except: device = product if not depsonly: - print("Device %s not found. Attempting to retrieve device repository from E foundation Gitlab (https://gitlab.e.foundation)." % device) + print("Device %s not found. Attempting to retrieve device repository from E FOUNDATION Gitlab (https://gitlab.e.foundation)." % device) repositories = [] -- GitLab From 08ddd3f9b6ad2bc53b7bbd17806b824faa5e7227 Mon Sep 17 00:00:00 2001 From: Anmol Agrawal Date: Thu, 2 Jun 2022 10:51:08 +0000 Subject: [PATCH 12/14] Squashed error messages into one This was to avoid having redundant code that would only run in extremely rare scenarios --- build/tools/roomservice.py | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/build/tools/roomservice.py b/build/tools/roomservice.py index 6674a31de..f47ee22e8 100755 --- a/build/tools/roomservice.py +++ b/build/tools/roomservice.py @@ -78,11 +78,8 @@ def getRepos(): result = json.loads(urllib.request.urlopen(gitlabreq).read().decode()) for res in result: repositories.append(res) - except urllib.error.URLError: - print("Failed to search Gitlab") - reposFromE = False - except ValueError: - print("Failed to parse return data from Gitlab") + except: + print("Failed to search Gitlab or could not parse return data from Gitlab") reposFromE = False if not repositories: print("Device %s not found in e. Attempting to retrieve device repository from LineageOS Github (http://github.com/LineageOS)." % device) @@ -91,11 +88,8 @@ def getRepos(): try: result = json.loads(urllib.request.urlopen(githubreq).read().decode()) reposFromE = False - except urllib.error.URLError: - print("Failed to search GitHub") - sys.exit(1) - except ValueError: - print("Failed to parse return data from GitHub") + except: + print("Failed to search GitHub or could not parse return data from GitHub") sys.exit(1) for res in result.get('items', []): repositories.append(res) @@ -210,11 +204,8 @@ def isOnE(repository): result = json.loads(urllib.request.urlopen(gitlabreq).read().decode()) if result: return True - except urllib.error.URLError: - print("Failed to search Gitlab") - return False - except ValueError: - print("Failed to parse return data from Gitlab") + except: + print("Failed to search Gitlab or could not parse return data from Gitlab") return False -- GitLab From 1b539ba7fce1a754cdad53117220b24e8414306a Mon Sep 17 00:00:00 2001 From: Anmol Agrawal Date: Mon, 27 Jun 2022 12:45:49 +0530 Subject: [PATCH 13/14] Switched to snake_case Because that's what Python uses --- build/tools/roomservice.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/build/tools/roomservice.py b/build/tools/roomservice.py index f47ee22e8..87ae60dce 100755 --- a/build/tools/roomservice.py +++ b/build/tools/roomservice.py @@ -41,7 +41,7 @@ except ImportError: from xml.etree import ElementTree product = sys.argv[1] -gitlabApiUrl = "https://gitlab.e.foundation/api/v4" +gitlab_api_url = "https://gitlab.e.foundation/api/v4" if len(sys.argv) > 2: depsonly = sys.argv[2] @@ -69,25 +69,25 @@ except: githubauth = None def getRepos(): - global reposFromE - reposFromE = True - searchLink = "{}/projects?search=_{} device".format(gitlabApiUrl, device) - searchLink = searchLink.replace(' ', '%20') - gitlabreq = urllib.request.Request(searchLink) + global repos_from_e + repos_from_e = True + search_link = "{}/projects?search=_{} device".format(gitlab_api_url, device) + search_link = search_link.replace(' ', '%20') + gitlabreq = urllib.request.Request(search_link) try: result = json.loads(urllib.request.urlopen(gitlabreq).read().decode()) for res in result: repositories.append(res) except: print("Failed to search Gitlab or could not parse return data from Gitlab") - reposFromE = False + repos_from_e = False if not repositories: print("Device %s not found in e. Attempting to retrieve device repository from LineageOS Github (http://github.com/LineageOS)." % device) githubreq = urllib.request.Request("https://api.github.com/search/repositories?q=%s+user:LineageOS+in:name+fork:true" % device) add_auth(githubreq) try: result = json.loads(urllib.request.urlopen(githubreq).read().decode()) - reposFromE = False + repos_from_e = False except: print("Failed to search GitHub or could not parse return data from GitHub") sys.exit(1) @@ -143,7 +143,7 @@ def get_default_revision(): m = ElementTree.parse(get_manifest_path()) d = m.findall('default')[0] r = d.get('revision') - if reposFromE: + if repos_from_e: for remote in m.findall('remote'): if 'e' == remote.get('name'): r = remote.get('revision') @@ -197,9 +197,9 @@ def is_in_manifest(projectpath): return False -def isOnE(repository): - searchLink = "{}/projects?search={}".format(gitlabApiUrl, repository) - gitlabreq = urllib.request.Request(searchLink) +def is_on_e(repository): + search_link = "{}/projects?search={}".format(gitlab_api_url, repository) + gitlabreq = urllib.request.Request(search_link) try: result = json.loads(urllib.request.urlopen(gitlabreq).read().decode()) if result: @@ -225,7 +225,7 @@ def add_to_manifest(repositories, fallback_branch = None): continue print('Adding dependency: %s -> %s' % (repo_name, repo_target)) - if reposFromE and isOnE(repo_name): + if repos_from_e and is_on_e(repo_name): project = ElementTree.Element("project", attrib = { "path": repo_target, "remote": "e", "name": "e/devices/%s" % repo_name }) else: @@ -310,8 +310,8 @@ else: default_revision = get_default_revision() print("Default revision: %s" % default_revision) print("Checking branch info") - if reposFromE: - gitlabreq = urllib.request.Request("{}/projects/{}/repository/branches?search={}".format(gitlabApiUrl, repository['id'], default_revision)) + if repos_from_e: + gitlabreq = urllib.request.Request("{}/projects/{}/repository/branches?search={}".format(gitlab_api_url, repository['id'], default_revision)) result = json.loads(urllib.request.urlopen(gitlabreq).read().decode()) else: githubreq = urllib.request.Request(repository['branches_url'].replace('{/branch}', '')) @@ -320,8 +320,8 @@ else: ## Try tags, too, since that's what releases use if not has_branch(result, default_revision): - if reposFromE: - gitlabreq = urllib.request.Request("{}/projects/{}/repository/tags".format(gitlabApiUrl, repository['id'])) + if repos_from_e: + gitlabreq = urllib.request.Request("{}/projects/{}/repository/tags".format(gitlab_api_url, repository['id'])) result.extend (json.loads(urllib.request.urlopen(gitlabreq).read().decode())) else: githubreq = urllib.request.Request(repository['tags_url'].replace('{/tag}', '')) -- GitLab From 7ebcd5b2072297b53de587081108bcce04231d2c Mon Sep 17 00:00:00 2001 From: Anmol Agrawal Date: Mon, 27 Jun 2022 12:54:40 +0530 Subject: [PATCH 14/14] Fixed some indentation --- build/tools/roomservice.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/build/tools/roomservice.py b/build/tools/roomservice.py index 87ae60dce..a5d6ec935 100755 --- a/build/tools/roomservice.py +++ b/build/tools/roomservice.py @@ -304,9 +304,7 @@ else: repo_name = repository['name'] if re.match(r"^android_device_[^_]*_" + device + "$", repo_name): print("Found repository: %s" % repository['name']) - manufacturer = repo_name.replace("android_device_", "").replace("_" + device, "") - default_revision = get_default_revision() print("Default revision: %s" % default_revision) print("Checking branch info") @@ -327,10 +325,8 @@ else: githubreq = urllib.request.Request(repository['tags_url'].replace('{/tag}', '')) add_auth(githubreq) result.extend (json.loads(urllib.request.urlopen(githubreq).read().decode())) - repo_path = "device/%s/%s" % (manufacturer, device) adding = {'repository':repo_name,'target_path':repo_path} - fallback_branch = None if not has_branch(result, default_revision): if os.getenv('ROOMSERVICE_BRANCHES'): -- GitLab