Given that we have a purecap sysroot there is little benefit in purecap only environment, Maintaining it manually would quickly become a pain in the case when the purecap share of app/libs were to grow.
Use the Yocto way for initramfs.
Signed-off-by: Pawel Zalewski pzalewski@thegoodpenguin.co.uk --- .../conf/machine/include/morello-common.inc | 2 +- .../recipes-core/busybox/busybox-morello.inc | 8 +-- .../images/{morello-fvp => }/files/init.sh | 24 +++++--- .../files/initramfs.list.template | 0 .../images/morello-initramfs-image.bb | 24 ++++++++ .../images/morello-initramfs-scripts.bb | 19 +++++++ .../images/morello-initramfs.bb | 57 ------------------- .../images/morello-soc/files/init.sh | 47 --------------- .../morello-soc/files/initramfs.list.template | 16 ------ meta-morello/wic/morello-efidisk.wks | 4 +- meta-morello/wic/morello-fvp-grub.cfg | 4 +- meta-morello/wic/morello-soc-grub.cfg | 4 +- 12 files changed, 70 insertions(+), 139 deletions(-) rename meta-morello/recipes-morello/images/{morello-fvp => }/files/init.sh (51%) rename meta-morello/recipes-morello/images/{morello-fvp => }/files/initramfs.list.template (100%) create mode 100644 meta-morello/recipes-morello/images/morello-initramfs-image.bb create mode 100644 meta-morello/recipes-morello/images/morello-initramfs-scripts.bb delete mode 100644 meta-morello/recipes-morello/images/morello-initramfs.bb delete mode 100644 meta-morello/recipes-morello/images/morello-soc/files/init.sh delete mode 100644 meta-morello/recipes-morello/images/morello-soc/files/initramfs.list.template
diff --git a/meta-morello/conf/machine/include/morello-common.inc b/meta-morello/conf/machine/include/morello-common.inc index 80524d3..1c29774 100644 --- a/meta-morello/conf/machine/include/morello-common.inc +++ b/meta-morello/conf/machine/include/morello-common.inc @@ -49,5 +49,5 @@ EFI_PROVIDER ?= "grub-efi" MACHINE_FEATURES += "efi"
INITRAMFS_MAXSIZE = "640000" -INITRAMFS_IMAGE = "morello-initramfs" +INITRAMFS_IMAGE = "morello-initramfs-image" INITRAMFS_IMAGE_BUNDLE = "0" diff --git a/meta-morello/recipes-core/busybox/busybox-morello.inc b/meta-morello/recipes-core/busybox/busybox-morello.inc index cb1e577..c70f8eb 100644 --- a/meta-morello/recipes-core/busybox/busybox-morello.inc +++ b/meta-morello/recipes-core/busybox/busybox-morello.inc @@ -29,8 +29,8 @@ EXTRA_OEMAKE = "\ KHEADERS='${STAGING_KERNEL_BUILDDIR}/kernel-headers/include/' \ "
-FILES:${PN} += "/busybox/busybox" -SYSROOT_DIRS += "/busybox" +FILES:${PN} += "/busybox-morello/busybox" +SYSROOT_DIRS += "/busybox-morello"
INHIBIT_SYSROOT_STRIP = "1" INHIBIT_PACKAGE_STRIP = "1" @@ -49,6 +49,6 @@ do_compile() { }
do_install() { - install -d ${D}/busybox - install -m 0755 ${S}/busybox ${D}/busybox/busybox + install -d ${D}/busybox-morello + install -m 0755 ${S}/busybox ${D}/busybox-morello/busybox } diff --git a/meta-morello/recipes-morello/images/morello-fvp/files/init.sh b/meta-morello/recipes-morello/images/files/init.sh similarity index 51% rename from meta-morello/recipes-morello/images/morello-fvp/files/init.sh rename to meta-morello/recipes-morello/images/files/init.sh index 1806644..c7d96e6 100644 --- a/meta-morello/recipes-morello/images/morello-fvp/files/init.sh +++ b/meta-morello/recipes-morello/images/files/init.sh @@ -1,35 +1,43 @@ -#!/bin/busybox sh +#!/busybox-morello/busybox sh
mount() { - /bin/busybox mount "$@" + /busybox-morello/busybox mount "$@" }
umount() { - /bin/busybox umount "$@" + /busybox-morello/busybox umount "$@" }
grep() { - /bin/busybox grep "$@" + /busybox-morello/busybox grep "$@" }
cp() { - /bin/busybox cp "$@" + /busybox-morello/busybox cp "$@" }
mkdir() { - /bin/busybox mkdir "$@" + /busybox-morello/busybox mkdir "$@" }
switch_root () { - /bin/busybox switch_root "$@" + /busybox-morello/busybox switch_root "$@" }
sed () { - /bin/busybox sed "$@" + /busybox-morello/busybox sed "$@" }
echo "Running init script"
+mkdir -m 0755 bin +mkdir -m 0755 include +mkdir -m 0755 share +mkdir -m 0755 proc +mkdir -m 0755 sys + +cp /busybox-morello/busybox /bin/busybox + mount -t proc proc /proc grep -qE $'\t'"devtmpfs$" /proc/filesystems && mount -t devtmpfs dev /dev mount -t sysfs sysfs /sys diff --git a/meta-morello/recipes-morello/images/morello-fvp/files/initramfs.list.template b/meta-morello/recipes-morello/images/files/initramfs.list.template similarity index 100% rename from meta-morello/recipes-morello/images/morello-fvp/files/initramfs.list.template rename to meta-morello/recipes-morello/images/files/initramfs.list.template diff --git a/meta-morello/recipes-morello/images/morello-initramfs-image.bb b/meta-morello/recipes-morello/images/morello-initramfs-image.bb new file mode 100644 index 0000000..5109129 --- /dev/null +++ b/meta-morello/recipes-morello/images/morello-initramfs-image.bb @@ -0,0 +1,24 @@ +inherit core-image + +DESCRIPTION = "Small image with purecap dev environment and minimal bloat." +LICENSE = "MIT" + +INITRAMFS_SCRIPTS ?= "\ + morello-initramfs-scripts \ + " + +PACKAGE_INSTALL = "${INITRAMFS_SCRIPTS}" +PACKAGE_INSTALL += "musl-libc busybox-morello pure-cap-app llvm-morello gdbserver gdb llvm-morello-staticdev" + +IMAGE_FEATURES = "" + +export IMAGE_BASENAME = "initramfs" +IMAGE_NAME_SUFFIX ?= "" +IMAGE_LINGUAS = "" + +IMAGE_FSTYPES = "${INITRAMFS_FSTYPES}" + +IMAGE_ROOTFS_SIZE = "8192" +IMAGE_ROOTFS_EXTRA_SPACE = "0" + +COMPATIBLE_HOST = '(x86_64.*|i.86.*|arm.*|aarch64.*)-(linux.*|freebsd.*)' diff --git a/meta-morello/recipes-morello/images/morello-initramfs-scripts.bb b/meta-morello/recipes-morello/images/morello-initramfs-scripts.bb new file mode 100644 index 0000000..ac777da --- /dev/null +++ b/meta-morello/recipes-morello/images/morello-initramfs-scripts.bb @@ -0,0 +1,19 @@ +COMPATIBLE_MACHINE = "morello" +SUMMARY = "Morello initramfs" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" + +FILESEXTRAPATHS:prepend := "${THISDIR}:" + +RDEPENDS:${PN} += "busybox-morello" + +SRC_URI = "file://files/init.sh \ + " + +S = "${WORKDIR}" + +do_install() { + install -m 0755 ${WORKDIR}/files/init.sh ${D}/init +} + +FILES:${PN} = "/init" \ No newline at end of file diff --git a/meta-morello/recipes-morello/images/morello-initramfs.bb b/meta-morello/recipes-morello/images/morello-initramfs.bb deleted file mode 100644 index 4d5e159..0000000 --- a/meta-morello/recipes-morello/images/morello-initramfs.bb +++ /dev/null @@ -1,57 +0,0 @@ -inherit deploy nopackages - -COMPATIBLE_MACHINE = "morello" -SUMMARY = "Initramfs for busybox" -DESCRIPTION = "Initramfs for busybox, bypassing the Yocto way" -LICENSE = "MIT" -LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" -OUTPUTS_NAME = "morello-initramfs" - -PACKAGE_ARCH = "${MACHINE_ARCH}" - -DEPENDS += "virtual/morello-busybox gen-init-cpio-native" -PROVIDES = "${OUTPUTS_NAME}" - -BB_DONT_CACHE = "1" -INHIBIT_DEFAULT_DEPS = "1" - -FILESEXTRAPATHS:prepend := "${THISDIR}:" - -SRC_URI = "file://files/init.sh \ - file://files/initramfs.list.template \ - " -do_configure[noexec] = "1" -do_compile[noexec] = "1" -do_deploy[depends] = "virtual/morello-busybox:do_populate_sysroot" - - -do_install() { - - local sysroot_prefix="recipe-sysroot" - - sed -e "s@%FILES%@/files@" \ - "${WORKDIR}/files/initramfs.list.template" > "${WORKDIR}/files/initramfs.list.tmp1" - - sed -e "s@%BUSYBOX%@/${sysroot_prefix}/busybox@" \ - "${WORKDIR}/files/initramfs.list.tmp1" > "${WORKDIR}/files/initramfs.list" - - install -d ${D}/${OUTPUTS_NAME} - - rm -f ${D}/${OUTPUTS_NAME}/initramfs - - { - env -C ${WORKDIR} ${STAGING_BINDIR_NATIVE}/gen_init_cpio "${WORKDIR}/files/initramfs.list" - } > ${D}/${OUTPUTS_NAME}/initramfs - -} - -do_deploy() { - install -d ${DEPLOYDIR}/${OUTPUTS_NAME} - install ${D}/${OUTPUTS_NAME}/initramfs ${DEPLOYDIR}/${OUTPUTS_NAME}/initramfs -} -addtask deploy after do_install - -do_image_complete() { - echo "Image complete" -} -addtask image_complete before do_build diff --git a/meta-morello/recipes-morello/images/morello-soc/files/init.sh b/meta-morello/recipes-morello/images/morello-soc/files/init.sh deleted file mode 100644 index 1806644..0000000 --- a/meta-morello/recipes-morello/images/morello-soc/files/init.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/busybox sh - -mount() { - /bin/busybox mount "$@" -} - -umount() { - /bin/busybox umount "$@" -} - -grep() { - /bin/busybox grep "$@" -} - -cp() { - /bin/busybox cp "$@" -} - -mkdir() { - /bin/busybox mkdir "$@" -} - -switch_root () { - /bin/busybox switch_root "$@" -} - -sed () { - /bin/busybox sed "$@" -} - -echo "Running init script" - -mount -t proc proc /proc -grep -qE $'\t'"devtmpfs$" /proc/filesystems && mount -t devtmpfs dev /dev -mount -t sysfs sysfs /sys - -echo "Installing busybox..." - -/bin/busybox --install -s - -! grep -qE $'\t'"devtmpfs$" /proc/filesystems && mdev -s - -echo "/bin/sh as PID 1!" -echo "init.sh" -exec setsid cttyhack sh -echo setsid ctty hack failed so "exec /bin/sh" fallback will be used -exec /bin/sh \ No newline at end of file diff --git a/meta-morello/recipes-morello/images/morello-soc/files/initramfs.list.template b/meta-morello/recipes-morello/images/morello-soc/files/initramfs.list.template deleted file mode 100644 index da55738..0000000 --- a/meta-morello/recipes-morello/images/morello-soc/files/initramfs.list.template +++ /dev/null @@ -1,16 +0,0 @@ -dir /bin 755 0 0 -dir /include 755 0 0 -dir /lib 755 0 0 -dir /share 755 0 0 -dir /dev 755 0 0 -dir /proc 755 0 0 -dir /sbin 755 0 0 -dir /sys 755 0 0 -dir /newroot 755 0 0 -dir /usr 755 0 0 -dir /usr/lib 755 0 0 -dir /usr/bin 755 0 0 -dir /etc 755 0 0 - -file /bin/busybox .%BUSYBOX%/busybox 755 0 0 -file /init .%FILES%/init.sh 755 0 0 \ No newline at end of file diff --git a/meta-morello/wic/morello-efidisk.wks b/meta-morello/wic/morello-efidisk.wks index eda618a..dd8cfa7 100644 --- a/meta-morello/wic/morello-efidisk.wks +++ b/meta-morello/wic/morello-efidisk.wks @@ -2,8 +2,8 @@ # long-description: Creates a partitioned EFI disk image that the user # can directly dd to boot media. Uses a custom grub.cfg file to configure the boot.
-part /boot --source bootimg-efi --sourceparams="loader=grub-efi,initrd=morello-initramfs/initramfs,file=morello-initramfs/initramfs" --ondisk sda --label msdos --active --align 1024 +part /boot --source bootimg-efi --sourceparams="loader=grub-efi,initrd=initramfs-${MACHINE}.cpio.gz,file=initramfs-${MACHINE}.cpio.gz" --ondisk sda --label msdos --active --align 1024
part / --source rootfs --ondisk sda --fstype=ext4 --label root --align 1024 --uuid=70ead9cb-4d31-4ffa-8127-7cc8c720eaa8
-bootloader --ptable gpt --configfile="${MACHINE}-grub.cfg" +bootloader --ptable gpt --configfile="${MACHINE}-grub.cfg" \ No newline at end of file diff --git a/meta-morello/wic/morello-fvp-grub.cfg b/meta-morello/wic/morello-fvp-grub.cfg index 72c2030..bcf46a7 100644 --- a/meta-morello/wic/morello-fvp-grub.cfg +++ b/meta-morello/wic/morello-fvp-grub.cfg @@ -22,7 +22,7 @@ menuentry 'BusyBox Morello Platform (ACPI) : a64 + c64 sysroot' { root=PARTUUID=70ead9cb-4d31-4ffa-8127-7cc8c720eaa8 \ }
-menuentry 'BusyBox Morello Platform (Device Tree): initramfs pure c64' { +menuentry 'BusyBox Morello Platform (Device Tree): initramfs a64 (min bloat) + c64 sysroot' { devicetree /morello-fvp.dtb linux /Image \ acpi=off \ @@ -31,5 +31,5 @@ menuentry 'BusyBox Morello Platform (Device Tree): initramfs pure c64' { ip=dhcp \ root=PARTUUID=70ead9cb-4d31-4ffa-8127-7cc8c720eaa8 \
- initrd /initramfs + initrd /initramfs-morello-fvp.cpio.gz } \ No newline at end of file diff --git a/meta-morello/wic/morello-soc-grub.cfg b/meta-morello/wic/morello-soc-grub.cfg index 5356269..c0841fd 100644 --- a/meta-morello/wic/morello-soc-grub.cfg +++ b/meta-morello/wic/morello-soc-grub.cfg @@ -23,7 +23,7 @@ menuentry 'BusyBox Morello Platform (ACPI) : a64 + c64 sysroot' { root=PARTUUID=70ead9cb-4d31-4ffa-8127-7cc8c720eaa8 \ }
-menuentry 'BusyBox Morello Platform (Device Tree): initramfs pure c64' { +menuentry 'BusyBox Morello Platform (Device Tree): initramfs a64 (min bloat) + c64 sysroot' { devicetree /morello-soc.dtb linux /Image \ acpi=off \ @@ -33,5 +33,5 @@ menuentry 'BusyBox Morello Platform (Device Tree): initramfs pure c64' { ip=dhcp \ root=PARTUUID=70ead9cb-4d31-4ffa-8127-7cc8c720eaa8 \
- initrd /initramfs + initrd /initramfs-morello-soc.cpio.gz } \ No newline at end of file