When run job with initramfs, there is a default combination of kernel, modules and headers, and I add a key "kernel_version" to make it optional.
Signed-off-by: Xu Xijian xuxijian@huawei.com --- src/lib/job.cr | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/src/lib/job.cr b/src/lib/job.cr index 7fbc414..88f64ab 100644 --- a/src/lib/job.cr +++ b/src/lib/job.cr @@ -86,6 +86,7 @@ class Job kernel_append_root kernel_params docker_image + kernel_version )
macro method_missing(call) @@ -134,6 +135,7 @@ class Job set_result_service() set_os_mount() set_depends_initrd() + set_kernel_version() set_initrds_uri() set_kernel_uri() set_kernel_append_root() @@ -293,8 +295,9 @@ class Job end
private def set_kernel_uri + vmlinuz_sub_path = (("#{kernel_version}" == "default") ? "vmlinuz" : "boot/vmlinuz-#{kernel_version}") self["kernel_uri"] = "kernel #{OS_HTTP_PREFIX}" + - "#{JobHelper.service_path("#{SRV_OS}/#{os_dir}/vmlinuz")}" + "#{JobHelper.service_path("#{SRV_OS}/#{os_dir}/#{vmlinuz_sub_path}")}" end
private def kernel_common_params @@ -315,10 +318,15 @@ class Job temp_initrds = [] of String
osimage_dir = "#{SRV_INITRD}/osimage/#{os_dir}" + boot_dir = "#{SRV_OS}/#{os_dir}/boot" temp_initrds << "#{INITRD_HTTP_PREFIX}" + "#{JobHelper.service_path("#{osimage_dir}/current")}" temp_initrds << "#{INITRD_HTTP_PREFIX}" + "#{JobHelper.service_path("#{osimage_dir}/run-ipconfig.cgz")}" + temp_initrds << "#{OS_HTTP_PREFIX}" + + "#{JobHelper.service_path("#{boot_dir}/modules-#{kernel_version}.cgz")}" + temp_initrds << "#{OS_HTTP_PREFIX}" + + "#{JobHelper.service_path("#{boot_dir}/headers-#{kernel_version}.cgz")}"
temp_initrds.concat(initrd_deps.split(/ /)) unless initrd_deps.empty? temp_initrds.concat(initrd_pkg.split(/ /)) unless initrd_pkg.empty? @@ -359,6 +367,10 @@ class Job return basenames end
+ private def set_kernel_version + self["kernel_version"] ||= "default" + end + private def set_initrds_uri uris = ""
On Thu, Oct 29, 2020 at 02:27:01PM +0800, Xu Xijian wrote:
When run job with initramfs, there is a default combination of kernel, modules and headers, and I add a key "kernel_version" to make it optional.
Should explain how to set it in the job and what's the mapping between its typical values and actual files in the disk.
Can put such user oriented info in doc/job/kernel_version.md
Thanks, Fengguang
Signed-off-by: Xu Xijian xuxijian@huawei.com
src/lib/job.cr | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/src/lib/job.cr b/src/lib/job.cr index 7fbc414..88f64ab 100644 --- a/src/lib/job.cr +++ b/src/lib/job.cr @@ -86,6 +86,7 @@ class Job kernel_append_root kernel_params docker_image
kernel_version )
macro method_missing(call)
@@ -134,6 +135,7 @@ class Job set_result_service() set_os_mount() set_depends_initrd()
- set_kernel_version() set_initrds_uri() set_kernel_uri() set_kernel_append_root()
@@ -293,8 +295,9 @@ class Job end
private def set_kernel_uri
- vmlinuz_sub_path = (("#{kernel_version}" == "default") ? "vmlinuz" : "boot/vmlinuz-#{kernel_version}") self["kernel_uri"] = "kernel #{OS_HTTP_PREFIX}" +
"#{JobHelper.service_path("#{SRV_OS}/#{os_dir}/vmlinuz")}"
"#{JobHelper.service_path("#{SRV_OS}/#{os_dir}/#{vmlinuz_sub_path}")}"
end
private def kernel_common_params
@@ -315,10 +318,15 @@ class Job temp_initrds = [] of String
osimage_dir = "#{SRV_INITRD}/osimage/#{os_dir}"
boot_dir = "#{SRV_OS}/#{os_dir}/boot" temp_initrds << "#{INITRD_HTTP_PREFIX}" + "#{JobHelper.service_path("#{osimage_dir}/current")}" temp_initrds << "#{INITRD_HTTP_PREFIX}" + "#{JobHelper.service_path("#{osimage_dir}/run-ipconfig.cgz")}"
temp_initrds << "#{OS_HTTP_PREFIX}" +
"#{JobHelper.service_path("#{boot_dir}/modules-#{kernel_version}.cgz")}"
temp_initrds << "#{OS_HTTP_PREFIX}" +
"#{JobHelper.service_path("#{boot_dir}/headers-#{kernel_version}.cgz")}"
temp_initrds.concat(initrd_deps.split(/ /)) unless initrd_deps.empty? temp_initrds.concat(initrd_pkg.split(/ /)) unless initrd_pkg.empty?
@@ -359,6 +367,10 @@ class Job return basenames end
- private def set_kernel_version
- self["kernel_version"] ||= "default"
- end
- private def set_initrds_uri uris = ""
-- 2.23.0
On Thu, Oct 29, 2020 at 02:31:53PM +0800, Wu Fengguang wrote:
On Thu, Oct 29, 2020 at 02:27:01PM +0800, Xu Xijian wrote:
When run job with initramfs, there is a default combination of kernel, modules and headers, and I add a key "kernel_version" to make it optional.
Should explain how to set it in the job and what's the mapping between its typical values and actual files in the disk.
Can put such user oriented info in doc/job/kernel_version.md
Thanks, Fengguang
OK, Thanks for reminding.
Thanks, Xijian