summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYevgeny Popovych <yevgenyp@pointgrab.com>2018-07-20 18:14:20 +0300
committerPhil Wise <philip.wise@here.com>2018-08-14 16:03:10 +0200
commit212d71d273023470b82854c363854b301bd11314 (patch)
tree7f2fdf96c359f8a39e440624103cd1c5309e3917
parent625c3a3a7b7390012c26b34ce4bb4cd277d9ed07 (diff)
downloadmeta-updater-212d71d273023470b82854c363854b301bd11314.tar.gz
ostree-initrd: Make it an initramfs, not initrd
The reasoning here is to allow initramfs generated by this recipe to be included in FIT. To do so w/o changing openembedded-core (it allows only cpio format) - init script should be able to execute from a rootfs (i.e. true initramfs), not ramdisk (initrd). See [1] for more information on these keywords. The gist of this change is switch from `pivot_root` to `switch_root`. This also allows to get rid of some clutter, since `switch_root` handles transition to new sysroot all by itself. Again, see [1] for details on these utility/syscall. [1] https://www.kernel.org/doc/Documentation/filesystems/ramfs-rootfs-initramfs.txt Signed-off-by: Yevgeny Popovych <yevgenyp@pointgrab.com>
-rw-r--r--classes/sota.bbclass2
-rw-r--r--classes/sota_qemux86-64.bbclass2
-rw-r--r--classes/sota_raspberrypi.bbclass1
-rw-r--r--recipes-sota/ostree-initrd/files/init.sh22
-rw-r--r--recipes-sota/ostree-initrd/ostree-initrd.bb10
5 files changed, 12 insertions, 25 deletions
diff --git a/classes/sota.bbclass b/classes/sota.bbclass
index 0eb8981..f5c6247 100644
--- a/classes/sota.bbclass
+++ b/classes/sota.bbclass
@@ -23,7 +23,7 @@ WKS_FILE_sota ?= "sdimage-sota.wks"
23 23
24EXTRA_IMAGEDEPENDS_append_sota = " parted-native mtools-native dosfstools-native" 24EXTRA_IMAGEDEPENDS_append_sota = " parted-native mtools-native dosfstools-native"
25 25
26INITRAMFS_FSTYPES ??= "${@oe.utils.ifelse(d.getVar('OSTREE_BOOTLOADER', True) == 'u-boot', 'ext4.gz.u-boot', 'ext4.gz')}" 26INITRAMFS_FSTYPES ??= "${@oe.utils.ifelse(d.getVar('OSTREE_BOOTLOADER', True) == 'u-boot', 'cpio.gz.u-boot', 'cpio.gz')}"
27 27
28# Please redefine OSTREE_REPO in order to have a persistent OSTree repo 28# Please redefine OSTREE_REPO in order to have a persistent OSTree repo
29OSTREE_REPO ?= "${DEPLOY_DIR_IMAGE}/ostree_repo" 29OSTREE_REPO ?= "${DEPLOY_DIR_IMAGE}/ostree_repo"
diff --git a/classes/sota_qemux86-64.bbclass b/classes/sota_qemux86-64.bbclass
index 9ef531d..0850af6 100644
--- a/classes/sota_qemux86-64.bbclass
+++ b/classes/sota_qemux86-64.bbclass
@@ -4,7 +4,7 @@ IMAGE_FSTYPES_remove = "wic"
4PREFERRED_PROVIDER_virtual/bootloader_sota = "u-boot" 4PREFERRED_PROVIDER_virtual/bootloader_sota = "u-boot"
5UBOOT_MACHINE_sota = "qemu-x86_defconfig" 5UBOOT_MACHINE_sota = "qemu-x86_defconfig"
6OSTREE_BOOTLOADER ?= "u-boot" 6OSTREE_BOOTLOADER ?= "u-boot"
7INITRAMFS_FSTYPES ?= "ext4.gz" 7INITRAMFS_FSTYPES ?= "cpio.gz"
8 8
9OSTREE_KERNEL_ARGS ?= "ramdisk_size=16384 rw rootfstype=ext4 rootwait rootdelay=2 ostree_root=/dev/hda" 9OSTREE_KERNEL_ARGS ?= "ramdisk_size=16384 rw rootfstype=ext4 rootwait rootdelay=2 ostree_root=/dev/hda"
10 10
diff --git a/classes/sota_raspberrypi.bbclass b/classes/sota_raspberrypi.bbclass
index e69ccf8..e5f002d 100644
--- a/classes/sota_raspberrypi.bbclass
+++ b/classes/sota_raspberrypi.bbclass
@@ -3,6 +3,7 @@ RPI_USE_U_BOOT_sota = "1"
3KERNEL_CLASSES_append_sota = " kernel-fitimage" 3KERNEL_CLASSES_append_sota = " kernel-fitimage"
4KERNEL_IMAGETYPE_sota = "fitImage" 4KERNEL_IMAGETYPE_sota = "fitImage"
5OSTREE_KERNEL = "${KERNEL_IMAGETYPE}-${INITRAMFS_IMAGE}-${MACHINE}.bin" 5OSTREE_KERNEL = "${KERNEL_IMAGETYPE}-${INITRAMFS_IMAGE}-${MACHINE}.bin"
6INITRAMFS_FSTYPES = "cpio.gz"
6 7
7PREFERRED_PROVIDER_virtual/bootloader_sota ?= "u-boot" 8PREFERRED_PROVIDER_virtual/bootloader_sota ?= "u-boot"
8UBOOT_ENTRYPOINT_sota ?= "0x00008000" 9UBOOT_ENTRYPOINT_sota ?= "0x00008000"
diff --git a/recipes-sota/ostree-initrd/files/init.sh b/recipes-sota/ostree-initrd/files/init.sh
index d7e0429..4818a07 100644
--- a/recipes-sota/ostree-initrd/files/init.sh
+++ b/recipes-sota/ostree-initrd/files/init.sh
@@ -41,7 +41,6 @@ do_mount_fs sysfs /sys
41do_mount_fs devtmpfs /dev 41do_mount_fs devtmpfs /dev
42do_mount_fs devpts /dev/pts 42do_mount_fs devpts /dev/pts
43do_mount_fs tmpfs /dev/shm 43do_mount_fs tmpfs /dev/shm
44do_mount_fs tmpfs /tmp
45do_mount_fs tmpfs /run 44do_mount_fs tmpfs /run
46 45
47# check if smack is active (and if so, mount smackfs) 46# check if smack is active (and if so, mount smackfs)
@@ -63,23 +62,10 @@ mount "$ostree_sysroot" /sysroot || {
63 sleep 5 62 sleep 5
64 mount "$ostree_sysroot" /sysroot || bail_out "Unable to mount $ostree_sysroot as physical sysroot" 63 mount "$ostree_sysroot" /sysroot || bail_out "Unable to mount $ostree_sysroot as physical sysroot"
65} 64}
66ostree-prepare-root /sysroot
67
68# move mounted devices to new root
69cd /sysroot
70for x in dev proc run; do
71 log_info "Moving /$x to new rootfs"
72 mount -o move "/$x" "$x"
73done
74
75# switch to new rootfs
76log_info "Switching to new rootfs"
77mkdir -p run/initramfs
78 65
79pivot_root . run/initramfs || bail_out "pivot_root failed." 66ostree-prepare-root /sysroot
80
81log_info "Launching target init"
82 67
83exec chroot . sh -c 'umount /run/initramfs; exec /sbin/init' \ 68log_info "Switching to rootfs"
84 <dev/console >dev/console 2>&1 69exec switch_root /sysroot /sbin/init
85 70
71bail_out "Failed to switch_root to $ostree_sysroot"
diff --git a/recipes-sota/ostree-initrd/ostree-initrd.bb b/recipes-sota/ostree-initrd/ostree-initrd.bb
index 6046c81..26525c8 100644
--- a/recipes-sota/ostree-initrd/ostree-initrd.bb
+++ b/recipes-sota/ostree-initrd/ostree-initrd.bb
@@ -1,20 +1,20 @@
1SUMMARY = "Extremely basic live image init script" 1SUMMARY = "Initramfs for booting into libostree managed system"
2LICENSE = "MIT" 2LICENSE = "MIT"
3LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" 3LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
4
4SRC_URI = "file://init.sh" 5SRC_URI = "file://init.sh"
5 6
6S = "${WORKDIR}" 7S = "${WORKDIR}"
7 8
8PV = "3" 9PV = "4"
9 10
10do_install() { 11do_install() {
11 install -dm 0755 ${D}/etc 12 install -dm 0755 ${D}/etc
12 touch ${D}/etc/initrd-release 13 touch ${D}/etc/initrd-release
13 install -dm 0755 ${D}/dev 14 install -dm 0755 ${D}/dev
14 install -dm 0755 ${D}/sbin 15 install -m 0755 ${WORKDIR}/init.sh ${D}/init
15 install -m 0755 ${WORKDIR}/init.sh ${D}/sbin/init
16} 16}
17 17
18inherit allarch 18inherit allarch
19 19
20FILES_${PN} += " /dev /etc/initrd-release /sbin/init " 20FILES_${PN} += " /dev /etc/initrd-release /init "