Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
openEuler-Advisor
提交
c3d2cc3b
O
openEuler-Advisor
项目概览
openeuler
/
openEuler-Advisor
通知
36
Star
4
Fork
4
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
openEuler-Advisor
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c3d2cc3b
编写于
5月 09, 2020
作者:
S
Shinwell_Hu
提交者:
Gitee
5月 09, 2020
浏览文件
操作
浏览文件
下载
差异文件
!4 fix more issue
Merge pull request !4 from myeuler/master
上级
8da7cfe3
2a5730be
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
62 addition
and
38 deletion
+62
-38
packager/python-packager.py
packager/python-packager.py
+62
-38
未找到文件。
packager/python-packager.py
浏览文件 @
c3d2cc3b
...
@@ -114,7 +114,12 @@ def get_requires(j):
...
@@ -114,7 +114,12 @@ def get_requires(j):
idx
=
r
.
find
(
";"
)
idx
=
r
.
find
(
";"
)
mod
=
transform_module_name
(
r
[:
idx
])
mod
=
transform_module_name
(
r
[:
idx
])
if
mod
!=
""
:
if
mod
!=
""
:
print
(
"Requires:
\t
"
+
mod
)
#print ("Requires:\t" + mod)
#
# have to remover version info because sometime the version info like
# <0.3 can not be recogonized by rpmbuild
#
print
(
"Requires:
\t
"
+
mod
.
lstrip
().
split
(
" "
)[
0
])
def
refine_requires
(
req
):
def
refine_requires
(
req
):
...
@@ -124,11 +129,29 @@ def refine_requires(req):
...
@@ -124,11 +129,29 @@ def refine_requires(req):
ra
=
req
.
split
(
";"
,
1
)
ra
=
req
.
split
(
";"
,
1
)
#
#
# Do not add requires which has ;, which is often has very complicated precondition
# Do not add requires which has ;, which is often has very complicated precondition
#
#
TODO: need more parsing of the denpency after ;
if
(
len
(
ra
)
>=
2
):
#
if (len(ra) >= 2):
return
""
#
return ""
return
transform_module_name
(
ra
[
0
])
return
transform_module_name
(
ra
[
0
])
def
get_build_requires
(
resp
):
req_list
=
[]
rds
=
resp
[
"info"
][
"requires_dist"
]
if
rds
is
not
None
:
for
rp
in
rds
:
br
=
refine_requires
(
rp
)
if
(
br
==
""
):
continue
#
# Do not output BuildRequires:
# just collect all build requires and using pip to install
# than can help to build all rpm withoud trap into
# build dependency nightmare
#
#print(buildreq_tag_template.format(req=br))
name
=
str
.
lstrip
(
br
).
split
(
" "
)
req_list
.
append
(
name
[
0
])
return
req_list
def
get_buildarch
(
j
):
def
get_buildarch
(
j
):
"""
"""
...
@@ -226,29 +249,15 @@ def prepare_rpm_build_env(buildroot):
...
@@ -226,29 +249,15 @@ def prepare_rpm_build_env(buildroot):
print
(
"Build Root path %s does not exist
\n
"
,
buildroot
)
print
(
"Build Root path %s does not exist
\n
"
,
buildroot
)
return
False
return
False
bpath
=
os
.
path
.
join
(
buildroot
,
"SPECS"
)
for
sdir
in
[
'SPECS'
,
'BUILD'
,
'SOURCES'
,
'SRPMS'
,
'RPMS'
,
'BUILDROOT'
]:
if
(
os
.
path
.
exists
(
bpath
)
==
False
):
bpath
=
os
.
path
.
join
(
buildroot
,
sdir
)
os
.
mkdir
(
bpath
)
if
(
os
.
path
.
exists
(
bpath
)
==
False
):
bpath
=
os
.
path
.
join
(
buildroot
,
"BUILD"
)
os
.
mkdir
(
bpath
)
if
(
os
.
path
.
exists
(
bpath
)
==
False
):
os
.
mkdir
(
bpath
)
bpath
=
os
.
path
.
join
(
buildroot
,
"SOURCES"
)
if
(
os
.
path
.
exists
(
bpath
)
==
False
):
os
.
mkdir
(
bpath
)
bpath
=
os
.
path
.
join
(
buildroot
,
"SRPMS"
)
if
(
os
.
path
.
exists
(
bpath
)
==
False
):
os
.
mkdir
(
bpath
)
bpath
=
os
.
path
.
join
(
buildroot
,
"RPMS"
)
if
(
os
.
path
.
exists
(
bpath
)
==
False
):
os
.
mkdir
(
bpath
)
bpath
=
os
.
path
.
join
(
buildroot
,
"BUILDROOT"
)
if
(
os
.
path
.
exists
(
bpath
)
==
False
):
os
.
mkdir
(
bpath
)
return
True
return
True
def
installed
_package
(
pkg
):
def
try_install
_package
(
pkg
):
"""
"""
install packages listed in build requires
install packages listed in build requires
"""
"""
...
@@ -256,8 +265,27 @@ def installed_package(pkg):
...
@@ -256,8 +265,27 @@ def installed_package(pkg):
ret
=
subprocess
.
call
([
"rpm"
,
"-qi"
,
pkg
])
ret
=
subprocess
.
call
([
"rpm"
,
"-qi"
,
pkg
])
if
ret
==
0
:
if
ret
==
0
:
return
True
return
True
return
False
# try pip installation
pip_name
=
pkg
.
split
(
"-"
)
if
len
(
pip_name
)
==
2
:
ret
=
subprocess
.
call
([
"pip3"
,
"install"
,
"--user"
,
pip_name
[
1
]])
else
:
ret
=
subprocess
.
call
([
"pip3"
,
"install"
,
"--user"
,
pip_name
[
0
]])
if
ret
!=
0
:
print
(
"%s can not be installed correctly, Fix it later, go ahead to do building..."
%
pip_name
)
#
# TODO: try to build anyway, fix it later
#
return
True
def
prepare_dependencies
(
req_list
):
for
req
in
req_list
:
if
(
try_install_package
(
req
)
==
False
):
return
req
return
""
def
build_package
(
specfile
):
def
build_package
(
specfile
):
"""
"""
...
@@ -267,6 +295,7 @@ def build_package(specfile):
...
@@ -267,6 +295,7 @@ def build_package(specfile):
return
ret
return
ret
def
build_rpm
(
resp
,
buildroot
):
def
build_rpm
(
resp
,
buildroot
):
"""
"""
full process to build rpm
full process to build rpm
...
@@ -275,10 +304,12 @@ def build_rpm(resp, buildroot):
...
@@ -275,10 +304,12 @@ def build_rpm(resp, buildroot):
return
False
return
False
specfile
=
os
.
path
.
join
(
buildroot
,
"SPECS"
,
"python-"
+
resp
[
"info"
][
"name"
]
+
".spec"
)
specfile
=
os
.
path
.
join
(
buildroot
,
"SPECS"
,
"python-"
+
resp
[
"info"
][
"name"
]
+
".spec"
)
req_list
=
build_spec
(
resp
,
specfile
)
req_list
=
build_spec
(
resp
,
specfile
)
for
req
in
req_list
:
ret
=
prepare_dependencies
(
req_list
)
if
(
installed_package
(
req
)
==
False
):
if
ret
!=
""
:
return
req
print
(
"%s can not be installed automatically, Please handle it"
%
ret
)
return
ret
download_source
(
resp
,
os
.
path
.
join
(
buildroot
,
"SOURCES"
))
download_source
(
resp
,
os
.
path
.
join
(
buildroot
,
"SOURCES"
))
...
@@ -291,6 +322,8 @@ def build_spec(resp, output):
...
@@ -291,6 +322,8 @@ def build_spec(resp, output):
"""
"""
print out the spec file
print out the spec file
"""
"""
if
os
.
path
.
isdir
(
output
):
output
=
os
.
path
.
join
(
output
,
"python3-"
+
resp
[
"info"
][
"name"
])
tmp
=
sys
.
stdout
tmp
=
sys
.
stdout
if
(
output
==
""
):
if
(
output
==
""
):
print
()
print
()
...
@@ -323,16 +356,7 @@ def build_spec(resp, output):
...
@@ -323,16 +356,7 @@ def build_spec(resp, output):
print
(
buildreq_tag_template
.
format
(
req
=
'gdb'
))
print
(
buildreq_tag_template
.
format
(
req
=
'gdb'
))
req_list
=
[]
build_req_list
=
get_build_requires
(
resp
)
rds
=
resp
[
"info"
][
"requires_dist"
]
if
rds
is
not
None
:
for
rp
in
rds
:
br
=
refine_requires
(
rp
)
if
(
br
==
""
):
continue
print
(
buildreq_tag_template
.
format
(
req
=
br
))
name
=
str
.
lstrip
(
br
).
split
(
" "
)
req_list
.
append
(
name
[
0
])
print
(
"%description -n python3-"
+
resp
[
"info"
][
"name"
])
print
(
"%description -n python3-"
+
resp
[
"info"
][
"name"
])
print
(
get_description
(
resp
))
print
(
get_description
(
resp
))
...
@@ -392,7 +416,7 @@ def build_spec(resp, output):
...
@@ -392,7 +416,7 @@ def build_spec(resp, output):
sys
.
stdout
=
tmp
sys
.
stdout
=
tmp
return
req_list
return
build_
req_list
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录