[PATCH] sbin/split-job: get_kernel_info and init job result_root elements

In order to avoid potential problems while assigning values to dimension keys(like commit,compiler,kconfig) from option parameters, assign default values to these dimension variables. Implement a helper function get_kernel_info() to retrieve the kernel version and the version of the compiler that is used to compile the kernel. Invoke the get_kernel_info() during collecting distribution information of local system. Initialize the dimension commit key with value kernelversion got from the distroinfo if no commit option is setting. Initialize the dimension compiler key with value kernelcompiler if it is not assigned. Initialize the dimension kconfig key with value "defconfig" if no kconfig option is setting, as we can't guarantee that we can get the right kconfig file name in various environment. Signed-off-by: Zheng Zengkai <zhengzengkai@huawei.com> --- lib/detect-system.sh | 24 ++++++++++++++++++++++++ lib/distro_info.rb | 9 ++++++--- sbin/split-job | 5 +++-- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/lib/detect-system.sh b/lib/detect-system.sh index 384480b29..da3cdea63 100755 --- a/lib/detect-system.sh +++ b/lib/detect-system.sh @@ -108,6 +108,30 @@ detect_libc_version() return 1 } +get_kernel_compiler() +{ + local system_dir=${1:-/} + local proc_version=$(<${system_dir}proc/version) + local pattern1='gcc[[:space:]].GCC.[[:space:]]*([0-9]+\.[0-9]+\.[0-9]+)' + local pattern2='gcc[[:space:]]+version[[:space:]]+([0-9]+\.[0-9]+\.[0-9]+)' + export _kernel_compiler='unknown' + + if [[ "$proc_version" =~ $pattern1 ]]; then + _kernel_compiler="${BASH_REMATCH[1]}" + elif [[ "$proc_version" =~ $pattern2 ]]; then + _kernel_compiler="${BASH_REMATCH[1]}" + fi +} + +get_kernel_info() +{ + local system_dir=${1:-/} + export _kernel_version='unknown' + + _kernel_version=$(command uname -r) + get_kernel_compiler $system_dir +} + detect_system() { local system_dir=${1:-/} diff --git a/lib/distro_info.rb b/lib/distro_info.rb index b17c77fa7..066be440c 100755 --- a/lib/distro_info.rb +++ b/lib/distro_info.rb @@ -6,7 +6,7 @@ module LKP # # DistroInfo is singleton, and provide information to distribution information of local system - # Include: system name, system version, system arch + # Include: system name, system version, system arch, kernel version, kernel compiler # In the backend, it's invoking detect-system.sh to get environment information. # Example of properties on debian # p systemName => Debian @@ -18,12 +18,12 @@ module LKP # class DistroInfo include Singleton - attr_reader :systemname, :systemnamel, :systemversion, :systemarch + attr_reader :systemname, :systemnamel, :systemversion, :systemarch, :kernelversion, :kernelcompiler def initialize(rootfs = '/') path_to_script = "#{LKP_SRC}/lib/detect-system.sh" - @systemname, @systemnamel, @systemversion, @systemarch = %x[ + @systemname, @systemnamel, @systemversion, @systemarch, @kernelversion, @kernelcompiler = %x[ export LKP_SRC=#{LKP_SRC} . #{path_to_script} detect_system #{rootfs} @@ -31,6 +31,9 @@ module LKP echo $_system_name_lowercase echo $_system_version get_system_arch #{rootfs} + get_kernel_info #{rootfs} + echo $_kernel_version + echo $_kernel_compiler ].split end end diff --git a/sbin/split-job b/sbin/split-job index bef7e970f..63b68bc84 100755 --- a/sbin/split-job +++ b/sbin/split-job @@ -97,8 +97,9 @@ ARGV.each do |jobfile| jobfile = Job.find_jobfile(jobfile) jobfile = refine_job_file(jobfile) if @opt_compatible jobs.load(jobfile, expand_template: true) || next - jobs['kconfig'] = @opt_kconfig if @opt_kconfig - jobs['commit'] = @opt_commit if @opt_commit + jobs['kconfig'] = @opt_kconfig || "defconfig" + jobs['commit'] = @opt_commit || distroinfo.kernelversion + jobs['compiler'] ||= distroinfo.kernelcompiler jobs['testbox'] = @opt_testbox jobs['arch'] ||= distroinfo.systemarch jobs['tbox_group'] = tbox_group(@opt_testbox) -- 2.20.1
participants (1)
-
Zheng Zengkai