Add initrd and kernels

This commit is contained in:
Ettore Di Giacinto
2022-09-30 23:45:22 +00:00
parent c9c8709823
commit 9596de87f9
4 changed files with 96 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
requires:
- name: "{{.Values.name}}"
category: "distro-kernels"
version: ">=0"
copy:
# The toolkit is required in module-setup and embedded in the initramfs.
- package:
category: "system"
{{ if eq .Values.name "opensuse" }}
name: "elemental-toolkit"
{{ else }}
name: "elemental-toolkit-{{.Values.name}}"
{{ end }}
version: ">=0"
source: "/framework/."
destination: "/"
prelude:
# remove if any
- rm -rf /boot/initrd || true
steps:
# Create initrd
- |
kernel=$(ls /lib/modules | head -n1) && \
dracut -f "/boot/initrd-${kernel}" "${kernel}" && \
ln -sf "initrd-${kernel}" /boot/initrd

View File

@@ -0,0 +1,10 @@
packages:
- name: "opensuse"
category: "distro-initrd"
version: "0.1"
- name: "fedora"
category: "distro-initrd"
version: "0.1"
- name: "ubuntu"
category: "distro-initrd"
version: "0.1"

View File

@@ -0,0 +1,39 @@
image: "{{.Values.image}}:{{.Values.version}}"
excludes:
- ^/boot/grub2
- ^/boot/initrd
unpack: true
includes:
- ^/boot|^/boot/.*
- ^/lib/modules|^/lib/modules.*
steps:
{{ if .Values.distribution }}
{{if eq .Values.distribution "opensuse" }}
- zypper in -y --no-recommends {{.Values.kernel_package}}
- zypper cc
{{ if .Values.arch }}
{{ if eq .Values.arch "aarch64" }}
# aarch64 has an uncompressed kernel so we need to link it to vmlinuz
- |
kernel=$(ls /boot/Image-* | head -n1) && \
ln -sf "${kernel#/boot/}" /boot/vmlinuz
{{ end }}
{{ end }}
{{else if eq .Values.distribution "fedora" }}
- dnf install -y {{.Values.kernel_package}}
- dnf clean all
- |
kernel=$(ls /boot/vmlinuz-* | head -n1) && \
ln -sf "${kernel#/boot/}" /boot/vmlinuz
{{else if eq .Values.distribution "ubuntu" }}
# Note for future issues with grub: https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/1879558 https://github.com/rancher-sandbox/cOS-toolkit/pull/101#discussion_r621929109
- apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y {{.Values.kernel_package}}
- apt-get clean
- |
kernel=$(ls /boot/vmlinuz-* | head -n1) && \
ln -sf "${kernel#/boot/}" /boot/vmlinuz
{{end}}
{{end}}
- kernel=$(ls /lib/modules | head -n1) && depmod -a "${kernel}"

View File

@@ -0,0 +1,19 @@
packages:
- category: "distro-kernels"
name: "opensuse"
version: "15.4"
image: "opensuse/leap"
distribution: "opensuse"
kernel_package: "kernel-default dracut kernel-firmware-all"
- category: "distro-kernels"
name: "fedora"
version: "36"
image: "fedora"
distribution: "fedora"
kernel_package: "kernel grub2 kernel-core dracut dracut-live"
- category: "distro-kernels"
name: "ubuntu"
version: "20.04"
image: "ubuntu"
distribution: "ubuntu"
kernel_package: "linux-image-generic-hwe-20.04 dracut dracut-network"