Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
pyporter
提交
f648ed39
P
pyporter
项目概览
openeuler
/
pyporter
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
pyporter
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
f648ed39
编写于
5月 25, 2020
作者:
M
myeuler
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refine code
上级
e0f8a4c0
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
46 addition
and
30 deletion
+46
-30
pyporter
pyporter
+46
-30
未找到文件。
pyporter
浏览文件 @
f648ed39
...
...
@@ -66,6 +66,21 @@ class PyPorter:
with
urllib
.
request
.
urlopen
(
url
)
as
u
:
self
.
__json
=
json
.
loads
(
u
.
read
().
decode
(
'utf-8'
))
def
get_spec_name
(
self
):
return
"python3-"
+
self
.
__json
[
"info"
][
"name"
]
+
".spec"
def
get_name
(
self
):
return
self
.
__json
[
"info"
][
"name"
]
def
get_version
(
self
):
return
self
.
__json
[
"info"
][
"version"
]
def
get_summary
(
self
):
return
self
.
__json
[
"info"
][
"summary"
]
def
get_home
(
self
):
return
self
.
__json
[
"info"
][
"project_urls"
][
"Homepage"
]
def
get_license
(
self
):
"""
By default, the license info can be achieved from json["info"]["license"]
...
...
@@ -111,13 +126,13 @@ class PyPorter:
return
ks
[
2
].
strip
()
return
""
def
get_buildarch
(
self
,
j
):
def
get_buildarch
(
self
):
"""
if this module has a prebuild package for amd64, then it is arch dependent.
print BuildArch tag if needed.
"""
v
=
j
[
"info"
][
"version"
]
rs
=
j
[
"releases"
][
v
]
v
=
self
.
__json
[
"info"
][
"version"
]
rs
=
self
.
__json
[
"releases"
][
v
]
for
r
in
rs
:
if
r
[
"packagetype"
]
==
"bdist_wheel"
:
if
r
[
"url"
].
find
(
"amd64"
)
!=
-
1
:
...
...
@@ -126,14 +141,14 @@ class PyPorter:
return
print
(
"BuildArch:
\t
noarch"
)
def
get_description
(
self
,
j
):
def
get_description
(
self
):
"""
return description.
Usually it's json["info"]["description"]
If it's rst style, then only use the content for the first paragraph, and remove all tag line.
For empty description, use summary instead.
"""
desc
=
j
[
"info"
][
"description"
].
splitlines
()
desc
=
self
.
__json
[
"info"
][
"description"
].
splitlines
()
res
=
[]
paragraph
=
0
for
d
in
desc
:
...
...
@@ -154,9 +169,9 @@ class PyPorter:
if
res
!=
[]:
return
"
\n
"
.
join
(
res
)
elif
paragraph
==
0
:
return
j
[
"info"
][
"description"
]
return
self
.
__json
[
"info"
][
"description"
]
else
:
return
j
[
"info"
][
"summary"
]
return
self
.
__json
[
"info"
][
"summary"
]
def
get_build_requires
():
req_list
=
[]
...
...
@@ -353,55 +368,56 @@ def build_rpm(j, rootpath):
return
""
def
build_spec
(
resp
,
output
):
def
build_reqs
(
porter
):
def
build_spec
(
porter
,
output
):
"""
print out the spec file
"""
if
os
.
path
.
isdir
(
output
):
output
=
os
.
path
.
join
(
output
,
"python3-"
+
resp
[
"info"
][
"name"
]
)
output
=
os
.
path
.
join
(
output
,
porter
.
get_spec_name
()
)
tmp
=
sys
.
stdout
if
(
output
==
""
):
print
()
else
:
if
(
output
!=
""
):
sys
.
stdout
=
open
(
output
,
'w+'
)
print
(
"%global _empty_manifest_terminate_build 0"
)
print
(
name_tag_template
.
format
(
pkg_name
=
resp
[
"info"
][
"name"
]
))
print
(
version_tag_template
.
format
(
pkg_ver
=
resp
[
"info"
][
"version"
]
))
print
(
name_tag_template
.
format
(
pkg_name
=
porter
.
get_name
()
))
print
(
version_tag_template
.
format
(
pkg_ver
=
porter
.
get_version
()
))
print
(
release_tag_template
)
print
(
summary_tag_template
.
format
(
pkg_sum
=
resp
[
"info"
][
"summary"
]
))
print
(
license_tag_template
.
format
(
pkg_lic
=
get_license
(
resp
)))
print
(
home_tag_template
.
format
(
pkg_home
=
resp
[
"info"
][
"project_urls"
][
"Homepage"
]
))
print
(
source_tag_template
.
format
(
pkg_source
=
get_source_url
(
resp
)))
get_buildarch
(
resp
)
print
(
summary_tag_template
.
format
(
pkg_sum
=
porter
.
get_summary
()
))
print
(
license_tag_template
.
format
(
pkg_lic
=
porter
.
get_license
(
)))
print
(
home_tag_template
.
format
(
pkg_home
=
porter
.
get_home
()
))
print
(
source_tag_template
.
format
(
pkg_source
=
porter
.
get_source_url
(
)))
porter
.
get_buildarch
(
)
print
(
""
)
get_requires
(
resp
)
porter
.
get_requires
(
)
print
(
""
)
print
(
"%description"
)
print
(
get_description
(
resp
))
print
(
porter
.
get_description
(
))
print
(
""
)
print
(
"%package -n python3-{name}"
.
format
(
name
=
resp
[
"info"
][
"name"
]))
print
(
summary_tag_template
.
format
(
pkg_sum
=
resp
[
"info"
][
"summary"
]))
print
(
"Provides:
\t
python-"
+
resp
[
"info"
][
"name"
])
print
(
buildreq_tag_template
.
format
(
req
=
'python3-devel'
))
print
(
buildreq_tag_template
.
format
(
req
=
'python3-setuptools'
))
if
build_noarch
==
False
:
print
(
buildreq_tag_template
.
format
(
req
=
'python3-cffi'
))
print
(
buildreq_tag_template
.
format
(
req
=
'gcc'
))
print
(
buildreq_tag_template
.
format
(
req
=
'gdb'
))
build_req_list
=
get_build_requires
(
resp
)
build_req_list
=
porter
.
get_build_requires
(
)
print
(
"%description -n python3-"
+
resp
[
"info"
][
"name"
])
print
(
get_description
(
resp
))
print
(
get_description
())
print
(
""
)
print
(
"%package help"
)
print
(
"Summary:
\t
Development documents and examples for {name}"
.
format
(
name
=
resp
[
"info"
][
"name"
]))
print
(
"Provides:
\t
python3-{name}-doc"
.
format
(
name
=
resp
[
"info"
][
"name"
]))
print
(
"%description help"
)
print
(
get_description
(
resp
))
print
(
get_description
())
print
(
""
)
print
(
"%prep"
)
print
(
"%autosetup -n {name}-{ver}"
.
format
(
name
=
resp
[
"info"
][
"name"
],
ver
=
resp
[
"info"
][
"version"
]))
...
...
@@ -509,23 +525,23 @@ if __name__ == "__main__":
sys
.
exit
(
0
)
if
(
args
.
spec
):
build_spec
(
response
,
args
.
output
)
build_spec
(
porter
,
args
.
output
)
if
(
args
.
build
):
ret
=
build_rpm
(
response
,
args
.
rootpath
)
ret
=
build_rpm
(
porter
,
args
.
rootpath
)
if
ret
!=
""
:
print
(
"build failed : BuildRequire : %s
\n
"
%
ret
)
sys
.
exit
(
1
)
if
(
args
.
buildinstall
):
ret
=
build_install_rpm
(
response
,
args
.
rootpath
)
ret
=
build_install_rpm
(
porter
,
args
.
rootpath
)
if
ret
!=
""
:
print
(
"Build & install failed
\n
"
)
sys
.
exit
(
1
)
if
(
args
.
download
):
download_source
(
response
,
args
.
path
)
download_source
(
porter
,
args
.
path
)
if
(
args
.
json
):
store_json
(
response
,
args
.
pkg
,
args
.
path
)
store_json
(
porter
,
args
.
pkg
,
args
.
path
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录