From 4d610e9f230dd23589b18588446c2368f3a99446 Mon Sep 17 00:00:00 2001 From: Anton Gerasimov Date: Tue, 25 Apr 2017 15:21:07 +0200 Subject: Replace includes with bblcasses They are more flexible and allow tricks like conditionally inheriting machine-related classes from the main one which makes things easier for external users like AGL --- README.adoc | 2 +- classes/sota.bbclass | 33 ++++++++++++++++++++++++++ classes/sota_bleeding.inc | 1 + classes/sota_minnowboard.bbclass | 7 ++++++ classes/sota_minnowboard_uboot.inc | 8 +++++++ classes/sota_none.bbclass | 1 + classes/sota_porter.bbclass | 10 ++++++++ classes/sota_qemux86-64.bbclass | 9 +++++++ classes/sota_raspberrypi.bbclass | 12 ++++++++++ conf/distro/poky-sota-systemd.conf | 2 +- conf/distro/poky-sota.conf | 2 +- conf/distro/sota.conf.inc | 25 ------------------- conf/include/bblayers/sota_intel-corei7-64.inc | 2 ++ conf/include/bblayers/sota_minnowboard.inc | 2 -- conf/include/bblayers/sota_raspberrypi.inc | 2 -- conf/include/bblayers/sota_raspberrypi2.inc | 2 ++ conf/include/bblayers/sota_raspberrypi3.inc | 2 ++ conf/include/local/sota_bleeding.inc | 1 - conf/include/local/sota_minnowboard.inc | 9 ------- conf/include/local/sota_minnowboard_uboot.inc | 10 -------- conf/include/local/sota_porter.inc | 12 ---------- conf/include/local/sota_qemux86-64.inc | 11 --------- conf/include/local/sota_raspberrypi.inc | 14 ----------- scripts/envsetup.sh | 8 +------ 24 files changed, 91 insertions(+), 96 deletions(-) create mode 100644 classes/sota.bbclass create mode 100644 classes/sota_bleeding.inc create mode 100644 classes/sota_minnowboard.bbclass create mode 100644 classes/sota_minnowboard_uboot.inc create mode 100644 classes/sota_none.bbclass create mode 100644 classes/sota_porter.bbclass create mode 100644 classes/sota_qemux86-64.bbclass create mode 100644 classes/sota_raspberrypi.bbclass delete mode 100644 conf/distro/sota.conf.inc create mode 100644 conf/include/bblayers/sota_intel-corei7-64.inc delete mode 100644 conf/include/bblayers/sota_minnowboard.inc delete mode 100644 conf/include/bblayers/sota_raspberrypi.inc create mode 100644 conf/include/bblayers/sota_raspberrypi2.inc create mode 100644 conf/include/bblayers/sota_raspberrypi3.inc delete mode 100644 conf/include/local/sota_bleeding.inc delete mode 100644 conf/include/local/sota_minnowboard.inc delete mode 100644 conf/include/local/sota_minnowboard_uboot.inc delete mode 100644 conf/include/local/sota_porter.inc delete mode 100644 conf/include/local/sota_qemux86-64.inc delete mode 100644 conf/include/local/sota_raspberrypi.inc diff --git a/README.adoc b/README.adoc index f8e8ada..e26497c 100644 --- a/README.adoc +++ b/README.adoc @@ -18,7 +18,7 @@ If you already have a Yocto-based project and you want to add atomic filesystem 1. Clone the `meta-updater` layer and add it to your https://www.yoctoproject.org/docs/2.1/ref-manual/ref-manual.html#structure-build-conf-bblayers.conf[bblayers.conf]. 2. Clone BSP integration layer (meta-updater-$\{PLATFORM}, e.g. https://github.com/advancedtelematic/meta-updater-raspberrypi[meta-updater-raspberrypi]) and add it to your conf/bblayers.conf. If your board isn't supported yet, you could write a BSP integration for it yourself. See the <> section for the details. -3. Set up your https://www.yoctoproject.org/docs/2.1/ref-manual/ref-manual.html#var-DISTRO[distro]. If you are using "poky", the default distro in Yocto, you can change it in your conf/local.conf to "poky-sota". Alternatively, if you are using your own or third party distro configuration, you can add 'require conf/distro/sota.conf.inc' to it, thus combining capabilities of your distro with meta-updater features. +3. Set up your https://www.yoctoproject.org/docs/2.1/ref-manual/ref-manual.html#var-DISTRO[distro]. If you are using "poky", the default distro in Yocto, you can change it in your conf/local.conf to "poky-sota". Alternatively, if you are using your own or third party distro configuration, you can add 'INHERIT += " sota"' to it, thus combining capabilities of your distro with meta-updater features. You can then build your image as usual, with bitbake. After building the root file system, bitbake will then create an https://ostree.readthedocs.io/en/latest/manual/adapting-existing/[OSTree-enabled version] of it, commit it to your local OSTree repo and (optionally) push it to a remote server. Additionally, a live disk image will be created (normally named $\{IMAGE_NAME}.-sdimg-ota e.g. core-image-raspberrypi3.rpi-sdimg-ota). You can control this behaviour through <>. diff --git a/classes/sota.bbclass b/classes/sota.bbclass new file mode 100644 index 0000000..0697932 --- /dev/null +++ b/classes/sota.bbclass @@ -0,0 +1,33 @@ +DISTRO_FEATURES_append = " sota" +OVERRIDES .= ":sota" + +IMAGE_INSTALL_append = " ostree os-release" + +# live image for OSTree-enabled systems +IMAGE_CLASSES += "image_types_ostree image_types_ota" +IMAGE_FSTYPES += "ostreepush otaimg" + +# if don't build wic image unless IMAGE_BOOT_FILES is set. Prevents build from failing +# on machines that don't support updater yet +IMAGE_FSTYPES += "${@' wic' if (d.getVar("IMAGE_BOOT_FILES", True)) else ''}" +WKS_FILE ?= "sdimage-sota.wks" +do_image_wic[depends] += "${IMAGE_BASENAME}:do_image_otaimg" + +EXTRA_IMAGEDEPENDS += " parted-native mtools-native dosfstools-native" + +# Please redefine OSTREE_REPO in order to have a persistent OSTree repo +OSTREE_REPO ?= "${DEPLOY_DIR_IMAGE}/ostree_repo" +OSTREE_BRANCHNAME ?= "ota-${MACHINE}" +OSTREE_OSNAME ?= "poky" +OSTREE_INITRAMFS_IMAGE ?= "initramfs-ostree-image" + +# Prelinking increases the size of downloads and causes build errors +USER_CLASSES_remove = "image-prelink" + +SOTA_MACHINE ?= "none" +SOTA_MACHINE_raspberrypi = "raspberrypi" +SOTA_MACHINE_raspberrypi3 = "raspberrypi" +SOTA_MACHINE_porter = "porter" +SOTA_MACHINE_intel-corei7-64 = "minnowboard" +SOTA_MACHINE_qemux86-64 = "qemux86-64" +inherit sota_${SOTA_MACHINE} diff --git a/classes/sota_bleeding.inc b/classes/sota_bleeding.inc new file mode 100644 index 0000000..fc5947d --- /dev/null +++ b/classes/sota_bleeding.inc @@ -0,0 +1 @@ +SRCREV_pn-aktualizr ?= "${AUTOREV}" diff --git a/classes/sota_minnowboard.bbclass b/classes/sota_minnowboard.bbclass new file mode 100644 index 0000000..970bd6a --- /dev/null +++ b/classes/sota_minnowboard.bbclass @@ -0,0 +1,7 @@ +OSTREE_BOOTLOADER ?= "grub" +EFI_PROVIDER = "grub-efi" + +WKS_FILE = "efiimage-sota.wks" +IMAGE_BOOT_FILES = "" + +OSTREE_KERNEL_ARGS ?= "ramdisk_size=16384 rw rootfstype=ext4 rootwait rootdelay=2 console=ttyS0,115200 console=tty0" diff --git a/classes/sota_minnowboard_uboot.inc b/classes/sota_minnowboard_uboot.inc new file mode 100644 index 0000000..5097e9d --- /dev/null +++ b/classes/sota_minnowboard_uboot.inc @@ -0,0 +1,8 @@ +PREFERRED_PROVIDER_virtual/bootloader = "u-boot-ota" +UBOOT_MACHINE = "minnowmax_defconfig" + +EXTRA_IMAGEDEPENDS_append = " minnowboard-bootfiles" +IMAGE_BOOT_FILES = "minnowboard-bootfiles/*" + +OSTREE_KERNEL_ARGS ?= "ramdisk_size=16384 rw rootfstype=ext4 rootwait rootdelay=2 ostree_root=/dev/hda console=ttyS0,115200 console=tty0" + diff --git a/classes/sota_none.bbclass b/classes/sota_none.bbclass new file mode 100644 index 0000000..dc72a07 --- /dev/null +++ b/classes/sota_none.bbclass @@ -0,0 +1 @@ +# null machine it's here to make bitbake happy when SOTA_MACHINE is undefined diff --git a/classes/sota_porter.bbclass b/classes/sota_porter.bbclass new file mode 100644 index 0000000..a8f5ba1 --- /dev/null +++ b/classes/sota_porter.bbclass @@ -0,0 +1,10 @@ +# Commit united image to OSTree, not just uImage +OSTREE_KERNEL = "uImage+dtb" + +EXTRA_IMAGEDEPENDS_append_sota = " porter-bootfiles" +IMAGE_CLASSES_append_sota = " image_types_uboot " +IMAGE_BOOT_FILES_sota += "porter-bootfiles/*" + +OSTREE_BOOTLOADER ?= "u-boot" +UBOOT_MACHINE_sota = "porter_config" + diff --git a/classes/sota_qemux86-64.bbclass b/classes/sota_qemux86-64.bbclass new file mode 100644 index 0000000..533c11c --- /dev/null +++ b/classes/sota_qemux86-64.bbclass @@ -0,0 +1,9 @@ +# See https://advancedtelematic.atlassian.net/browse/PRO-2693 +PREFERRED_VERSION_linux-yocto_qemux86-64_sota = "4.4%" + +# U-Boot support for SOTA +PREFERRED_PROVIDER_virtual/bootloader_sota = "u-boot-ota" +UBOOT_MACHINE_sota = "qemu-x86_defconfig" +OSTREE_BOOTLOADER ?= "u-boot" + +OSTREE_KERNEL_ARGS ?= "ramdisk_size=16384 rw rootfstype=ext4 rootwait rootdelay=2 ostree_root=/dev/hda" diff --git a/classes/sota_raspberrypi.bbclass b/classes/sota_raspberrypi.bbclass new file mode 100644 index 0000000..1d23d1f --- /dev/null +++ b/classes/sota_raspberrypi.bbclass @@ -0,0 +1,12 @@ +IMAGE_CLASSES += "${@bb.utils.contains('DISTRO_FEATURES', 'sota', 'image_types_uboot sdcard_image-rpi-ota', '', d)}" +IMAGE_FSTYPES += "${@bb.utils.contains('DISTRO_FEATURES', 'sota', 'rpi-sdimg-ota', 'rpi-sdimg', d)}" + +### both rpi-sdimg and rpi-sdimg-ota broken +IMAGE_FSTYPES += "ext4.xz ext4.bmap tar.xz" + +KERNEL_IMAGETYPE_sota = "uImage" +PREFERRED_PROVIDER_virtual/bootloader_sota ?= "u-boot" +UBOOT_MACHINE_raspberrypi2_sota ?= "rpi_2_defconfig" +UBOOT_MACHINE_raspberrypi3_sota ?= "rpi_3_32b_defconfig" + +OSTREE_BOOTLOADER ?= "u-boot" diff --git a/conf/distro/poky-sota-systemd.conf b/conf/distro/poky-sota-systemd.conf index 85744ea..e6f43f7 100644 --- a/conf/distro/poky-sota-systemd.conf +++ b/conf/distro/poky-sota-systemd.conf @@ -1,5 +1,4 @@ require conf/distro/poky.conf -require conf/distro/sota.conf.inc DISTRO = "poky-sota" DISTRO_NAME = "OTA-enabled Linux" @@ -9,4 +8,5 @@ DISTRO_CODENAME = "sota" DISTRO_FEATURES_append = " systemd" VIRTUAL-RUNTIME_init_manager = "systemd" +INHERIT += " sota" IMAGE_INSTALL_append = " connman connman-client rvi-sota-client" diff --git a/conf/distro/poky-sota.conf b/conf/distro/poky-sota.conf index 2bbc62b..6972a94 100644 --- a/conf/distro/poky-sota.conf +++ b/conf/distro/poky-sota.conf @@ -1,9 +1,9 @@ require conf/distro/poky.conf -require conf/distro/sota.conf.inc DISTRO = "poky-sota" DISTRO_NAME = "OTA-enabled Linux" DISTRO_VERSION = "1.0" DISTRO_CODENAME = "sota" +INHERIT += " sota" IMAGE_INSTALL_append = " connman connman-client" diff --git a/conf/distro/sota.conf.inc b/conf/distro/sota.conf.inc deleted file mode 100644 index 20946a6..0000000 --- a/conf/distro/sota.conf.inc +++ /dev/null @@ -1,25 +0,0 @@ -DISTRO_FEATURES_append = " sota" -OVERRIDES .= ":sota" - -IMAGE_INSTALL_append = " ostree os-release" - -# live image for OSTree-enabled systems -IMAGE_CLASSES += "image_types_ostree image_types_ota" -IMAGE_FSTYPES += "ostreepush otaimg" - -# if don't build wic image unless IMAGE_BOOT_FILES is set. Prevents build from failing -# on machines that don't support updater yet -IMAGE_FSTYPES += "${@' wic' if (d.getVar("IMAGE_BOOT_FILES", True)) else ''}" -WKS_FILE ?= "sdimage-sota.wks" -do_image_wic[depends] += "${IMAGE_BASENAME}:do_image_otaimg" - -EXTRA_IMAGEDEPENDS += " parted-native mtools-native dosfstools-native" - -# Please redefine OSTREE_REPO in order to have a persistent OSTree repo -OSTREE_REPO ?= "${DEPLOY_DIR_IMAGE}/ostree_repo" -OSTREE_BRANCHNAME ?= "ota-${MACHINE}" -OSTREE_OSNAME ?= "poky" -OSTREE_INITRAMFS_IMAGE ?= "initramfs-ostree-image" - -# Prelinking increases the size of downloads and causes build errors -USER_CLASSES_remove = "image-prelink" diff --git a/conf/include/bblayers/sota_intel-corei7-64.inc b/conf/include/bblayers/sota_intel-corei7-64.inc new file mode 100644 index 0000000..1771e6c --- /dev/null +++ b/conf/include/bblayers/sota_intel-corei7-64.inc @@ -0,0 +1,2 @@ + +BBLAYERS += " ${METADIR}/meta-updater-minnowboard ${METADIR}/meta-intel " diff --git a/conf/include/bblayers/sota_minnowboard.inc b/conf/include/bblayers/sota_minnowboard.inc deleted file mode 100644 index 1771e6c..0000000 --- a/conf/include/bblayers/sota_minnowboard.inc +++ /dev/null @@ -1,2 +0,0 @@ - -BBLAYERS += " ${METADIR}/meta-updater-minnowboard ${METADIR}/meta-intel " diff --git a/conf/include/bblayers/sota_raspberrypi.inc b/conf/include/bblayers/sota_raspberrypi.inc deleted file mode 100644 index 11ede20..0000000 --- a/conf/include/bblayers/sota_raspberrypi.inc +++ /dev/null @@ -1,2 +0,0 @@ - -BBLAYERS += " ${METADIR}/meta-updater-raspberrypi ${METADIR}/meta-raspberrypi " diff --git a/conf/include/bblayers/sota_raspberrypi2.inc b/conf/include/bblayers/sota_raspberrypi2.inc new file mode 100644 index 0000000..11ede20 --- /dev/null +++ b/conf/include/bblayers/sota_raspberrypi2.inc @@ -0,0 +1,2 @@ + +BBLAYERS += " ${METADIR}/meta-updater-raspberrypi ${METADIR}/meta-raspberrypi " diff --git a/conf/include/bblayers/sota_raspberrypi3.inc b/conf/include/bblayers/sota_raspberrypi3.inc new file mode 100644 index 0000000..11ede20 --- /dev/null +++ b/conf/include/bblayers/sota_raspberrypi3.inc @@ -0,0 +1,2 @@ + +BBLAYERS += " ${METADIR}/meta-updater-raspberrypi ${METADIR}/meta-raspberrypi " diff --git a/conf/include/local/sota_bleeding.inc b/conf/include/local/sota_bleeding.inc deleted file mode 100644 index fc5947d..0000000 --- a/conf/include/local/sota_bleeding.inc +++ /dev/null @@ -1 +0,0 @@ -SRCREV_pn-aktualizr ?= "${AUTOREV}" diff --git a/conf/include/local/sota_minnowboard.inc b/conf/include/local/sota_minnowboard.inc deleted file mode 100644 index 36d1a17..0000000 --- a/conf/include/local/sota_minnowboard.inc +++ /dev/null @@ -1,9 +0,0 @@ -MACHINE = "intel-corei7-64" - -OSTREE_BOOTLOADER ?= "grub" -EFI_PROVIDER = "grub-efi" - -WKS_FILE = "efiimage-sota.wks" -IMAGE_BOOT_FILES = "" - -OSTREE_KERNEL_ARGS ?= "ramdisk_size=16384 rw rootfstype=ext4 rootwait rootdelay=2 console=ttyS0,115200 console=tty0" diff --git a/conf/include/local/sota_minnowboard_uboot.inc b/conf/include/local/sota_minnowboard_uboot.inc deleted file mode 100644 index e64f7eb..0000000 --- a/conf/include/local/sota_minnowboard_uboot.inc +++ /dev/null @@ -1,10 +0,0 @@ -MACHINE = "intel-corei7-64" - -PREFERRED_PROVIDER_virtual/bootloader = "u-boot-ota" -UBOOT_MACHINE = "minnowmax_defconfig" - -EXTRA_IMAGEDEPENDS_append = " minnowboard-bootfiles" -IMAGE_BOOT_FILES = "minnowboard-bootfiles/*" - -OSTREE_KERNEL_ARGS ?= "ramdisk_size=16384 rw rootfstype=ext4 rootwait rootdelay=2 ostree_root=/dev/hda console=ttyS0,115200 console=tty0" - diff --git a/conf/include/local/sota_porter.inc b/conf/include/local/sota_porter.inc deleted file mode 100644 index 9828248..0000000 --- a/conf/include/local/sota_porter.inc +++ /dev/null @@ -1,12 +0,0 @@ -MACHINE = "porter" - -# Commit united image to OSTree, not just uImage -OSTREE_KERNEL = "uImage+dtb" - -EXTRA_IMAGEDEPENDS_append_sota = " porter-bootfiles" -IMAGE_CLASSES_append_sota = " image_types_uboot " -IMAGE_BOOT_FILES_sota += "porter-bootfiles/*" - -OSTREE_BOOTLOADER ?= "u-boot" -UBOOT_MACHINE_sota = "porter_config" - diff --git a/conf/include/local/sota_qemux86-64.inc b/conf/include/local/sota_qemux86-64.inc deleted file mode 100644 index b03631b..0000000 --- a/conf/include/local/sota_qemux86-64.inc +++ /dev/null @@ -1,11 +0,0 @@ -MACHINE = "qemux86-64" - -# See https://advancedtelematic.atlassian.net/browse/PRO-2693 -PREFERRED_VERSION_linux-yocto_qemux86-64_sota = "4.4%" - -# U-Boot support for SOTA -PREFERRED_PROVIDER_virtual/bootloader_sota = "u-boot-ota" -UBOOT_MACHINE_sota = "qemu-x86_defconfig" -OSTREE_BOOTLOADER ?= "u-boot" - -OSTREE_KERNEL_ARGS ?= "ramdisk_size=16384 rw rootfstype=ext4 rootwait rootdelay=2 ostree_root=/dev/hda" diff --git a/conf/include/local/sota_raspberrypi.inc b/conf/include/local/sota_raspberrypi.inc deleted file mode 100644 index ae13b8e..0000000 --- a/conf/include/local/sota_raspberrypi.inc +++ /dev/null @@ -1,14 +0,0 @@ -MACHINE ?= "raspberrypi3" - -IMAGE_CLASSES += "${@bb.utils.contains('DISTRO_FEATURES', 'sota', 'image_types_uboot sdcard_image-rpi-ota', '', d)}" -IMAGE_FSTYPES += "${@bb.utils.contains('DISTRO_FEATURES', 'sota', 'rpi-sdimg-ota', 'rpi-sdimg', d)}" - -### both rpi-sdimg and rpi-sdimg-ota broken -IMAGE_FSTYPES += "ext4.xz ext4.bmap tar.xz" - -KERNEL_IMAGETYPE_sota = "uImage" -PREFERRED_PROVIDER_virtual/bootloader_sota ?= "u-boot" -UBOOT_MACHINE_raspberrypi2_sota ?= "rpi_2_defconfig" -UBOOT_MACHINE_raspberrypi3_sota ?= "rpi_3_32b_defconfig" - -OSTREE_BOOTLOADER ?= "u-boot" diff --git a/scripts/envsetup.sh b/scripts/envsetup.sh index 6c01d5b..5adf319 100755 --- a/scripts/envsetup.sh +++ b/scripts/envsetup.sh @@ -35,11 +35,6 @@ fi SCRIPTDIR=$(cd $(dirname $BASH_SOURCE) && pwd -P) METADIR=$(cd $(dirname $BASH_SOURCE)/../.. && pwd -P) -if ! [[ -e ${SCRIPTDIR}/../conf/include/local/sota_${MACHINE}.inc && -e ${SCRIPTDIR}/../conf/include/bblayers/sota_${MACHINE}.inc ]]; then - echo "Error: invalid machine: ${MACHINE}" >&2 - return -1 -fi - if [ -e ${BUILDDIR}/conf/local.conf ]; then source $METADIR/poky/oe-init-build-env ${BUILDDIR} else @@ -47,8 +42,7 @@ else echo "METADIR := \"\${@os.path.abspath('${METADIR}')}\"" >> conf/bblayers.conf cat ${METADIR}/meta-updater/conf/include/bblayers/sota.inc >> conf/bblayers.conf cat ${METADIR}/meta-updater/conf/include/bblayers/sota_${MACHINE}.inc >> conf/bblayers.conf - echo "include conf/include/local/sota_${MACHINE}.inc" >> conf/local.conf - echo "include conf/distro/sota.conf.inc" >> conf/local.conf + echo "MACHINE = \"${MACHINE}\"" >> conf/local.conf echo "DISTRO = \"poky-sota-systemd\"" >> conf/local.conf fi -- cgit v1.2.3-54-g00ecf