Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
avocado
提交
5a6ae99f
A
avocado
项目概览
openeuler
/
avocado
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
avocado
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5a6ae99f
编写于
2月 04, 2016
作者:
L
Lucas Meneghel Rodrigues
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1002 from ldoktor/sudo
avocado.utils.software_manager: Bugfixes and cleanups
上级
aea36d71
acc07362
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
43 addition
and
34 deletion
+43
-34
avocado/utils/software_manager.py
avocado/utils/software_manager.py
+43
-34
未找到文件。
avocado/utils/software_manager.py
浏览文件 @
5a6ae99f
...
...
@@ -207,10 +207,7 @@ class RpmBackend(BaseBackend):
if
'not installed'
in
inst_version
:
return
False
if
inst_version
>=
version
:
return
True
else
:
return
False
return
bool
(
inst_version
>=
version
)
def
check_installed
(
self
,
name
,
version
=
None
,
arch
=
None
):
"""
...
...
@@ -367,7 +364,7 @@ class YumBackend(RpmBackend):
verbose
=
False
,
shell
=
True
)
out
=
cmd_result
.
stdout
.
strip
()
try
:
ver
=
re
.
findall
(
'\d*.\d*.\d*'
,
out
)[
0
]
ver
=
re
.
findall
(
r
'\d*.\d*.\d*'
,
out
)[
0
]
except
IndexError
:
ver
=
out
self
.
pm_version
=
ver
...
...
@@ -435,12 +432,15 @@ class YumBackend(RpmBackend):
self
.
cfgparser
.
set
(
section_name
,
'name'
,
'Avocado managed repository'
)
self
.
cfgparser
.
set
(
section_name
,
'url'
,
url
)
self
.
cfgparser
.
set
(
section_name
,
'enabled'
,
1
)
self
.
cfgparser
.
set
(
section_name
,
'gpgcheck'
,
0
)
tmp_file_repo
=
tempfile
.
mktemp
(
prefix
=
'avocado_software_manager'
)
self
.
cfgparser
.
write
(
open
(
tmp_file_repo
,
"w"
))
process
.
system
(
'mv %s %s'
%
(
tmp_file_repo
,
self
.
repo_file_path
),
sudo
=
True
)
self
.
cfgparser
.
set
(
section_name
,
'enabled'
,
'1'
)
self
.
cfgparser
.
set
(
section_name
,
'gpgcheck'
,
'0'
)
prefix
=
'avocado_software_manager'
with
tempfile
.
NamedTemporaryFile
(
"w"
,
prefix
=
prefix
)
as
tmp_file
:
self
.
cfgparser
.
write
(
tmp_file
)
tmp_file
.
flush
()
# Sync the content
process
.
system
(
'cp %s %s'
%
(
tmp_file
.
name
,
self
.
repo_file_path
),
sudo
=
True
)
return
True
except
(
OSError
,
process
.
CmdError
),
details
:
log
.
error
(
details
)
...
...
@@ -453,15 +453,18 @@ class YumBackend(RpmBackend):
:param url: Universal Resource Locator of the repository.
"""
try
:
tmp_file_repo
=
tempfile
.
mktemp
(
prefix
=
'avocado_software_manager'
)
for
section
in
self
.
cfgparser
.
sections
():
for
option
,
value
in
self
.
cfgparser
.
items
(
section
):
if
option
==
'url'
and
value
==
url
:
self
.
cfgparser
.
remove_section
(
section
)
self
.
cfgparser
.
write
(
open
(
tmp_file_repo
,
"w"
))
process
.
system
(
'mv %s %s'
%
(
tmp_file_repo
,
self
.
repo_file_path
),
sudo
=
True
)
return
True
prefix
=
'avocado_software_manager'
with
tempfile
.
NamedTemporaryFile
(
"w"
,
prefix
=
prefix
)
as
tmp_file
:
for
section
in
self
.
cfgparser
.
sections
():
for
option
,
value
in
self
.
cfgparser
.
items
(
section
):
if
option
==
'url'
and
value
==
url
:
self
.
cfgparser
.
remove_section
(
section
)
self
.
cfgparser
.
write
(
tmp_file
.
file
)
tmp_file
.
flush
()
# Sync the content
process
.
system
(
'cp %s %s'
%
(
tmp_file
.
name
,
self
.
repo_file_path
),
sudo
=
True
)
return
True
except
(
OSError
,
process
.
CmdError
),
details
:
log
.
error
(
details
)
return
False
...
...
@@ -498,9 +501,9 @@ class YumBackend(RpmBackend):
return
None
try
:
d_provides
=
self
.
yum_base
.
searchPackageProvides
(
args
=
[
name
])
except
Exception
,
e
:
except
Exception
,
e
xc
:
log
.
error
(
"Error searching for package that "
"provides %s: %s"
,
name
,
e
)
"provides %s: %s"
,
name
,
e
xc
)
d_provides
=
[]
provides_list
=
[
key
for
key
in
d_provides
]
...
...
@@ -668,19 +671,20 @@ class AptBackend(DpkgBackend):
executable
=
utils_path
.
find_command
(
'apt-get'
)
self
.
base_command
=
executable
+
' --yes --allow-unauthenticated'
self
.
repo_file_path
=
'/etc/apt/sources.list.d/avocado.list'
self
.
dpkg_force_confdef
=
'-o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold"'
self
.
dpkg_force_confdef
=
(
'-o Dpkg::Options::="--force-confdef" '
'-o Dpkg::Options::="--force-confold"'
)
cmd_result
=
process
.
run
(
'apt-get -v | head -1'
,
ignore_status
=
True
,
verbose
=
False
,
shell
=
True
)
out
=
cmd_result
.
stdout
.
strip
()
try
:
ver
=
re
.
findall
(
'\d\S*'
,
out
)[
0
]
ver
=
re
.
findall
(
r
'\d\S*'
,
out
)[
0
]
except
IndexError
:
ver
=
out
self
.
pm_version
=
ver
log
.
debug
(
'apt-get version: %s'
%
self
.
pm_version
)
log
.
debug
(
'apt-get version: %s'
,
self
.
pm_version
)
# gdebi-core is necessary for local installation with dependency
# handling
if
not
self
.
check_installed
(
'gdebi-core'
):
...
...
@@ -700,7 +704,8 @@ class AptBackend(DpkgBackend):
i_cmd
=
utils_path
.
find_command
(
'gdebi'
)
+
' -n -q '
+
name
else
:
command
=
'install'
i_cmd
=
" "
.
join
([
self
.
base_command
,
self
.
dpkg_force_confdef
,
command
,
name
])
i_cmd
=
" "
.
join
([
self
.
base_command
,
self
.
dpkg_force_confdef
,
command
,
name
])
try
:
process
.
system
(
i_cmd
,
shell
=
True
,
sudo
=
True
)
...
...
@@ -752,14 +757,16 @@ class AptBackend(DpkgBackend):
new_file_contents
=
[]
with
open
(
self
.
repo_file_path
,
'r'
)
as
repo_file
:
for
line
in
repo_file
.
readlines
():
if
not
line
=
=
repo
:
if
line
!
=
repo
:
new_file_contents
.
append
(
line
)
new_file_contents
=
"
\n
"
.
join
(
new_file_contents
)
tmp_file_repo
=
tempfile
.
mktemp
(
prefix
=
'avocado_software_manager'
)
with
open
(
tmp_file_repo
,
'w'
)
as
tmp_file_repo
:
tmp_file_repo
.
write
(
new_file_contents
)
process
.
system
(
'mv %s %s'
%
(
tmp_file_repo
,
self
.
repo_file_path
),
sudo
=
True
)
prefix
=
"avocado_software_manager"
with
tempfile
.
NamedTemporaryFile
(
"w"
,
prefix
=
prefix
)
as
tmp_file
:
tmp_file
.
write
(
new_file_contents
)
tmp_file
.
flush
()
# Sync the content
process
.
system
(
'cp %s %s'
%
(
tmp_file
.
name
,
self
.
repo_file_path
),
sudo
=
True
)
except
(
OSError
,
process
.
CmdError
),
details
:
log
.
error
(
details
)
return
False
...
...
@@ -782,10 +789,12 @@ class AptBackend(DpkgBackend):
if
name
:
up_command
=
'install --only-upgrade'
up_cmd
=
" "
.
join
([
self
.
base_command
,
self
.
dpkg_force_confdef
,
up_command
,
name
])
up_cmd
=
" "
.
join
([
self
.
base_command
,
self
.
dpkg_force_confdef
,
up_command
,
name
])
else
:
up_command
=
'upgrade'
up_cmd
=
" "
.
join
([
self
.
base_command
,
self
.
dpkg_force_confdef
,
up_command
])
up_cmd
=
" "
.
join
([
self
.
base_command
,
self
.
dpkg_force_confdef
,
up_command
])
try
:
process
.
system
(
up_cmd
,
shell
=
True
,
sudo
=
True
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录