python3-openEuler 0.0.3__tar.gz → 0.0.5__tar.gz
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.
Potentially problematic release.
This version of python3-openEuler might be problematic. Click here for more details.
- {python3_openeuler-0.0.3 → python3_openeuler-0.0.5}/PKG-INFO +1 -1
- {python3_openeuler-0.0.3 → python3_openeuler-0.0.5}/openEuler/openEuler.py +81 -1
- {python3_openeuler-0.0.3 → python3_openeuler-0.0.5}/python3_openEuler.egg-info/PKG-INFO +1 -1
- {python3_openeuler-0.0.3 → python3_openeuler-0.0.5}/setup.py +1 -1
- {python3_openeuler-0.0.3 → python3_openeuler-0.0.5}/LICENSE +0 -0
- {python3_openeuler-0.0.3 → python3_openeuler-0.0.5}/README.md +0 -0
- {python3_openeuler-0.0.3 → python3_openeuler-0.0.5}/openEuler/__init__.py +0 -0
- {python3_openeuler-0.0.3 → python3_openeuler-0.0.5}/python3_openEuler.egg-info/SOURCES.txt +0 -0
- {python3_openeuler-0.0.3 → python3_openeuler-0.0.5}/python3_openEuler.egg-info/dependency_links.txt +0 -0
- {python3_openeuler-0.0.3 → python3_openeuler-0.0.5}/python3_openEuler.egg-info/requires.txt +0 -0
- {python3_openeuler-0.0.3 → python3_openeuler-0.0.5}/python3_openEuler.egg-info/top_level.txt +0 -0
- {python3_openeuler-0.0.3 → python3_openeuler-0.0.5}/setup.cfg +0 -0
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import re
|
|
2
2
|
import logging
|
|
3
|
+
import tempfile
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from pyrpm.spec import Spec
|
|
6
|
+
import git
|
|
3
7
|
import requests
|
|
4
8
|
from bs4 import BeautifulSoup
|
|
5
9
|
import traceback
|
|
@@ -131,10 +135,84 @@ class Gitee():
|
|
|
131
135
|
log.error(f"request url is {url}, parameters is {parameters},headers is {headers} failed, response status code is {response.status_code}")
|
|
132
136
|
break
|
|
133
137
|
|
|
138
|
+
|
|
139
|
+
DEFAULT_MACROS = {
|
|
140
|
+
"python3_pkgversion": '3.9',
|
|
141
|
+
"lustre_name":"lustre"
|
|
142
|
+
}
|
|
143
|
+
|
|
134
144
|
class OpenEuler():
|
|
135
145
|
def __init__(self):
|
|
136
146
|
pass
|
|
137
147
|
|
|
148
|
+
def __replace_macros(self,value, macros):
|
|
149
|
+
"""根据宏字典替换字符串中的宏."""
|
|
150
|
+
if not macros:
|
|
151
|
+
return value
|
|
152
|
+
|
|
153
|
+
# 预编译所有宏的正则表达式,提升效率
|
|
154
|
+
patterns = [
|
|
155
|
+
(re.compile(re.escape(key)), val)
|
|
156
|
+
for key, val in macros.items()
|
|
157
|
+
]
|
|
158
|
+
|
|
159
|
+
prev_value = None
|
|
160
|
+
current_value = value
|
|
161
|
+
# 循环替换直到无变化(处理嵌套宏)
|
|
162
|
+
while current_value != prev_value:
|
|
163
|
+
prev_value = current_value
|
|
164
|
+
for pattern, replacement in patterns:
|
|
165
|
+
current_value = pattern.sub(replacement, current_value)
|
|
166
|
+
return current_value
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def __extract_macros(self,spec):
|
|
170
|
+
macros = dict(spec.macros)
|
|
171
|
+
|
|
172
|
+
# 补充必要的默认宏(若不存在)
|
|
173
|
+
macros.setdefault("name", spec.name)
|
|
174
|
+
macros.setdefault("version", spec.version)
|
|
175
|
+
macros.setdefault("release", spec.release)
|
|
176
|
+
|
|
177
|
+
# 补充全局默认宏(若不存在)
|
|
178
|
+
for key, default_val in DEFAULT_MACROS.items():
|
|
179
|
+
macros.setdefault(key, default_val)
|
|
180
|
+
|
|
181
|
+
return macros
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
def __get_rpm_list_from_spec(self,spec_file):
|
|
185
|
+
"""从 RPM spec 文件中提取所有包名并替换宏。"""
|
|
186
|
+
spec = Spec.from_file(spec_file)
|
|
187
|
+
rpm_list = []
|
|
188
|
+
macros = self.__extract_macros(spec)
|
|
189
|
+
|
|
190
|
+
# 提取子包名称
|
|
191
|
+
for pkg in spec.packages:
|
|
192
|
+
subpackage_name = self.__replace_macros(pkg.name, macros)
|
|
193
|
+
if subpackage_name not in rpm_list:
|
|
194
|
+
if "%" in subpackage_name:
|
|
195
|
+
log.warning(f"{subpackage_name} contains macro, please check")
|
|
196
|
+
else:
|
|
197
|
+
rpm_list.append(subpackage_name)
|
|
198
|
+
|
|
199
|
+
return rpm_list
|
|
200
|
+
|
|
201
|
+
def get_openEuler_rpm_names_from_repo(self,os_version,repo_name,repo_url):
|
|
202
|
+
branch=f"openEuler-{os_version}"
|
|
203
|
+
rpm_list = []
|
|
204
|
+
with tempfile.TemporaryDirectory() as temp_dir:
|
|
205
|
+
git.Repo.clone_from(repo_url, temp_dir, branch=branch, depth=1)
|
|
206
|
+
log.info(f"clone {repo_name} success")
|
|
207
|
+
spec_files = list(Path(temp_dir).rglob("*.spec"))
|
|
208
|
+
|
|
209
|
+
for spec_file in spec_files:
|
|
210
|
+
temp_list = self.__get_rpm_list_from_spec(spec_file)
|
|
211
|
+
for elem in temp_list:
|
|
212
|
+
if elem not in rpm_list:
|
|
213
|
+
rpm_list.append(elem)
|
|
214
|
+
return rpm_list
|
|
215
|
+
|
|
138
216
|
def get_openEuler_repo_names_and_urls(
|
|
139
217
|
self,
|
|
140
218
|
os_version: str
|
|
@@ -244,7 +322,9 @@ class OpenEuler():
|
|
|
244
322
|
|
|
245
323
|
if __name__ == "__main__":
|
|
246
324
|
# 初始化获取器
|
|
247
|
-
|
|
325
|
+
oe = OpenEuler()
|
|
326
|
+
for rpm in oe.get_openEuler_rpm_names_from_repo("24.03-LTS-SP2", "python-minio","https://gitee.com/src-openeuler/python-minio.git"):
|
|
327
|
+
print(f"src_name:python-minio,rpm:{rpm}")
|
|
248
328
|
# log.info("正在初始化 Gitee 模块...")
|
|
249
329
|
# repos_generator = oe.get_openEuler_repo_names_and_urls(
|
|
250
330
|
# os_version="24.03-LTS-SP2"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python3_openeuler-0.0.3 → python3_openeuler-0.0.5}/python3_openEuler.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
{python3_openeuler-0.0.3 → python3_openeuler-0.0.5}/python3_openEuler.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|