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 | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/src/lib/job.cr b/src/lib/job.cr index 0fd57e0..2fa1125 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,17 @@ class Job return true end
+ private def set_kernel_version + boot_dir = "#{SRV_OS}/#{os_dir}/boot" + suffix = "-#{kernel_version}" if self["kernel_version"]? + self["vmlinuz_path"] = File.real_path("#{boot_dir}/vmlinuz#{suffix}") + self["modules_path"] = File.real_path("#{boot_dir}/modules#{suffix}.cgz") + self["headers_path"] = File.real_path("#{boot_dir}/headers#{suffix}.cgz") + 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 +329,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?
On Mon, Nov 02, 2020 at 03:23:28PM +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 hdxuxijian@163.com
src/lib/job.cr | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/src/lib/job.cr b/src/lib/job.cr index 0fd57e0..2fa1125 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,17 @@ class Job return true end
- private def set_kernel_version
- boot_dir = "#{SRV_OS}/#{os_dir}/boot"
- suffix = "-#{kernel_version}" if self["kernel_version"]?
- self["vmlinuz_path"] = File.real_path("#{boot_dir}/vmlinuz#{suffix}")
- self["modules_path"] = File.real_path("#{boot_dir}/modules#{suffix}.cgz")
- self["headers_path"] = File.real_path("#{boot_dir}/headers#{suffix}.cgz")
Did you test that if no kernel_version?
Thanks, Xueliang
- 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 +329,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?
-- 2.23.0
On Mon, Nov 02, 2020 at 04:28:10PM +0800, Cao Xueliang wrote:
On Mon, Nov 02, 2020 at 03:23:28PM +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 hdxuxijian@163.com
src/lib/job.cr | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/src/lib/job.cr b/src/lib/job.cr index 0fd57e0..2fa1125 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,17 @@ class Job return true end
- private def set_kernel_version
- boot_dir = "#{SRV_OS}/#{os_dir}/boot"
- suffix = "-#{kernel_version}" if self["kernel_version"]?
- self["vmlinuz_path"] = File.real_path("#{boot_dir}/vmlinuz#{suffix}")
- self["modules_path"] = File.real_path("#{boot_dir}/modules#{suffix}.cgz")
- self["headers_path"] = File.real_path("#{boot_dir}/headers#{suffix}.cgz")
Did you test that if no kernel_version?
Thanks, Xueliang
Yes, it runs ok because there is a default vmlinuz, modules.cgz and headers.cgz.
Thanks, Xijian
- self["vmlinuz_path"] = File.real_path("#{boot_dir}/vmlinuz#{suffix}")
- self["modules_path"] = File.real_path("#{boot_dir}/modules#{suffix}.cgz")
- self["headers_path"] = File.real_path("#{boot_dir}/headers#{suffix}.cgz")
These look more clear:
vmlinuz_path => linux_kernel_path modules_path => linux_modules_initrd headers_path => linux_headers_initrd
btw, what if we are going to support more OS kernels? Like BSD kernels and other IOT OS.
Thanks, Fengguang
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 +329,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?
-- 2.23.0
On Tue, Nov 03, 2020 at 09:52:21AM +0800, Wu Fengguang wrote:
- self["vmlinuz_path"] = File.real_path("#{boot_dir}/vmlinuz#{suffix}")
- self["modules_path"] = File.real_path("#{boot_dir}/modules#{suffix}.cgz")
- self["headers_path"] = File.real_path("#{boot_dir}/headers#{suffix}.cgz")
These look more clear:
vmlinuz_path => linux_kernel_path modules_path => linux_modules_initrd headers_path => linux_headers_initrd
OK
btw, what if we are going to support more OS kernels? Like BSD kernels and other IOT OS.
Just put new kernels into $os_dir/boot/ and give them a name with version, now we have three versions of openeuler20.03, we can see in boot/ there are three kind of versions of vmlinuz for use:
├── vmlinuz-4.19.90-2003 ├── vmlinuz-4.19.90-mysql └── vmlinuz-4.19.90-nginx
Thanks, Xijian