Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
avocado
提交
3d39de31
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,发现更多精彩内容 >>
未验证
提交
3d39de31
编写于
3月 26, 2018
作者:
C
Cleber Rosa
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'tambewilliam/extend_kernel_py_v2'
Signed-off-by:
N
Cleber Rosa
<
crosa@redhat.com
>
上级
99c4d6d8
52ea978e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
49 addition
and
13 deletion
+49
-13
avocado/utils/kernel.py
avocado/utils/kernel.py
+38
-10
examples/tests/linuxbuild.py
examples/tests/linuxbuild.py
+7
-3
examples/tests/linuxbuild.py.data/linuxbuild.yaml
examples/tests/linuxbuild.py.data/linuxbuild.yaml
+4
-0
未找到文件。
avocado/utils/kernel.py
浏览文件 @
3d39de31
...
...
@@ -19,7 +19,7 @@ import logging
import
tempfile
from
distutils.version
import
LooseVersion
# pylint: disable=E0611
from
.
import
asset
,
archive
,
build
from
.
import
asset
,
archive
,
build
,
distro
,
process
log
=
logging
.
getLogger
(
'avocado.test'
)
...
...
@@ -46,6 +46,7 @@ class KernelBuild(object):
"""
self
.
version
=
version
self
.
config_path
=
config_path
self
.
distro
=
distro
.
detect
()
if
work_dir
is
None
:
work_dir
=
tempfile
.
mkdtemp
(
prefix
=
'avocado_'
+
__name__
)
self
.
work_dir
=
work_dir
...
...
@@ -62,13 +63,21 @@ class KernelBuild(object):
self
.
config_path
,
self
.
work_dir
)
def
download
(
self
):
def
download
(
self
,
url
=
None
):
"""
Download kernel source.
:param url: override the url from where to fetch the kernel
source tarball
:type url: str or None
"""
self
.
kernel_file
=
self
.
SOURCE
.
format
(
version
=
self
.
version
)
base_url
=
self
.
URL
.
format
(
major
=
self
.
version
.
split
(
'.'
,
1
)[
0
])
full_url
=
base_url
+
self
.
kernel_file
kernel_file
=
self
.
SOURCE
.
format
(
version
=
self
.
version
)
if
url
is
not
None
:
base_url
=
self
.
URL
.
format
(
major
=
self
.
version
.
split
(
'.'
,
1
)[
0
])
else
:
base_url
=
url
full_url
=
base_url
+
kernel_file
self
.
asset_path
=
asset
.
Asset
(
full_url
,
asset_hash
=
None
,
algorithm
=
None
,
locations
=
None
,
cache_dirs
=
self
.
data_dirs
).
fetch
()
...
...
@@ -85,21 +94,40 @@ class KernelBuild(object):
Configure/prepare kernel source to build.
"""
self
.
linux_dir
=
os
.
path
.
join
(
self
.
work_dir
,
'linux-%s'
%
self
.
version
)
build
.
make
(
self
.
linux_dir
,
extra_args
=
'
O=%s mrproper'
%
self
.
build
_dir
)
build
.
make
(
self
.
linux_dir
,
extra_args
=
'
-C %s mrproper'
%
self
.
linux
_dir
)
if
self
.
config_path
is
not
None
:
dotconfig
=
os
.
path
.
join
(
self
.
linux_dir
,
'.config'
)
shutil
.
copy
(
self
.
config_path
,
dotconfig
)
def
build
(
self
):
def
build
(
self
,
binary_package
=
False
):
"""
Build kernel from source.
:param binary_package: when True, the appropriate
platform package is built
for install() to use
:type binary_pacakge: bool
"""
log
.
info
(
"Starting build the kernel"
)
build_output_format
=
""
if
binary_package
is
True
:
if
self
.
distro
.
name
==
"Ubuntu"
:
build_output_format
=
"deb-pkg"
if
self
.
config_path
is
None
:
build
.
make
(
self
.
linux_dir
,
extra_args
=
'O=%s defconfig'
%
self
.
build_dir
)
build
.
make
(
self
.
linux_dir
,
extra_args
=
'-C %s defconfig'
%
self
.
linux_dir
)
else
:
build
.
make
(
self
.
linux_dir
,
extra_args
=
'-C %s olddefconfig'
%
self
.
linux_dir
)
build
.
make
(
self
.
linux_dir
,
extra_args
=
'-C %s %s'
%
(
self
.
linux_dir
,
build_output_format
))
def
install
(
self
):
"""
Install built kernel.
"""
log
.
info
(
"Starting kernel install"
)
if
self
.
distro
.
name
==
"Ubuntu"
:
process
.
run
(
'dpkg -i %s/*.deb'
%
self
.
work_dir
,
shell
=
True
,
sudo
=
True
)
else
:
build
.
make
(
self
.
linux_dir
,
extra_args
=
'O=%s olddefconfig'
%
self
.
build_dir
)
build
.
make
(
self
.
linux_dir
,
extra_args
=
'O=%s'
%
self
.
build_dir
)
log
.
info
(
"Skipping kernel install"
)
def
__del__
(
self
):
shutil
.
rmtree
(
self
.
work_dir
)
...
...
examples/tests/linuxbuild.py
浏览文件 @
3d39de31
...
...
@@ -17,8 +17,10 @@ class LinuxBuildTest(Test):
"""
def
setUp
(
self
):
kernel_src_url
=
self
.
params
.
get
(
'linux_src_url'
,
default
=
'https://www.kernel.org/pub/linux/kernel/v3.x'
)
kernel_version
=
self
.
params
.
get
(
'linux_version'
,
default
=
'3.19.8'
)
linux_config
=
self
.
params
.
get
(
'linux_config'
,
default
=
None
)
self
.
do_kernel_install
=
self
.
params
.
get
(
'do_kernel_install'
,
default
=
None
)
if
linux_config
is
not
None
:
linux_config
=
self
.
get_data
(
linux_config
)
if
linux_config
is
None
:
...
...
@@ -26,14 +28,16 @@ class LinuxBuildTest(Test):
self
.
linux_build
=
kernel
.
KernelBuild
(
kernel_version
,
linux_config
,
self
.
work
dir
,
self
.
src
dir
,
self
.
cache_dirs
)
self
.
linux_build
.
download
()
self
.
linux_build
.
download
(
kernel_src_url
)
self
.
linux_build
.
uncompress
()
self
.
linux_build
.
configure
()
def
test
(
self
):
self
.
linux_build
.
build
()
self
.
linux_build
.
build
(
True
if
self
.
do_kernel_install
is
not
None
else
False
)
if
self
.
do_kernel_install
is
not
None
:
self
.
linux_build
.
install
()
if
__name__
==
"__main__"
:
...
...
examples/tests/linuxbuild.py.data/linuxbuild.yaml
0 → 100644
浏览文件 @
3d39de31
linux_src_url
:
https://www.kernel.org/pub/linux/kernel/v4.x/
linux_version
:
4.15.1
linux_config
:
/boot/config-4.13.0-31-generic
#do_kernel_install: y
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录