On Wed, Oct 28, 2020 at 07:46:24PM +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.
Signed-off-by: Xu Xijian xuxijian@huawei.com
src/lib/job.cr | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/lib/job.cr b/src/lib/job.cr index 8f5dd36..c8b9dc6 100644 --- a/src/lib/job.cr +++ b/src/lib/job.cr @@ -85,6 +85,7 @@ class Job kernel_append_root kernel_params docker_image
kernel_version )
macro method_missing(call)
@@ -281,8 +282,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}")}"
1. 考虑kernel_version 增加到 INIT_FIELD 里面(默认值default) 2. 必须要把vmlinuz放到 boot 子目录,然后作为后缀吗?参考其它的设置: $version下面有vmlinuz - $version = "default" - $version = "others"
end
private def kernel_common_params @@ -303,10 +305,16 @@ class Job temp_initrds = [] of String
osimage_dir = "#{SRV_INITRD}/osimage/#{os_dir}"
- boot_dir = "#{SRV_OS}/#{os_dir}/boot"
- self["kernel_version"] ||= "default"
如果这样用,就没有必要在METHOD_KEYS里面添加了,在那里添加是指可以用 kernel_version 这个方法。 按照上面的INIT_FIELD考虑。
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?
-- 2.23.0