python3-openEuler 0.0.3__tar.gz → 0.0.4__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.4}/PKG-INFO +1 -1
- {python3_openeuler-0.0.3 → python3_openeuler-0.0.4}/openEuler/openEuler.py +78 -1
- {python3_openeuler-0.0.3 → python3_openeuler-0.0.4}/python3_openEuler.egg-info/PKG-INFO +1 -1
- {python3_openeuler-0.0.3 → python3_openeuler-0.0.4}/setup.py +1 -1
- {python3_openeuler-0.0.3 → python3_openeuler-0.0.4}/LICENSE +0 -0
- {python3_openeuler-0.0.3 → python3_openeuler-0.0.4}/README.md +0 -0
- {python3_openeuler-0.0.3 → python3_openeuler-0.0.4}/openEuler/__init__.py +0 -0
- {python3_openeuler-0.0.3 → python3_openeuler-0.0.4}/python3_openEuler.egg-info/SOURCES.txt +0 -0
- {python3_openeuler-0.0.3 → python3_openeuler-0.0.4}/python3_openEuler.egg-info/dependency_links.txt +0 -0
- {python3_openeuler-0.0.3 → python3_openeuler-0.0.4}/python3_openEuler.egg-info/requires.txt +0 -0
- {python3_openeuler-0.0.3 → python3_openeuler-0.0.4}/python3_openEuler.egg-info/top_level.txt +0 -0
- {python3_openeuler-0.0.3 → python3_openeuler-0.0.4}/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,81 @@ 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
|
+
original_value = value
|
|
151
|
+
while True:
|
|
152
|
+
for key, val in macros.items():
|
|
153
|
+
value = re.sub(r'%\{' + re.escape(key) + r'\}', val, value)
|
|
154
|
+
if value == original_value:
|
|
155
|
+
break
|
|
156
|
+
original_value = value
|
|
157
|
+
return value
|
|
158
|
+
|
|
159
|
+
def __extract_macros(self,spec):
|
|
160
|
+
macros = {}
|
|
161
|
+
for key, value in spec.macros.items():
|
|
162
|
+
macros[key] = value
|
|
163
|
+
if "name" not in macros.keys():
|
|
164
|
+
macros['name'] = spec.name
|
|
165
|
+
if "version" not in macros.keys():
|
|
166
|
+
macros['version'] = spec.version
|
|
167
|
+
if "release" not in macros.keys():
|
|
168
|
+
macros['release'] = spec.release
|
|
169
|
+
for k, w in DEFAULT_MACROS.items():
|
|
170
|
+
if k not in macros.keys():
|
|
171
|
+
macros[k] = w
|
|
172
|
+
return macros
|
|
173
|
+
|
|
174
|
+
def __get_spec_files(self,root_path):
|
|
175
|
+
spec_files = []
|
|
176
|
+
for elem in Path(root_path).glob("**/*"):
|
|
177
|
+
if Path(elem).is_file() and elem.name.endswith(".spec"):
|
|
178
|
+
spec_files.append(elem)
|
|
179
|
+
return spec_files
|
|
180
|
+
|
|
181
|
+
def __get_rpm_list_from_spec(self,spec_file):
|
|
182
|
+
"""从 RPM spec 文件中提取所有包名并替换宏。"""
|
|
183
|
+
spec = Spec.from_file(spec_file)
|
|
184
|
+
rpm_list = []
|
|
185
|
+
macros = self.__extract_macros(spec)
|
|
186
|
+
|
|
187
|
+
# 提取子包名称
|
|
188
|
+
for pkg in spec.packages:
|
|
189
|
+
subpackage_name = self.__replace_macros(pkg.name, macros)
|
|
190
|
+
if subpackage_name not in rpm_list:
|
|
191
|
+
if "%" in subpackage_name:
|
|
192
|
+
log.warning(f"{subpackage_name} contains macro, please check")
|
|
193
|
+
else:
|
|
194
|
+
rpm_list.append(subpackage_name)
|
|
195
|
+
|
|
196
|
+
return rpm_list
|
|
197
|
+
|
|
198
|
+
def get_openEuler_rpm_names_from_repo(self,os_version,repo_name,repo_url):
|
|
199
|
+
branch=f"openEuler-{os_version}"
|
|
200
|
+
rpm_list = []
|
|
201
|
+
with tempfile.TemporaryDirectory() as temp_dir:
|
|
202
|
+
git.Repo.clone_from(repo_url, temp_dir, branch=branch, depth=1)
|
|
203
|
+
log.info(f"clone {repo_name} success")
|
|
204
|
+
spec_files = self.__get_spec_files(temp_dir)
|
|
205
|
+
|
|
206
|
+
for spec_file in spec_files:
|
|
207
|
+
temp_list = self.__get_rpm_list_from_spec(spec_file)
|
|
208
|
+
for elem in temp_list:
|
|
209
|
+
if elem not in rpm_list:
|
|
210
|
+
rpm_list.append(elem)
|
|
211
|
+
return rpm_list
|
|
212
|
+
|
|
138
213
|
def get_openEuler_repo_names_and_urls(
|
|
139
214
|
self,
|
|
140
215
|
os_version: str
|
|
@@ -244,7 +319,9 @@ class OpenEuler():
|
|
|
244
319
|
|
|
245
320
|
if __name__ == "__main__":
|
|
246
321
|
# 初始化获取器
|
|
247
|
-
|
|
322
|
+
oe = OpenEuler()
|
|
323
|
+
for rpm in oe.get_openEuler_rpm_names_from_repo("24.03-LTS-SP2", "python-minio","https://gitee.com/src-openeuler/python-minio.git"):
|
|
324
|
+
print(f"src_name:python-minio,rpm:{rpm}")
|
|
248
325
|
# log.info("正在初始化 Gitee 模块...")
|
|
249
326
|
# repos_generator = oe.get_openEuler_repo_names_and_urls(
|
|
250
327
|
# 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.4}/python3_openEuler.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
{python3_openeuler-0.0.3 → python3_openeuler-0.0.4}/python3_openEuler.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|