diff options
Diffstat (limited to 'meta-netboot')
-rw-r--r-- | meta-netboot/README | 15 | ||||
-rw-r--r-- | meta-netboot/README.renesas-gen3 | 90 | ||||
-rw-r--r-- | meta-netboot/classes/netboot.bbclass | 5 | ||||
-rw-r--r-- | meta-netboot/conf/include/agl-netboot.inc | 7 | ||||
-rw-r--r-- | meta-netboot/conf/layer.conf | 6 | ||||
-rw-r--r-- | meta-netboot/recipes-core/busybox/busybox_%.bbappend | 7 | ||||
-rw-r--r-- | meta-netboot/recipes-core/busybox/busybox_netboot.inc | 6 | ||||
-rw-r--r-- | meta-netboot/recipes-core/images/initramfs-netboot-image.bb | 23 | ||||
-rw-r--r-- | meta-netboot/recipes-core/images/initramfs-netboot-image_netboot.inc | 23 | ||||
-rw-r--r-- | meta-netboot/recipes-core/initramfs-netboot/files/init.sh | 31 | ||||
-rw-r--r-- | meta-netboot/recipes-core/initramfs-netboot/initramfs-netboot_1.0.bb | 12 | ||||
-rw-r--r-- | meta-netboot/recipes-core/systemd/files/resolv-conf-relabel.service | 14 | ||||
-rw-r--r-- | meta-netboot/recipes-core/systemd/resolv-conf-relabel.bb | 21 | ||||
-rw-r--r-- | meta-netboot/recipes-support/nbd/nbd_%.bbappend | 7 | ||||
-rw-r--r-- | meta-netboot/recipes-support/nbd/nbd_netboot.inc | 5 | ||||
-rwxr-xr-x | meta-netboot/scripts/run-yocto-check-layer.sh | 44 |
16 files changed, 164 insertions, 152 deletions
diff --git a/meta-netboot/README b/meta-netboot/README index 7efa22650..a30238b9d 100644 --- a/meta-netboot/README +++ b/meta-netboot/README @@ -3,6 +3,19 @@ meta-netboot This layer contains some recipes and configuration adjustments to allow network boot through NBD (network block device). +Maintenance +----------- + +All patches must be submitted via the AGL Gerrit instance at +https://gerrit.automotivelinux.org. See this wiki page for +details: + +https://wiki.automotivelinux.org/agl-distro/contributing + +Layer maintainers: + Jan-Simon Möller <jsmoeller@linuxfoundation.org> + + Content and usage ----------------- @@ -59,7 +72,7 @@ setenv bootargs_root 'root=/dev/ram0 ramdisk_size=16384 ip=dhcp' setenv bootargs_video 'vmalloc=384M video=HDMI-A-1:1920x1080-32@60' setenv serverip '<your_serverip>' setenv 'bootdaddr' '0x48000000' -setenv 'bootdfile' 'Image-r8a7795-h3ulcb.dtb' +setenv 'bootdfile' 'Image-r8a77951-ulcb.dtb' setenv 'bootdload_net' 'tftp ${bootdaddr} h3ulcb/${bootdfile}' setenv 'bootkaddr' '0x48080000' setenv 'bootkfile' 'Image' diff --git a/meta-netboot/README.renesas-gen3 b/meta-netboot/README.renesas-gen3 deleted file mode 100644 index 496141eef..000000000 --- a/meta-netboot/README.renesas-gen3 +++ /dev/null @@ -1,90 +0,0 @@ -Below are the environment variables that can be set in the u-boot console to boot the Renesas Gen3 ULCB boards. - -Adjust board type with the following identifiers: - -* 'm3ulcb' for Renesas Gen3 Starter Kit Pro -* 'h3ulcb' for Renesas Gen3 Starter Kit Premium - -################## Common options ##################### -# these options are common to all configurations: - -##### board info - -# choose board -setenv board m3ulcb -setenv soc r8a7796 -# or -setenv board h3ulcb -setenv soc r8a7795 - -##### boot mode -# choose bootmode: -# netboot -setenv bootmode net -# or sdcard -setenv bootmode sd -# or sdcard with initrd -setenv bootmode sdi - -##### sdcard options -# which sdcard slot to use -setenv bootmmc '0:1' - -##### netboot options -# replace <IP> and <NUM> by appropriate addresses -setenv ipaddr '<board_IP>' -setenv serverip '<server_IP>' -setenv ethact ravb -setenv ethaddr DE:AD:C0:FF:EE:<NUM> - -################## Internal variables ##################### - -# kernel file -setenv set_bootkfile 'setenv bootkfile Image' -setenv bootkaddr 0x48080000 - -# dtb file -setenv set_bootdfile 'setenv bootdfile Image-${soc}-${board}.dtb' -setenv bootdaddr 0x48000000 - -# initrd -setenv set_bootifile 'setenv bootifile initramfs-netboot-image-${board}.ext4.gz' -setenv bootiaddr 0x5C3F9520 -setenv bootisize 3A6AB6 - -# kernel args -setenv bootargs_console 'console=ttySC0,115200 ignore_loglevel' -setenv bootargs_video 'vmalloc=384M video=HDMI-A-1:1920x1080-32@60' -setenv bootargs_extra 'rw rootfstype=ext4 rootwait rootdelay=2' - -# final boot command -setenv bootcmd 'run bootcmd_${bootmode}' - -################ Boot on MMC (SDcard) ################# - -setenv bootkload_sd 'ext4load mmc ${bootmmc} ${bootkaddr} boot/${bootkfile}' -setenv bootiload_sd 'ext4load mmc ${bootmmc} ${bootiaddr} boot/${bootifile}' -setenv bootdload_sd 'ext4load mmc ${bootmmc} ${bootdaddr} boot/${bootdfile}' - -# without initrd -setenv bootargs_root_sd 'root=/dev/mmcblk1p1' -setenv bootload_sd 'run set_bootkfile; run bootkload_sd; run set_bootdfile; run bootdload_sd' -setenv bootcmd_sd 'setenv bootargs ${bootargs_console} ${bootargs_video} ${bootargs_root_sd} ${bootargs_extra}; run bootload_sd; booti ${bootkaddr} - ${bootdaddr}' - -# with initrd -setenv bootargs_root_sdi 'root=/dev/ram0 ramdisk_size=16384' -setenv bootload_sdi 'run set_bootkfile; run bootkload_sd; run set_bootdfile; run bootdload_sd; run set_bootifile; run bootiload_sd' -setenv bootcmd_sdi 'setenv bootargs ${bootargs_console} ${bootargs_video} ${bootargs_root_sdi} ${bootargs_extra}; run bootload_sdi; booti ${bootkaddr} ${bootiaddr}:${bootisize} ${bootdaddr}' - -################ Netboot through TFTP+NBD ################## - -setenv bootkload_net 'tftp ${bootkaddr} ${board}/${bootkfile}' -setenv bootdload_net 'tftp ${bootdaddr} ${board}/${bootdfile}' -setenv bootiload_net 'tftp ${bootiaddr} ${board}/${bootifile}' - -setenv bootargs_root_net 'root=/dev/ram0 ramdisk_size=16384 ip=dhcp' -setenv bootload_net 'run set_bootkfile; run bootkload_net; run set_bootdfile; run bootdload_net; run set_bootifile; run bootiload_net' - -setenv bootcmd_net 'setenv bootargs ${bootargs_console} ${bootargs_video} ${bootargs_root_net} ${bootargs_extra} nbd.server=${serverip}; run bootload_net; booti ${bootkaddr} ${bootiaddr}:${bootisize} ${bootdaddr}' - - diff --git a/meta-netboot/classes/netboot.bbclass b/meta-netboot/classes/netboot.bbclass index 63369285f..a18d64f5b 100644 --- a/meta-netboot/classes/netboot.bbclass +++ b/meta-netboot/classes/netboot.bbclass @@ -1,5 +1,10 @@ # Enable network bootable image and initrd/initramfs +OVERRIDES .= ":netboot" +# add 512MB of extra space in ext4 output image +IMAGE_ROOTFS_EXTRA_SPACE = "524288" +NETBOOT_ENABLED ??= "1" + python () { if (bb.utils.contains("IMAGE_FSTYPES","live",True,False,d)): # typical case for Minnowboard Max diff --git a/meta-netboot/conf/include/agl-netboot.inc b/meta-netboot/conf/include/agl-netboot.inc index fcff8c318..2c1307e81 100644 --- a/meta-netboot/conf/include/agl-netboot.inc +++ b/meta-netboot/conf/include/agl-netboot.inc @@ -1,5 +1,6 @@ INHERIT += "netboot" -OVERRIDES .= ":netboot" -# add 512MB of extra space in ext4 output image -IMAGE_ROOTFS_EXTRA_SPACE = "524288" +IMAGE_INSTALL:append:netboot = " \ + curl \ + ${@bb.utils.contains('DISTRO_FEATURES', 'selinux', 'resolv-conf-relabel policycoreutils-loadpolicy', '', d)} \ +" diff --git a/meta-netboot/conf/layer.conf b/meta-netboot/conf/layer.conf index 50def90fc..a41406cbb 100644 --- a/meta-netboot/conf/layer.conf +++ b/meta-netboot/conf/layer.conf @@ -1,6 +1,3 @@ -# Added for futur conditionnals tests -DISTRO_FEATURES_append = " netboot" - # We have a conf and classes directory, add to BBPATH BBPATH .= ":${LAYERDIR}" @@ -12,4 +9,5 @@ BBFILE_COLLECTIONS += "meta-netboot" BBFILE_PATTERN_meta-netboot = "^${LAYERDIR}/" BBFILE_PRIORITY_meta-netboot = "60" -LAYERSERIES_COMPAT_meta-netboot = "dunfell" +LAYERSERIES_COMPAT_meta-netboot = "scarthgap" +LAYERDEPENDS_meta-netboot = "core networking-layer" diff --git a/meta-netboot/recipes-core/busybox/busybox_%.bbappend b/meta-netboot/recipes-core/busybox/busybox_%.bbappend index 358913448..fcf6acfd1 100644 --- a/meta-netboot/recipes-core/busybox/busybox_%.bbappend +++ b/meta-netboot/recipes-core/busybox/busybox_%.bbappend @@ -1,6 +1 @@ -FILESEXTRAPATHS_prepend := "${THISDIR}/files:" - -SRC_URI += " \ - file://enable_nbd.cfg \ - " - +require ${@bb.utils.contains('NETBOOT_ENABLED', '1', 'busybox_netboot.inc', '', d)} diff --git a/meta-netboot/recipes-core/busybox/busybox_netboot.inc b/meta-netboot/recipes-core/busybox/busybox_netboot.inc new file mode 100644 index 000000000..836493834 --- /dev/null +++ b/meta-netboot/recipes-core/busybox/busybox_netboot.inc @@ -0,0 +1,6 @@ +FILESEXTRAPATHS:prepend := "${THISDIR}/files:" + +SRC_URI:append = " \ + file://enable_nbd.cfg \ + " + diff --git a/meta-netboot/recipes-core/images/initramfs-netboot-image.bb b/meta-netboot/recipes-core/images/initramfs-netboot-image.bb index 965a0bd37..b5610f30d 100644 --- a/meta-netboot/recipes-core/images/initramfs-netboot-image.bb +++ b/meta-netboot/recipes-core/images/initramfs-netboot-image.bb @@ -1,23 +1,2 @@ -# Netboot initramfs image. -DESCRIPTION = "Netboot initrd image" - -PACKAGE_INSTALL = "initramfs-netboot busybox base-passwd ${ROOTFS_BOOTSTRAP_INSTALL}" - -# Do not pollute the initrd image with rootfs features -IMAGE_FEATURES = "" - -export IMAGE_BASENAME = "initramfs-netboot-image" -IMAGE_LINGUAS = "" - LICENSE = "MIT" - -IMAGE_FSTYPES := "${NETBOOT_FSTYPES}" -inherit core-image - -# hotfix for dragonboard (which uses _append in the bsp) -IMAGE_FSTYPES_remove += "wic.gz" - -IMAGE_ROOTFS_SIZE = "8192" -IMAGE_ROOTFS_EXTRA_SPACE = "256" - -BAD_RECOMMENDATIONS += "busybox-syslog" +require ${@bb.utils.contains('NETBOOT_ENABLED', '1', 'initramfs-netboot-image_netboot.inc', '', d)} diff --git a/meta-netboot/recipes-core/images/initramfs-netboot-image_netboot.inc b/meta-netboot/recipes-core/images/initramfs-netboot-image_netboot.inc new file mode 100644 index 000000000..b98024de6 --- /dev/null +++ b/meta-netboot/recipes-core/images/initramfs-netboot-image_netboot.inc @@ -0,0 +1,23 @@ +# Netboot initramfs image. +DESCRIPTION = "Netboot initrd image" + +PACKAGE_INSTALL = "initramfs-netboot busybox base-passwd ${ROOTFS_BOOTSTRAP_INSTALL}" + +# Do not pollute the initrd image with rootfs features +IMAGE_FEATURES = "" + +export IMAGE_BASENAME = "initramfs-netboot-image" +IMAGE_LINGUAS = "" + +LICENSE = "MIT" + +IMAGE_FSTYPES := "${NETBOOT_FSTYPES}" +inherit core-image + +# hotfix for dragonboard (which uses _append in the bsp) +IMAGE_FSTYPES:remove = "wic.gz" + +IMAGE_ROOTFS_SIZE = "8192" +IMAGE_ROOTFS_EXTRA_SPACE = "256" + +BAD_RECOMMENDATIONS += "busybox-syslog" diff --git a/meta-netboot/recipes-core/initramfs-netboot/files/init.sh b/meta-netboot/recipes-core/initramfs-netboot/files/init.sh index 2b8bc63d0..87a1acb80 100644 --- a/meta-netboot/recipes-core/initramfs-netboot/files/init.sh +++ b/meta-netboot/recipes-core/initramfs-netboot/files/init.sh @@ -21,7 +21,6 @@ EOF # global variables -SMACK=n NBD_SERVER= NBD_PORT=10809 NBD_DEV=/dev/nbd0 @@ -109,17 +108,6 @@ check_debug "Debug point 1. Exit to continue initrd script (mount NBD device)." log_info "NBD parameters: device $NBD_DEV, server $NBD_SERVER:$NBD_PORT" -# check if smack is active (and if so, mount smackfs) -grep -q smackfs /proc/filesystems && { - SMACK=y - - do_mount_fs smackfs /sys/fs/smackfs - - # adjust current label and network label - echo System >/proc/self/attr/current - echo System >/sys/fs/smackfs/ambient -} - # start nbd client try=5 while :;do @@ -165,9 +153,24 @@ fi # also use /proc/net/pnp to generate /etc/resolv.conf rm -f /etc/resolv.conf grep -v bootserver /proc/net/pnp | sed 's/^domain/search/g' >/etc/resolv.conf -chsmack -A /etc/resolv.conf -# unmount tmp and run to let systemd remount them with correct smack labels (SPEC-2596) +# Do SELinux relabeling if required, to avoid a reboot that would complicate CI +if [ -f /.autorelabel ]; then + # Nothing SELinux related works w/o the fs mounted + do_mount_fs selinuxfs /sys/fs/selinux + + # Labeling requires the policy to be loaded + log_info "Loading SELinux policy" + /usr/sbin/load_policy + + /usr/bin/selinux-autorelabel.sh + + # Will get remounted by systemd startup, unmount to keep that behavior + # more like the non-netboot case. + umount /sys/fs/selinux +fi + +# unmount tmp and run to let systemd remount them log_info "Unmounting /tmp and /run" umount /tmp umount /run diff --git a/meta-netboot/recipes-core/initramfs-netboot/initramfs-netboot_1.0.bb b/meta-netboot/recipes-core/initramfs-netboot/initramfs-netboot_1.0.bb index f519694ed..dd61a1ea8 100644 --- a/meta-netboot/recipes-core/initramfs-netboot/initramfs-netboot_1.0.bb +++ b/meta-netboot/recipes-core/initramfs-netboot/initramfs-netboot_1.0.bb @@ -5,17 +5,17 @@ SRC_URI = "file://init.sh" S = "${WORKDIR}" -RDEPENDS_${PN} += "nbd-client" +RDEPENDS:${PN} += "nbd-client" do_install() { - install -dm 0755 ${D}/etc - touch ${D}/etc/initrd-release + install -dm 0755 ${D}${sysconfdir} + touch ${D}${sysconfdir}/initrd-release install -dm 0755 ${D}/dev - install -dm 0755 ${D}/sbin - install -m 0755 ${WORKDIR}/init.sh ${D}/sbin/init + install -dm 0755 ${D}${sbindir} + install -m 0755 ${WORKDIR}/init.sh ${D}${sbindir}/init } inherit allarch -FILES_${PN} += " /dev /etc/initrd-release /sbin/init " +FILES:${PN} += " /dev ${sysconfdir}/initrd-release ${sbindir}/init " diff --git a/meta-netboot/recipes-core/systemd/files/resolv-conf-relabel.service b/meta-netboot/recipes-core/systemd/files/resolv-conf-relabel.service new file mode 100644 index 000000000..5d9216cc2 --- /dev/null +++ b/meta-netboot/recipes-core/systemd/files/resolv-conf-relabel.service @@ -0,0 +1,14 @@ +[Unit] +Description=SELinux resolv.conf relabeling +DefaultDependencies=no +ConditionKernelCommandLine=ip +ConditionKernelCommandLine=nbd.server +After=local-fs.target +Before=sysinit.target + +[Service] +Type=oneshot +ExecStart=/usr/sbin/restorecon -Fi /etc/resolv.conf + +[Install] +WantedBy=sysinit.target diff --git a/meta-netboot/recipes-core/systemd/resolv-conf-relabel.bb b/meta-netboot/recipes-core/systemd/resolv-conf-relabel.bb new file mode 100644 index 000000000..36d096b44 --- /dev/null +++ b/meta-netboot/recipes-core/systemd/resolv-conf-relabel.bb @@ -0,0 +1,21 @@ +SUMMARY = "System unit to relabel resolve.conf" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" + +SRC_URI = "file://resolv-conf-relabel.service" + +inherit systemd allarch features_check + +SYSTEMD_SERVICE:${PN} = "${BPN}.service" + +REQUIRED_DISTRO_FEATURES = "systemd" + +do_configure[noexec] = "1" +do_compile[noexec] = "1" + +do_install() { + install -d ${D}${systemd_system_unitdir} + install -m 0644 ${WORKDIR}/resolv-conf-relabel.service ${D}${systemd_system_unitdir}/ +} + +FILES:${PN} += "${systemd_system_unitdir}" diff --git a/meta-netboot/recipes-support/nbd/nbd_%.bbappend b/meta-netboot/recipes-support/nbd/nbd_%.bbappend index fb11ef9c2..e67e591ff 100644 --- a/meta-netboot/recipes-support/nbd/nbd_%.bbappend +++ b/meta-netboot/recipes-support/nbd/nbd_%.bbappend @@ -1,6 +1 @@ - -do_install_append() { - mv ${D}/${sbindir}/${BPN}-client ${D}/${sbindir}/${BPN}3-client -} - -FILES_${PN}-client = "${sbindir}/${BPN}3-client" +require ${@bb.utils.contains('NETBOOT_ENABLED', '1', 'nbd_netboot.inc', '', d)} diff --git a/meta-netboot/recipes-support/nbd/nbd_netboot.inc b/meta-netboot/recipes-support/nbd/nbd_netboot.inc new file mode 100644 index 000000000..4c9489de1 --- /dev/null +++ b/meta-netboot/recipes-support/nbd/nbd_netboot.inc @@ -0,0 +1,5 @@ +do_install:append() { + mv ${D}/${sbindir}/nbd-client ${D}/${sbindir}/nbd3-client +} + +FILES:${PN}-client:append = " ${sbindir}/nbd3-client" diff --git a/meta-netboot/scripts/run-yocto-check-layer.sh b/meta-netboot/scripts/run-yocto-check-layer.sh new file mode 100755 index 000000000..979c76838 --- /dev/null +++ b/meta-netboot/scripts/run-yocto-check-layer.sh @@ -0,0 +1,44 @@ +#!/bin/bash +#set -x + +SCRIPTPATH="$( cd $(dirname $0) >/dev/null 2>&1 ; pwd -P )" +echo $SCRIPTPATH +AGLROOT="$SCRIPTPATH/../../.." +POKYDIR="$AGLROOT/external/poky" +TMPROOT=`mktemp -d` + +rm -rf ${TMPROOT}/testbuild-ycl || true +mkdir -p ${TMPROOT}/testbuild-ycl +cd ${TMPROOT}/testbuild-ycl + +source $POKYDIR/oe-init-build-env . + +cat << EOF >> conf/local.conf +# just define defaults +AGL_FEATURES ?= "" +AGL_EXTRA_IMAGE_FSTYPES ?= "" + +# important settings imported from poky-agl.conf +# we cannot import the distro config right away +# as the initial values are poky only till the layer +# is added in + +AGL_DEFAULT_DISTRO_FEATURES = "usrmerge largefile opengl wayland pam bluetooth bluez5 3g polkit" +DISTRO_FEATURES:append = " systemd wayland pam \${AGL_DEFAULT_DISTRO_FEATURES}" +DISTRO_FEATURES_BACKFILL_CONSIDERED:append = " sysvinit" +VIRTUAL-RUNTIME_init_manager = "systemd" + +EOF + +yocto-check-layer --no-auto-dependency \ + --dependency \ + $AGLROOT/external/meta-openembedded/meta-oe \ + $AGLROOT/external/meta-openembedded/meta-python \ + $AGLROOT/external/meta-openembedded/meta-networking \ + -- \ + $AGLROOT/meta-agl/meta-netboot + + +[ $? = 0 ] && rm -rf ${TMPROOT}/testbuild-ycl + +exit 0 |