NikGapps 3.29__py3-none-any.whl → 3.30__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. NikGapps/build/Build.py +8 -8
  2. NikGapps/build/NikGappsManager.py +2 -2
  3. NikGapps/build/Release.py +5 -5
  4. NikGapps/build_config.py +8 -8
  5. NikGapps/cache.py +10 -10
  6. NikGapps/config/NikGappsConfig.py +15 -15
  7. NikGapps/copy_repos.py +1 -1
  8. NikGapps/helper/Assets.py +8 -8
  9. NikGapps/helper/Package.py +1 -5
  10. NikGapps/helper/SystemStat.py +2 -2
  11. NikGapps/helper/compression/CompOps.py +3 -3
  12. NikGapps/helper/compression/Export.py +8 -8
  13. NikGapps/helper/compression/Tar.py +2 -2
  14. NikGapps/helper/compression/Zip.py +3 -2
  15. NikGapps/helper/compression/Zsh.py +1 -1
  16. NikGapps/helper/git/TestGit.py +1 -1
  17. NikGapps/helper/overlay/ApkMetaInfo.py +1 -1
  18. NikGapps/helper/overlay/Manifest.py +1 -1
  19. NikGapps/helper/overlay/Overlay.py +1 -1
  20. NikGapps/helper/upload/CmdUpload.py +7 -7
  21. NikGapps/helper/upload/GoFileUpload.py +7 -7
  22. NikGapps/main.py +7 -7
  23. NikGapps/overlay_control.py +11 -10
  24. NikGapps/test.py +1 -20
  25. {NikGapps-3.29.dist-info → NikGapps-3.30.dist-info}/METADATA +4 -3
  26. NikGapps-3.30.dist-info/RECORD +72 -0
  27. NikGapps/build/NikGappsPackages.py +0 -916
  28. NikGapps/helper/C.py +0 -16
  29. NikGapps/helper/Cmd.py +0 -296
  30. NikGapps/helper/FileOp.py +0 -235
  31. NikGapps/helper/Json.py +0 -34
  32. NikGapps/helper/P.py +0 -23
  33. NikGapps/helper/Statics.py +0 -166
  34. NikGapps/helper/T.py +0 -82
  35. NikGapps/helper/git/Git.py +0 -228
  36. NikGapps/helper/git/GitOperations.py +0 -118
  37. NikGapps/helper/git/GitStatics.py +0 -14
  38. NikGapps/helper/git/GithubManager.py +0 -21
  39. NikGapps/helper/git/GitlabManager.py +0 -265
  40. NikGapps/helper/upload/Upload.py +0 -125
  41. NikGapps/helper/web/Requests.py +0 -139
  42. NikGapps/helper/web/TelegramApi.py +0 -126
  43. NikGapps/helper/web/__init__.py +0 -0
  44. NikGapps-3.29.dist-info/RECORD +0 -89
  45. {NikGapps-3.29.dist-info → NikGapps-3.30.dist-info}/LICENSE +0 -0
  46. {NikGapps-3.29.dist-info → NikGapps-3.30.dist-info}/WHEEL +0 -0
  47. {NikGapps-3.29.dist-info → NikGapps-3.30.dist-info}/entry_points.txt +0 -0
  48. {NikGapps-3.29.dist-info → NikGapps-3.30.dist-info}/top_level.txt +0 -0
@@ -1,166 +0,0 @@
1
- import glob
2
- import math
3
- import os
4
- from pathlib import Path
5
- from .C import C
6
- from .T import T
7
-
8
-
9
- class Statics:
10
- time = T.get_london_date_time("%y%m%d%H%M")
11
- android_versions = {
12
- '10': {'sdk': '29', 'code': 'Q'},
13
- '11': {'sdk': '30', 'code': 'R'},
14
- '12': {'sdk': '31', 'code': 'S'},
15
- '12.1': {'sdk': '32', 'code': 'SL'},
16
- '13': {'sdk': '33', 'code': 'T'},
17
- '14': {'sdk': '34', 'code': 'U'},
18
- '15': {'sdk': '35', 'code': 'V'},
19
- }
20
- is_system_app = 1
21
- is_priv_app = 2
22
- system_root_dir = "/system/product"
23
- cwd = C.find_cwd()
24
- pwd = str(Path(cwd).parent)
25
- dir_sep = os.path.sep
26
- DELETE_FILES_NAME = "DeleteFilesData"
27
- meta_inf_dir = "META-INF/com/google/android/"
28
- nikgapps_config = "nikgapps.config"
29
- release_tracker_url = "https://raw.githubusercontent.com/nikgapps/tracker/main/release_tracker.json"
30
- folder_access_url = "https://raw.githubusercontent.com/nikgapps/tracker/main/folder_access.json"
31
- admin_access_url = "https://raw.githubusercontent.com/nikgapps/tracker/main/admin_access.txt"
32
- admin_access = None
33
- folder_access = None
34
- in_progress = "○"
35
- completed = "●"
36
- package_details = {}
37
- # "■ ▤ □ ▥ ▧ ▨ ▩ ▦ ▣ ◈ ◇ ◆ ◉ ◊ ○ ◌ ◍ ◎ ● ◐ ◑ ◒ ◓ ◔ ◕ ◖ ◗ ◘ ◙ ◚ ◛"
38
-
39
- @staticmethod
40
- def display_progress(percentage):
41
- percentage = max(1, min(100, percentage))
42
- completed_steps = int(percentage / 10)
43
- in_progress_steps = 10 - completed_steps
44
- progress_str = Statics.completed * completed_steps + Statics.in_progress * in_progress_steps
45
- elegant_progress_str = ' '.join(progress_str)
46
- return f"( {elegant_progress_str} )" if percentage != 100 else ""
47
-
48
- @staticmethod
49
- def get_import_path(app_set, pkg, install_path, target_version, export_directory=None):
50
- base_name = os.path.basename(install_path)
51
- dir_name = Statics.get_parent_path(install_path)
52
- dir_name = str(dir_name).replace("\\system_ext", "").replace("/system_ext", "") \
53
- .replace("\\system", "").replace("/system", "") \
54
- .replace("\\product", "").replace("/product", "")
55
- if export_directory is not None:
56
- output = export_directory + os.path.sep
57
- else:
58
- output = Statics.pwd + os.path.sep + "Export" + os.path.sep + str(
59
- target_version) + os.path.sep + T.get_london_date_time("%Y%m%d") + os.path.sep
60
- if app_set is not None:
61
- output += app_set + os.path.sep
62
- output += str(pkg) + os.path.sep + str(dir_name).replace("\\", "___").replace(
63
- os.path.sep, "___") + os.path.sep + base_name
64
- if not os.path.exists(Path(output).parent):
65
- os.makedirs(Path(output).parent)
66
- return Path(output)
67
-
68
- @staticmethod
69
- def get_parent_path(file_path):
70
- return Path(file_path).parent
71
-
72
- @staticmethod
73
- def find_latest_aapt():
74
- # Try to get the Android SDK path from environment variables
75
- sdk_path = os.environ.get("ANDROID_HOME") or os.environ.get("ANDROID_SDK_ROOT")
76
- if not sdk_path:
77
- raise EnvironmentError("Android SDK path not found. "
78
- "Set ANDROID_HOME or ANDROID_SDK_ROOT environment variable.")
79
- # Build the search pattern
80
- search_pattern = os.path.join(sdk_path, "build-tools", "*", "aapt")
81
- # Find all matching paths
82
- aapt_paths = glob.glob(search_pattern)
83
- # Sort the paths to find the latest
84
- if aapt_paths:
85
- latest_aapt_path = max(aapt_paths, key=os.path.getmtime)
86
- return str(latest_aapt_path)
87
- else:
88
- return None
89
-
90
- @staticmethod
91
- def get_download_link(file_name, sf_path):
92
- sf_prefix = "https://sourceforge.net/projects/nikgapps/files/"
93
- download_link = sf_prefix + sf_path[len("/home/frs/project/nikgapps/"):] + "/" + os.path.basename(
94
- file_name) + "/download"
95
- return download_link
96
-
97
- @staticmethod
98
- def get_file_bytes(file_name):
99
- file_stats = os.stat(file_name)
100
- # 1000 instead of 1024 because it's better to require more size than what gapps exactly takes
101
- return math.ceil(file_stats.st_size / 1000)
102
-
103
- @staticmethod
104
- def get_temp_packages_directory(android_version, arch="arm64"):
105
- return Statics.pwd + os.path.sep + "TempPackages" + os.path.sep + str(android_version) + os.path.sep + arch
106
-
107
- @staticmethod
108
- def get_overlay_source_directory(android_version):
109
- return Statics.pwd + os.path.sep + f"overlays_{android_version}_source"
110
-
111
- @staticmethod
112
- def get_overlay_source_repo(android_version):
113
- return f"git@gitlab.com:nikgapps/overlays_{android_version}_source.git"
114
-
115
- @staticmethod
116
- def get_overlay_directory(android_version):
117
- return Statics.pwd + os.path.sep + f"overlays_{android_version}"
118
-
119
- @staticmethod
120
- def get_overlay_repo(android_version):
121
- return f"git@gitlab.com:nikgapps/overlays_{android_version}.git"
122
-
123
- @staticmethod
124
- def get_temp_overlay_directory(android_version):
125
- return Statics.get_temp_packages_directory(android_version) + os.path.sep + "Overlays"
126
-
127
- @staticmethod
128
- def get_release_directory(android_version):
129
- return Statics.pwd + os.path.sep + "Releases" + os.path.sep + str(android_version)
130
-
131
- @staticmethod
132
- def get_android_code(android_version):
133
- return Statics.android_versions[str(android_version)]['code']
134
-
135
- @staticmethod
136
- def get_android_sdk(android_version):
137
- return Statics.android_versions[str(android_version)]['sdk']
138
-
139
- @staticmethod
140
- def get_package_details(android_version):
141
- return f"{android_version}{Statics.dir_sep}package_details.json"
142
-
143
- @staticmethod
144
- def get_sourceforge_release_directory(release_dir):
145
- sourceforge_root_directory = "/home/frs/project/nikgapps"
146
- match release_dir:
147
- case ("config"):
148
- return f"{sourceforge_root_directory}/Config-Releases"
149
- case ("canary"):
150
- return f"{sourceforge_root_directory}/Swift-Releases"
151
- case ("swift"):
152
- return f"{sourceforge_root_directory}/Swift-Releases"
153
- case ("stable"):
154
- return f"{sourceforge_root_directory}/Releases"
155
- case ("beta"):
156
- return f"{sourceforge_root_directory}/Next-Releases"
157
- case ("next"):
158
- return f"{sourceforge_root_directory}/Next-Releases"
159
- case _:
160
- return f"{sourceforge_root_directory}/{release_dir}"
161
-
162
- @staticmethod
163
- def get_partition(android_version, partition):
164
- if float(android_version) <= 10:
165
- return "product"
166
- return partition
NikGapps/helper/T.py DELETED
@@ -1,82 +0,0 @@
1
- import math
2
- import os
3
- import time
4
- from datetime import datetime
5
-
6
- import pytz
7
-
8
- from .P import P
9
-
10
-
11
- class T:
12
-
13
- def __init__(self):
14
- self.t = time.time()
15
-
16
- def taken(self, message=None):
17
- start_time = self.t
18
- P.yellow("---------------------------------------")
19
- if message is not None:
20
- P.yellow("--- " + message + " ---")
21
- sec = round(time.time() - start_time, 0)
22
- seconds = int(math.fmod(sec, 60))
23
- minutes = int(sec // 60)
24
- time_diff = (time.time() - start_time)
25
- P.yellow(f"--- {time_diff} seconds --- ")
26
- P.yellow(f"--- %s minutes %s seconds --- " % (minutes, seconds))
27
- P.yellow("---------------------------------------")
28
- return time_diff
29
-
30
- @staticmethod
31
- def get_london_date_time(date_format=None):
32
- dt_london = datetime.now(pytz.timezone('Europe/London'))
33
- return dt_london if date_format is None else dt_london.strftime(date_format)
34
-
35
- @staticmethod
36
- def get_new_york_date_time(date_format=None):
37
- tz_ny = pytz.timezone('America/New_York')
38
- datetime_ny = datetime.now(tz_ny)
39
- return datetime_ny if date_format is None else datetime_ny.strftime(date_format)
40
-
41
- @staticmethod
42
- def get_local_date_time(date_format=None):
43
- local = datetime.now()
44
- return local if date_format is None else local.strftime(date_format)
45
-
46
- @staticmethod
47
- def get_file_name(nikgappstype, android_version, arch="arm64"):
48
- current_time = T.get_current_time()
49
- return "NikGapps-" + nikgappstype + f"-{arch}-" + str(android_version) + "-" + current_time + ".zip"
50
-
51
- @staticmethod
52
- def get_current_time():
53
- tz_london = pytz.timezone('Europe/London')
54
- datetime_london = datetime.now(tz_london)
55
- return datetime_london.strftime("%Y%m%d")
56
-
57
- @staticmethod
58
- def get_path(user_name, android_version):
59
- tz_london = pytz.timezone('Europe/London')
60
- datetime_london = datetime.now(tz_london)
61
- return user_name + "/" + "Android-" + str(android_version) + "/" + str(datetime_london.strftime("%d-%b-%Y"))
62
-
63
- @staticmethod
64
- def get_mtime(pkg_zip_path):
65
- return datetime.fromtimestamp(os.path.getmtime(pkg_zip_path))
66
-
67
- @staticmethod
68
- def format_time(seconds):
69
- seconds = int(seconds)
70
- minutes, seconds = divmod(seconds, 60)
71
- hours, minutes = divmod(minutes, 60)
72
- days, hours = divmod(hours, 24)
73
- parts = []
74
- if days > 0:
75
- parts.append(f"{days} {'day' if days == 1 else 'days'}")
76
- if hours > 0:
77
- parts.append(f"{hours} {'hour' if hours == 1 else 'hours'}")
78
- if minutes > 0:
79
- parts.append(f"{minutes} {'minute' if minutes == 1 else 'minutes'}")
80
- if seconds > 0 or not parts:
81
- parts.append(f"{seconds} {'second' if seconds == 1 else 'seconds'}")
82
- return ', '.join(parts)
@@ -1,228 +0,0 @@
1
- import re
2
-
3
- import git.exc
4
- from git import Repo, Commit
5
- from shutil import copyfile
6
- from .. import Config
7
- from ..FileOp import FileOp
8
- from ..Assets import Assets
9
- import os
10
- import time
11
- import datetime
12
- from datetime import datetime
13
- import pytz
14
- from .GitStatics import GitStatics
15
- from ..P import P
16
- from ..T import T
17
-
18
-
19
- class Git:
20
-
21
- def __init__(self, working_tree_dir):
22
- os.environ["GIT_CLONE_PROTECTION_ACTIVE"] = 'false'
23
- self.enable_push = Config.GIT_PUSH
24
- self.working_tree_dir = working_tree_dir
25
- self.repo_name = None
26
- if FileOp.dir_exists(self.working_tree_dir):
27
- self.repo = Repo(working_tree_dir)
28
-
29
- def clone_repo(self, repo_url, branch="main", fresh_clone=True, commit_depth=1):
30
- try:
31
- t = T()
32
- if fresh_clone:
33
- # for fresh clone, we must clean the directory and clone again
34
- if FileOp.dir_exists(self.working_tree_dir):
35
- print(f"{self.working_tree_dir} already exists, deleting for a fresh clone!")
36
- FileOp.remove_dir(self.working_tree_dir)
37
- if commit_depth == 0:
38
- P.green(f"git clone -b {branch} {repo_url}")
39
- self.repo = git.Repo.clone_from(repo_url, self.working_tree_dir, branch=branch)
40
- else:
41
- P.green(f"git clone -b {branch} --depth={commit_depth} {repo_url}")
42
- self.repo = git.Repo.clone_from(repo_url, self.working_tree_dir, branch=branch, depth=commit_depth)
43
-
44
- else:
45
- # if it is not a fresh clone, we only clone when directory doesn't exist
46
- if not FileOp.dir_exists(self.working_tree_dir):
47
- print(f"{self.working_tree_dir} doesn't exists, fresh clone is enforced!")
48
- P.yellow(f"git clone -b {branch} --depth={commit_depth} {repo_url}")
49
- self.repo = git.Repo.clone_from(repo_url, self.working_tree_dir, branch=branch, depth=commit_depth)
50
- t.taken(f"Time taken to clone -b {branch} {repo_url}")
51
- self.update_repo_name(repo_url)
52
- assert self.repo.__class__ is Repo # clone an existing repository
53
- assert Repo.init(self.working_tree_dir).__class__ is Repo
54
- return True
55
- except Exception as e:
56
- print("Exception caught while cloning the repo: " + str(e))
57
- return False
58
-
59
- # this will return commits 21-30 from the commit list as traversed backwards master
60
- # ten_commits_past_twenty = list(repo.iter_commits('master', max_count=10, skip=20))
61
- # assert len(ten_commits_past_twenty) == 10
62
- # assert fifty_first_commits[20:30] == ten_commits_past_twenty
63
- # repo = git.Repo.clone_from(repo_url, working_tree_dir, branch='master')
64
- def get_latest_commit_date(self, branch=None, filter_key=None):
65
- tz_london = pytz.timezone('Europe/London')
66
- try:
67
- if branch is not None:
68
- commits = list(self.repo.iter_commits(branch, max_count=50))
69
- else:
70
- commits = list(self.repo.iter_commits('master', max_count=50))
71
- except git.exc.GitCommandError:
72
- if branch == "master":
73
- branch = "main"
74
- commits = list(self.repo.iter_commits(branch, max_count=50))
75
-
76
- for commit in commits:
77
- commit: Commit
78
- # if filter_key = 10, it will look for commits that starts with 10
79
- # failing will continue looking for latest available commit that starts with 10
80
- if filter_key is not None and not str(commit.message).startswith(filter_key + ":"):
81
- continue
82
- time_in_string = str(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(commit.committed_date)))
83
- time_in_object = datetime.strptime(time_in_string, '%Y-%m-%d %H:%M:%S')
84
- london_time_in_object = time_in_object.astimezone(tz_london)
85
- london_time_in_string = london_time_in_object.strftime('%Y-%m-%d %H:%M:%S')
86
- commit_datetime = datetime.strptime(london_time_in_string, '%Y-%m-%d %H:%M:%S')
87
- return commit_datetime
88
- return None
89
-
90
- def update_repo_name(self, git_url):
91
- git_pattern = re.compile(r'git@[^:]+:[^/]+/(.+)\.git')
92
- https_pattern = re.compile(r'https?://[^/]+/[^/]+/(.+)\.git')
93
- match = git_pattern.match(git_url) or https_pattern.match(git_url)
94
- if match:
95
- self.repo_name = match.group(1)
96
- else:
97
- raise ValueError("Invalid Git URL")
98
-
99
- def get_file_commit_date(self, file_path, str_format="%y%m%d%H%M", skip_containing=None):
100
- commits_touching_path = list(self.repo.iter_commits(paths=file_path))
101
- if commits_touching_path:
102
- for commit in commits_touching_path:
103
- if skip_containing is not None and str(skip_containing).lower() in commit.message.lower():
104
- P.blue(f"Skipping commit ({commit.hexsha[:7]}): "
105
- f"{commit.message} as it contains '{skip_containing}'")
106
- continue
107
- P.green(f"Commit ({commit.hexsha[:7]}): {commit.message} found for {file_path}")
108
- return commit.committed_datetime.strftime(str_format)
109
- else:
110
- return None
111
-
112
- def get_changed_files(self):
113
- files_list = []
114
- files = self.repo.git.diff(None, name_only=True)
115
- if files != "":
116
- for f in files.split('\n'):
117
- files_list.append(f)
118
- if self.repo.untracked_files.__len__() > 0:
119
- for f in self.repo.untracked_files:
120
- files_list.append(f)
121
- return files_list
122
-
123
- def due_changes(self):
124
- files = self.repo.git.diff(None, name_only=True)
125
- if files != "":
126
- if files.split('\n').__len__() > 0:
127
- return True
128
- if self.repo.untracked_files.__len__() > 0:
129
- return True
130
- return False
131
-
132
- def git_push(self, commit_message, push_untracked_files=False, debug=False, rebase=False, pull_first=False,
133
- post_buffer=None):
134
- if not self.enable_push:
135
- print("Git push is disabled, skipping push!")
136
- return False
137
- try:
138
- origin = self.repo.remote(name='origin')
139
- if post_buffer is not None:
140
- self.repo.git.config('http.postBuffer', post_buffer)
141
- if self.repo.is_dirty(untracked_files=True):
142
- self.repo.git.add(u=True)
143
- if push_untracked_files:
144
- self.repo.git.add(A=True)
145
- if commit_message is None:
146
- commit_message = "Auto Commit"
147
- self.repo.index.commit(commit_message)
148
- if pull_first:
149
- origin.fetch(self.repo.active_branch.name)
150
- origin.pull(self.repo.active_branch.name)
151
- if rebase:
152
- origin.fetch(self.repo.active_branch.name)
153
- try:
154
- self.repo.git.pull('--rebase')
155
- except git.GitCommandError as e:
156
- print(f"Error during rebase: {e}")
157
- return False
158
- if debug:
159
- remotes = self.repo.remotes
160
- for remote in remotes:
161
- print(f"Remote name: {remote.name}")
162
- for url in remote.urls:
163
- print(f"URL: {url}")
164
- P.blue(self.repo.git.status())
165
- push_info = origin.push(self.repo.active_branch.name)
166
- for info in push_info:
167
- if info.flags & (git.PushInfo.REMOTE_REJECTED | git.PushInfo.ERROR):
168
- print(f"Push failed for ref {info.local_ref}: {info.summary}")
169
- if info.summary.__contains__("remote rejected") and info.summary.__contains__(
170
- "is at") and info.summary.__contains__("but expected"):
171
- print("Remote rejected, trying to pull!")
172
- origin.fetch(self.repo.active_branch.name)
173
- origin.pull(self.repo.active_branch.name)
174
- # rebase if this fails.
175
- push_info = origin.push(self.repo.active_branch.name)
176
- for nested_info in push_info:
177
- if nested_info.flags & (git.PushInfo.REMOTE_REJECTED | git.PushInfo.ERROR):
178
- print(f"Push failed for ref {nested_info.local_ref}: {nested_info.summary}")
179
- return False
180
- return False
181
-
182
- print("Pushed to origin:", commit_message)
183
- return True
184
-
185
- except git.exc.GitCommandError as e:
186
- if "failed to push some refs" in e.stderr: # Check for the specific error
187
- self.repo.git.pull("origin", "main") # Pull changes from remote
188
- self.repo.git.push() # Retry the push
189
- else:
190
- print(f"Git error: {e}")
191
- raise e
192
-
193
- except Exception as e:
194
- print(f"Unexpected error: {e}")
195
- return False
196
-
197
- def update_changelog(self):
198
- source_file = Assets.changelog
199
- dest_file = GitStatics.website_repo_dir + os.path.sep + "_data" + os.path.sep + "changelogs.yaml"
200
- copyfile(source_file, dest_file)
201
- if self.due_changes():
202
- print("Updating the changelog to the website")
203
- self.git_push("Update Changelog")
204
- else:
205
- print("There is no changelog to update!")
206
-
207
- def update_config_changes(self, message):
208
- if self.due_changes():
209
- print(message)
210
- self.git_push(message, push_untracked_files=True)
211
- else:
212
- print("There is nothing to update!")
213
-
214
- def update_repo_changes(self, message):
215
- if self.due_changes():
216
- P.green(message)
217
- self.git_push(message, push_untracked_files=True)
218
- else:
219
- P.red("There is nothing to update!")
220
-
221
- def get_status(self, path):
222
- changed = [item.a_path for item in self.repo.index.diff(None)]
223
- if path in self.repo.untracked_files:
224
- return 'untracked'
225
- elif path in changed:
226
- return 'modified'
227
- else:
228
- return 'don''t care'
@@ -1,118 +0,0 @@
1
- import json
2
- from ..FileOp import FileOp
3
- from .Git import Git
4
- from .GitStatics import GitStatics
5
- from ..Statics import Statics
6
-
7
-
8
- class GitOperations:
9
-
10
- @staticmethod
11
- def setup_tracker_repo(fresh_clone=True):
12
- return GitOperations.setup_repo(GitStatics.tracker_repo_dir, GitStatics.tracker_repo_url, "main", fresh_clone)
13
-
14
- @staticmethod
15
- def setup_repo(repo_dir, repo_url, branch="main", fresh_clone=True, commit_depth=50):
16
- print()
17
- print("Repo Dir: " + repo_dir)
18
- repo = Git(repo_dir)
19
- result = repo.clone_repo(repo_url, branch=branch, fresh_clone=fresh_clone, commit_depth=commit_depth)
20
- return repo if result else None
21
-
22
- @staticmethod
23
- def clone_overlay_repo(android_version, fresh_clone=False, branch="main", source=False, enable_push=False):
24
- if float(android_version) > 12:
25
- overlay_source_dir = (Statics.pwd + Statics.dir_sep + f"overlays_{android_version}"
26
- + ("_source" if source else ""))
27
- overlay_source_repo = (("git@gitlab.com:nikgapps/" if enable_push else "https://gitlab.com/nikgapps/")
28
- + f"overlays_{android_version}"
29
- + ("_source" if source else "") + ".git")
30
- return GitOperations.setup_repo(overlay_source_dir, overlay_source_repo, branch, fresh_clone)
31
- else:
32
- print(f"Cloning Overlay repo not needed for android {android_version}")
33
- return None
34
-
35
- @staticmethod
36
- def clone_apk_repo(android_version, arch="arm64", fresh_clone=False, branch="main",
37
- cached=False, use_ssh_clone=False):
38
- arch = "" if arch == "arm64" else "_" + arch
39
- cache = "_cached" if cached else ""
40
- apk_source_directory = Statics.pwd + Statics.dir_sep + str(android_version) + arch + cache
41
- apk_source_repo = (GitStatics.apk_source_repo_ssh if use_ssh_clone else GitStatics.apk_source_repo) + str(
42
- android_version) + arch + cache + ".git"
43
- return GitOperations.setup_repo(apk_source_directory, apk_source_repo, branch, fresh_clone, commit_depth=1)
44
-
45
- # Following method is new method of cloning the apk source from Gitlab - based on release type
46
- @staticmethod
47
- def clone_apk_source(android_version, arch="arm64", release_type="stable", fresh_clone=False, cached=False,
48
- use_ssh_clone=False):
49
- url = f"{android_version}{('_' + arch if arch != 'arm64' else '')}_{release_type}"
50
- url = url + ("_cached" if cached else "")
51
- return GitOperations.clone_apk_url(url, fresh_clone, use_ssh_clone)
52
-
53
- @staticmethod
54
- def clone_apk_url(url, fresh_clone=False, use_ssh_clone=False):
55
- apk_source_directory = Statics.pwd + Statics.dir_sep + url
56
- apk_source_repo = ((GitStatics.apk_source_repo_ssh if use_ssh_clone else GitStatics.apk_source_repo) + url
57
- + ".git")
58
- return GitOperations.setup_repo(apk_source_directory, apk_source_repo, branch="main", fresh_clone=fresh_clone,
59
- commit_depth=1)
60
-
61
- @staticmethod
62
- def get_last_commit_date(branch, repo_dir=Statics.cwd, repo_url=None, android_version=None, use_ssh_clone=False):
63
- last_commit_datetime = None
64
- if android_version is not None:
65
- repository = GitOperations.clone_apk_repo(android_version, branch=branch, use_ssh_clone=use_ssh_clone)
66
- else:
67
- repository = Git(repo_dir)
68
- if repo_url is not None:
69
- repository.clone_repo(repo_url=repo_url, fresh_clone=False, branch=branch)
70
- if repository is not None:
71
- last_commit_datetime = repository.get_latest_commit_date(branch=branch)
72
- return last_commit_datetime
73
-
74
- @staticmethod
75
- def get_release_repo(release_type):
76
- release_repo = Git(GitStatics.release_history_dir)
77
- if not FileOp.dir_exists(GitStatics.release_history_dir):
78
- if release_type == "canary":
79
- GitStatics.release_repo_url = "git@github.com:nikgapps/canary-release.git"
80
- release_repo.clone_repo(GitStatics.release_repo_url, branch="master", commit_depth=50)
81
- if not FileOp.dir_exists(GitStatics.release_history_dir):
82
- print(GitStatics.release_history_dir + " doesn't exist!")
83
- return release_repo
84
-
85
- @staticmethod
86
- def get_website_repo_for_changelog(repo_dir=GitStatics.website_repo_dir, repo_url=GitStatics.website_repo_url,
87
- branch="main"):
88
- repo = Git(repo_dir)
89
- if repo_url is not None:
90
- repo.clone_repo(repo_url=repo_url, fresh_clone=False, branch=branch)
91
- if not FileOp.dir_exists(GitStatics.website_repo_dir):
92
- print(f"Repo {repo_dir} doesn't exist!")
93
- return repo
94
-
95
- @staticmethod
96
- def mark_a_release(android_version, release_type):
97
- tracker_repo = GitOperations.setup_tracker_repo(False)
98
- if tracker_repo is not None:
99
- release_tracker = tracker_repo.working_tree_dir + Statics.dir_sep + "release_tracker.json"
100
- decoded_hand = {}
101
- if FileOp.file_exists(release_tracker):
102
- with open(release_tracker, "r") as file:
103
- decoded_hand = json.load(file)
104
- if release_type not in decoded_hand:
105
- decoded_hand[release_type] = {}
106
- decoded_hand[release_type][android_version] = Statics.time
107
- else:
108
- decoded_hand[release_type] = {}
109
- decoded_hand[release_type][android_version] = Statics.time
110
- print(f"Marking a release with {decoded_hand}")
111
- with open(release_tracker, "w") as file:
112
- json.dump(decoded_hand, file, indent=2, sort_keys=True)
113
- if tracker_repo.due_changes():
114
- tracker_repo.git_push(
115
- f"Updated release_tracker.json with latest {release_type} release date: " + Statics.time,
116
- pull_first=True)
117
- else:
118
- print("No changes to commit!")
@@ -1,14 +0,0 @@
1
- from ..Statics import Statics
2
-
3
-
4
- class GitStatics:
5
- tracker_repo_url = "git@github.com:nikgapps/tracker.git"
6
- tracker_repo_dir = Statics.pwd + Statics.dir_sep + "tracker"
7
- apk_source_repo_ssh = f"git@gitlab.com:nikgapps/"
8
- apk_source_repo = f"https://gitlab.com/nikgapps/"
9
- release_repo_url = "git@github.com:nikgapps/release.git"
10
- release_history_dir = Statics.pwd + Statics.dir_sep + "release"
11
- website_repo_url = "git@github.com:nikgapps/nikgapps.github.io.git"
12
- website_repo_dir = Statics.pwd + Statics.dir_sep + "nikgapps.github.io"
13
- config_repo_dir = Statics.pwd + Statics.dir_sep + "config"
14
- config_repo_url = "git@github.com:nikgapps/config.git"
@@ -1,21 +0,0 @@
1
- from github import Github
2
-
3
-
4
- class GithubManager:
5
-
6
- def __init__(self, token):
7
- self.g = Github(token)
8
- self.user = self.g.get_user()
9
-
10
- def get_user(self):
11
- return self.g.get_user()
12
-
13
- def get_repos(self):
14
- return self.user.get_repos()
15
-
16
- def create_repo(self, repo_name):
17
- return self.user.create_repo(repo_name)
18
-
19
- @staticmethod
20
- def create_issue(repo, issue_title, issue_body):
21
- return repo.create_issue(title=issue_title, body=issue_body)