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 hdxuxijian@163.com --- src/lib/job.cr | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/src/lib/job.cr b/src/lib/job.cr index 0fd57e0..8bf7a65 100644 --- a/src/lib/job.cr +++ b/src/lib/job.cr @@ -87,6 +87,10 @@ class Job kernel_append_root kernel_params docker_image + kernel_version + vmlinuz_path + modules_path + headers_path )
macro method_missing(call) @@ -135,6 +139,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,9 +298,22 @@ class Job return true end
+ private def set_kernel_version + boot_dir = "#{SRV_OS}/#{os_dir}/boot" + if self["kernel_version"]? + self["vmlinuz_path"] = "#{boot_dir}/vmlinuz-#{kernel_version}" + self["modules_path"] = "#{boot_dir}/modules-#{kernel_version}.cgz" + self["headers_path"] = "#{boot_dir}/headers-#{kernel_version}.cgz" + else + self["vmlinuz_path"] = "#{boot_dir}/vmlinuz" + self["modules_path"] = "#{boot_dir}/modules.cgz" + self["headers_path"] = "#{boot_dir}/headers.cgz" + end + end + private def set_kernel_uri self["kernel_uri"] = "kernel #{OS_HTTP_PREFIX}" + - "#{JobHelper.service_path("#{SRV_OS}/#{os_dir}/vmlinuz")}" + "#{JobHelper.service_path("#{vmlinuz_path}")}" end
private def common_initrds @@ -316,6 +334,10 @@ class Job "#{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("#{modules_path}")}" + temp_initrds << "#{OS_HTTP_PREFIX}" + + "#{JobHelper.service_path("#{headers_path}")}"
temp_initrds.concat(initrd_deps.split(/ /)) unless initrd_deps.empty? temp_initrds.concat(initrd_pkg.split(/ /)) unless initrd_pkg.empty?
- private def set_kernel_version
- boot_dir = "#{SRV_OS}/#{os_dir}/boot"
- if self["kernel_version"]?
self["vmlinuz_path"] = "#{boot_dir}/vmlinuz-#{kernel_version}"
self["modules_path"] = "#{boot_dir}/modules-#{kernel_version}.cgz"
self["headers_path"] = "#{boot_dir}/headers-#{kernel_version}.cgz"
The if/else 'self[] = ...' blocks can be consolidated with help of
suffix = '-' + kernel_version
- else
self["vmlinuz_path"] = "#{boot_dir}/vmlinuz"
self["modules_path"] = "#{boot_dir}/modules.cgz"
self["headers_path"] = "#{boot_dir}/headers.cgz"
Those could be symlinks, better expand them to real path.
Thanks, Fengguang
On Sat, Oct 31, 2020 at 07:59:58PM +0800, Wu Fengguang wrote:
- private def set_kernel_version
- boot_dir = "#{SRV_OS}/#{os_dir}/boot"
- if self["kernel_version"]?
self["vmlinuz_path"] = "#{boot_dir}/vmlinuz-#{kernel_version}"
self["modules_path"] = "#{boot_dir}/modules-#{kernel_version}.cgz"
self["headers_path"] = "#{boot_dir}/headers-#{kernel_version}.cgz"
The if/else 'self[] = ...' blocks can be consolidated with help of
suffix = '-' + kernel_version
- else
self["vmlinuz_path"] = "#{boot_dir}/vmlinuz"
self["modules_path"] = "#{boot_dir}/modules.cgz"
self["headers_path"] = "#{boot_dir}/headers.cgz"
Those could be symlinks, better expand them to real path.
Thanks, Fengguang
Good
Thanks, Xijian