diff --git a/meta-citadel/classes/citadel-image.bbclass b/meta-citadel/classes/citadel-image.bbclass index f52ffbf..d9dbf9d 100644 --- a/meta-citadel/classes/citadel-image.bbclass +++ b/meta-citadel/classes/citadel-image.bbclass @@ -9,6 +9,10 @@ inherit image CITADEL_IMAGE_CHANNEL ??= "dev" +kernel_id() { + sha256sum ${DEPLOY_DIR_IMAGE}/bzImage-intel-corei7-64.bin | cut -d' ' -f1 +} + do_citadel_mkimage() { cat > ${B}/mkimage.conf << EOF image-type = "${CITADEL_IMAGE_TYPE}" @@ -19,9 +23,11 @@ EOF ver=$(printf "%03d" ${CITADEL_IMAGE_VERSION}) - if [ "${CITADEL_IMAGE_TYPE}" = "modules" ]; then + if [ "${CITADEL_IMAGE_TYPE}" = "kernel" ]; then + KERNEL_ID=$(kernel_id) echo "kernel-version = \"${CITADEL_KERNEL_VERSION}\"" >> ${B}/mkimage.conf - fname="citadel-modules-${CITADEL_KERNEL_VERSION}-${CITADEL_IMAGE_CHANNEL}-${ver}.img" + echo "kernel-id = \"${KERNEL_ID}\"" >> ${B}/mkimage.conf + fname="citadel-kernel-${CITADEL_KERNEL_VERSION}-${CITADEL_IMAGE_CHANNEL}-${ver}.img" else fname="citadel-${CITADEL_IMAGE_TYPE}-${CITADEL_IMAGE_CHANNEL}-${ver}.img" fi @@ -30,3 +36,5 @@ EOF } addtask do_citadel_mkimage after do_image_ext2 before do_image_complete +do_citadel_mkimage[cleandirs] = "${B}" + diff --git a/meta-citadel/recipes-citadel/images/citadel-image.inc b/meta-citadel/recipes-citadel/images/citadel-image.inc index 0778a49..c460bdb 100644 --- a/meta-citadel/recipes-citadel/images/citadel-image.inc +++ b/meta-citadel/recipes-citadel/images/citadel-image.inc @@ -3,6 +3,10 @@ CITADEL_IMAGE_CHANNEL = "dev" CITADEL_IMAGE_VERSION_rootfs = "1" CITADEL_IMAGE_VERSION_extra = "1" -CITADEL_IMAGE_VERSION_modules = "1" +CITADEL_IMAGE_VERSION_kernel = "1" CITADEL_KERNEL_VERSION = "4.9.65" + +generate_kernel_id() { + sha256sum ${DEPLOY_DIR_IMAGE}/bzImage-intel-corei7-64.bin | cut -d' ' -f1 +} diff --git a/meta-citadel/recipes-citadel/images/citadel-installer-image.bb b/meta-citadel/recipes-citadel/images/citadel-installer-image.bb index 1f90441..11af214 100644 --- a/meta-citadel/recipes-citadel/images/citadel-installer-image.bb +++ b/meta-citadel/recipes-citadel/images/citadel-installer-image.bb @@ -24,7 +24,7 @@ do_rootfs[umask] = "022" do_rootfs[depends] += "\ citadel-rootfs-image:do_image_complete \ citadel-extra-image:do_image_complete \ - citadel-modules-image:do_image_complete \ + citadel-kernel-image:do_image_complete \ citadel-kernel:do_deploy \ systemd-boot:do_deploy \ " @@ -58,7 +58,7 @@ install_image_files() { install -d ${IMAGE_ROOTFS}/images install_resource_image "rootfs" ${CITADEL_IMAGE_VERSION_rootfs} install_resource_image "extra" ${CITADEL_IMAGE_VERSION_extra} - install_resource_image "modules" ${CITADEL_IMAGE_VERSION_modules} + install_resource_image "kernel" ${CITADEL_IMAGE_VERSION_kernel} install ${TOPDIR}/appimg/appimg-rootfs.tar.xz ${IMAGE_ROOTFS}/images/ } @@ -105,10 +105,10 @@ EOF install_resource_image() { version=$(printf "%03d" ${2}) - if [ "${1}" = "modules" ]; then + if [ "${1}" = "kernel" ]; then kversion=$(cat ${DEPLOY_DIR_IMAGE}/kernel.version) - src_fname="citadel-modules-${kversion}-${CITADEL_IMAGE_CHANNEL}-${version}.img" - dst_fname="citadel-modules-${kversion}.img" + src_fname="citadel-kernel-${kversion}-${CITADEL_IMAGE_CHANNEL}-${version}.img" + dst_fname="citadel-kernel-${kversion}.img" else src_fname="citadel-${1}-${CITADEL_IMAGE_CHANNEL}-${version}.img" dst_fname="citadel-${1}.img" diff --git a/meta-citadel/recipes-citadel/images/citadel-modules-image.bb b/meta-citadel/recipes-citadel/images/citadel-kernel-image.bb similarity index 69% rename from meta-citadel/recipes-citadel/images/citadel-modules-image.bb rename to meta-citadel/recipes-citadel/images/citadel-kernel-image.bb index 8e821d1..0c880d6 100644 --- a/meta-citadel/recipes-citadel/images/citadel-modules-image.bb +++ b/meta-citadel/recipes-citadel/images/citadel-kernel-image.bb @@ -1,11 +1,10 @@ - -DESCRIPTION = "Kernel modules" +DESCRIPTION = "Resource image containing citadel kernel and kernel modules" LICENSE = "MIT" PACKAGE_INSTALL = "kernel-modules" -CITADEL_IMAGE_VERSION = "${CITADEL_IMAGE_VERSION_modules}" -CITADEL_IMAGE_TYPE = "modules" +CITADEL_IMAGE_VERSION = "${CITADEL_IMAGE_VERSION_kernel}" +CITADEL_IMAGE_TYPE = "kernel" require citadel-image.inc inherit citadel-image diff --git a/meta-citadel/recipes-initrd/citadel-initramfs/files/citadel-rootfs-mount.service b/meta-citadel/recipes-initrd/citadel-initramfs/files/citadel-rootfs-mount.service index d434fc0..c051d78 100644 --- a/meta-citadel/recipes-initrd/citadel-initramfs/files/citadel-rootfs-mount.service +++ b/meta-citadel/recipes-initrd/citadel-initramfs/files/citadel-rootfs-mount.service @@ -10,7 +10,7 @@ ConditionPathExists=/dev/mapper/citadel-rootfsB ConditionPathExists=/dev/mapper/citadel-storage # -# Pull in the unit that mounts 'extra' and 'modules' images +# Pull in the unit that mounts 'extra' and 'kernel' images # Wants=citadel-rootfs-setup.service diff --git a/meta-citadel/recipes-initrd/images/citadel-initramfs-image.bb b/meta-citadel/recipes-initrd/images/citadel-initramfs-image.bb index 8574f9a..cd3b9ff 100644 --- a/meta-citadel/recipes-initrd/images/citadel-initramfs-image.bb +++ b/meta-citadel/recipes-initrd/images/citadel-initramfs-image.bb @@ -109,12 +109,21 @@ INITRAMFS_MAXSIZE = "512000" INITRAMFS_FSTYPES = "cpio.lz4" IMAGE_FSTYPES = "${INITRAMFS_FSTYPES}" inherit core-image +require ${THISDIR}/../../recipes-citadel/images/citadel-image.inc IMAGE_ROOTFS_SIZE = "8192" IMAGE_ROOTFS_EXTRA_SPACE = "0" -ROOTFS_POSTPROCESS_COMMAND += "remove_blk_availability; " +ROOTFS_POSTPROCESS_COMMAND += "remove_blk_availability; append_initrd_release; " remove_blk_availability() { rm ${IMAGE_ROOTFS}${systemd_system_unitdir}/blk-availability.service } + +append_initrd_release() { + KERNEL_ID=$(generate_kernel_id) + cat >> ${IMAGE_ROOTFS}/etc/initrd-release << EOF +CITADEL_KERNEL_VERSION="${CITADEL_KERNEL_VERSION}" +CITADEL_KERNEL_ID="${KERNEL_ID}" +EOF +}