From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6617812835611181056 X-Received: by 2002:a81:7c88:: with SMTP id x130-v6mr977103ywc.18.1540966270402; Tue, 30 Oct 2018 23:11:10 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a25:6c8a:: with SMTP id h132-v6ls4767226ybc.3.gmail; Tue, 30 Oct 2018 23:11:10 -0700 (PDT) X-Google-Smtp-Source: AJdET5fFZ9nvNLtrJBsXHuCwBZKipNUfFOEJph1zWBp3teSUFM9pUROZC9y46YztFy64K6u6HzNw X-Received: by 2002:a25:38d:: with SMTP id 135-v6mr996661ybd.61.1540966270137; Tue, 30 Oct 2018 23:11:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540966270; cv=none; d=google.com; s=arc-20160816; b=iHi6886cd6I7dKrGTW7qMGMKws1eS6mRFmRX3qRfOmXD/lSsoAsw/hA5aoolHenJQk +OUabRNdV+2AMk4K6HwPibB+QWKD3z6shp8JWC/2OIhOal/2Le5FTOl+MvipwHmwbXJM /uJ88ECs3vZKk5pjAL8zCN5jUD8zv8i2n+nBiQb/2RfZySjJ84CVqrAT9Bg6osJUX6q9 ZOK1m3ISDvCSh7PdsxZd6ePA07jNEhQTYoqh6TW4r9NTciJsM/UChgNZbPyyOeVkelrh bv9zMohUKgRrZ/zbKNN+nwGllL1w5nFarhlo1UJHgBVyLZPABW31GPiXMJ8ue1yJeaBg jnvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=DQvymU0bcBzr7w2hjBNJ24KmKIRoOCT6ujo2etWAm2g=; b=nuvo1gBFZwfrPq7JnSfCVWDg2ocpcbxSOVG3rBU/5idEEnSt1wdPMQAR1Aw8p2Uw0R 7YAFmYgmGAV8UvKK1S2R4LJpVdUYs1TrA6dBp3sjswgYBgEGGeJiv6Wu4n+330sMzkUk /l8+ImDg+yOTvHOcqFy7p4Pr3alsaSoF4ynjuA2KvbUJ8B1sZcerVg+1BW/3yFK8LTwp USSp9EY3jImFV1hCqQWW2pSjh/8U4xMNJkwss4A9bHpjCsQOxBrZnhmWDM14BMB8gsDo i77cews+daxr4LEq8ibLEE8q07JUyPYMAXcyeGwIxv0kzpi/zoJyWV96f8u/5n/gnniJ O9Dg== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of cedric_hombourger@mentor.com designates 192.94.38.131 as permitted sender) smtp.mailfrom=Cedric_Hombourger@mentor.com Return-Path: Received: from relay1.mentorg.com (relay1.mentorg.com. [192.94.38.131]) by gmr-mx.google.com with ESMTPS id 130-v6si318808ybp.3.2018.10.30.23.11.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Oct 2018 23:11:10 -0700 (PDT) Received-SPF: pass (google.com: domain of cedric_hombourger@mentor.com designates 192.94.38.131 as permitted sender) client-ip=192.94.38.131; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of cedric_hombourger@mentor.com designates 192.94.38.131 as permitted sender) smtp.mailfrom=Cedric_Hombourger@mentor.com Received: from nat-ies.mentorg.com ([192.94.31.2] helo=svr-ies-mbx-02.mgc.mentorg.com) by relay1.mentorg.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) id 1gHjie-0001k5-O7 from Cedric_Hombourger@mentor.com for isar-users@googlegroups.com; Tue, 30 Oct 2018 23:11:08 -0700 Received: from localhost.localdomain (137.202.0.90) by svr-ies-mbx-02.mgc.mentorg.com (139.181.222.2) with Microsoft SMTP Server (TLS) id 15.0.1320.4; Wed, 31 Oct 2018 06:11:04 +0000 From: Cedric Hombourger To: CC: Cedric Hombourger Subject: [PATCH v2 1/2] isar-image-base: introduce and use isar-image class Date: Wed, 31 Oct 2018 07:10:24 +0100 Message-ID: <20181031061025.28840-2-Cedric_Hombourger@mentor.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181031061025.28840-1-Cedric_Hombourger@mentor.com> References: <20181030134154.7adc8bf9@md1pvb1c.ad001.siemens.net> <20181031061025.28840-1-Cedric_Hombourger@mentor.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: SVR-IES-MBX-08.mgc.mentorg.com (139.181.222.8) To svr-ies-mbx-02.mgc.mentorg.com (139.181.222.2) X-TUID: DzMtdc80jSwF Provide an isar-image class to ease the creation of custom image recipes. A second objective behind this change is for recipes (.bb files) to only contain meta-data: no code/scripts. Signed-off-by: Cedric Hombourger --- doc/user_manual.md | 33 ++++++++++++ meta-isar/classes/isar-image.bbclass | 59 ++++++++++++++++++++++ .../files => conf/distro}/debian-configscript.sh | 0 .../files => conf/distro}/raspbian-configscript.sh | 0 meta-isar/recipes-core/images/isar-image-base.bb | 57 ++------------------- 5 files changed, 95 insertions(+), 54 deletions(-) create mode 100644 meta-isar/classes/isar-image.bbclass rename meta-isar/{recipes-core/images/files => conf/distro}/debian-configscript.sh (100%) rename meta-isar/{recipes-core/images/files => conf/distro}/raspbian-configscript.sh (100%) diff --git a/doc/user_manual.md b/doc/user_manual.md index 42bcd6b..b702c28 100644 --- a/doc/user_manual.md +++ b/doc/user_manual.md @@ -496,6 +496,39 @@ Packages in the `IMAGE_TRANSIENT_PACKAGES` variable are installed to the image a --- +## Create a Custom Image Recipe + +A custom image recipe may be created to assemble packages of your choice into a root file-system image. The `isar-image` class +implements a `do_rootfs` function to compile and configure the file-system for you. Prebuilt packages may be selected for +installation by appending them to the `IMAGE_PREINSTALL` variable while packages created by ISAR should be appended to +`IMAGE_INSTALL`. A sample image recipe follows. + +### Example +``` +DESCRIPTION = "Sample image recipe for ISAR" + +LICENSE = "gpl-2.0" +LIC_FILES_CHKSUM = "file://${LAYERDIR_isar}/licenses/COPYING.GPLv2;md5=751419260aa954499f7abaabaa882bbe" + +PV = "1.0" + +IMAGE_PREINSTALL = " \ + openssh-server \ +" + +inherit isar-image + +``` + +### Additional Notes + +The distribution selected via the `DISTRO` variable may need to run a post-configuration script after the root file-system +was assembled. Isar provides scripts for Debian and Raspbian. In the event where a different Debian-based distribution is +used, your custom image recipe may need to set `DISTRO_CONFIG_SCRIPT` and use `SRC_URI` and `FILESPATH` for the script to +be copied into the work directory (`WORKDIR`). + +--- + ## Add a Custom Application Before creating a new recipe it's highly recommended to take a look into the BitBake user manual mentioned in Terms and Definitions section. diff --git a/meta-isar/classes/isar-image.bbclass b/meta-isar/classes/isar-image.bbclass new file mode 100644 index 0000000..ec2b9e3 --- /dev/null +++ b/meta-isar/classes/isar-image.bbclass @@ -0,0 +1,59 @@ +# Root filesystem for target installation +# +# This software is a part of ISAR. +# Copyright (C) 2015-2018 ilbers GmbH + +inherit image +inherit isar-bootstrap-helper + +FILESPATH =. "${LAYERDIR_isar}/conf/distro:" +SRC_URI += "${@ 'file://${DISTRO_CONFIG_SCRIPT}' if '${DISTRO_CONFIG_SCRIPT}' else '' }" + +DEPENDS += "${IMAGE_INSTALL} ${IMAGE_TRANSIENT_PACKAGES}" + +IMAGE_TRANSIENT_PACKAGES += "isar-cfg-localepurge" + +WORKDIR = "${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}/${PN}" + +ISAR_RELEASE_CMD_DEFAULT = "git -C ${LAYERDIR_isar} describe --tags --dirty --match 'v[0-9].[0-9]*'" +ISAR_RELEASE_CMD ?= "${ISAR_RELEASE_CMD_DEFAULT}" + +do_rootfs[root_cleandirs] = "${IMAGE_ROOTFS} \ + ${IMAGE_ROOTFS}/isar-apt" + +do_rootfs() { + cat > ${WORKDIR}/fstab << EOF +# Begin /etc/fstab +/dev/root / auto defaults 0 0 +proc /proc proc nosuid,noexec,nodev 0 0 +sysfs /sys sysfs nosuid,noexec,nodev 0 0 +devpts /dev/pts devpts gid=5,mode=620 0 0 +tmpfs /run tmpfs defaults 0 0 +devtmpfs /dev devtmpfs mode=0755,nosuid 0 0 + +# End /etc/fstab +EOF + + setup_root_file_system --clean --keep-apt-cache \ + --fstab "${WORKDIR}/fstab" \ + "${IMAGE_ROOTFS}" ${IMAGE_PREINSTALL} ${IMAGE_INSTALL} + + # Configure root filesystem + if [ -n "${DISTRO_CONFIG_SCRIPT}" ]; then + sudo install -m 755 "${WORKDIR}/${DISTRO_CONFIG_SCRIPT}" "${IMAGE_ROOTFS}" + sudo chroot ${IMAGE_ROOTFS} /${DISTRO_CONFIG_SCRIPT} "${MACHINE_SERIAL}" \ + "${BAUDRATE_TTY}" + sudo rm "${IMAGE_ROOTFS}/${DISTRO_CONFIG_SCRIPT}" + fi + + # Cleanup + sudo rm "${IMAGE_ROOTFS}/etc/apt/sources.list.d/isar-apt.list" + test ! -e "${IMAGE_ROOTFS}/usr/share/doc/qemu-user-static" && \ + sudo find "${IMAGE_ROOTFS}/usr/bin" \ + -maxdepth 1 -name 'qemu-*-static' -type f -delete + sudo umount -l ${IMAGE_ROOTFS}/isar-apt + sudo rmdir ${IMAGE_ROOTFS}/isar-apt + sudo umount -l ${IMAGE_ROOTFS}/dev + sudo umount -l ${IMAGE_ROOTFS}/proc + sudo rm -f "${IMAGE_ROOTFS}/etc/apt/apt.conf.d/55isar-fallback.conf" +} diff --git a/meta-isar/recipes-core/images/files/debian-configscript.sh b/meta-isar/conf/distro/debian-configscript.sh similarity index 100% rename from meta-isar/recipes-core/images/files/debian-configscript.sh rename to meta-isar/conf/distro/debian-configscript.sh diff --git a/meta-isar/recipes-core/images/files/raspbian-configscript.sh b/meta-isar/conf/distro/raspbian-configscript.sh similarity index 100% rename from meta-isar/recipes-core/images/files/raspbian-configscript.sh rename to meta-isar/conf/distro/raspbian-configscript.sh diff --git a/meta-isar/recipes-core/images/isar-image-base.bb b/meta-isar/recipes-core/images/isar-image-base.bb index bf606cc..074e566 100644 --- a/meta-isar/recipes-core/images/isar-image-base.bb +++ b/meta-isar/recipes-core/images/isar-image-base.bb @@ -1,64 +1,13 @@ -# Root filesystem for target installation +# Base image recipe for ISAR # # This software is a part of ISAR. -# Copyright (C) 2015-2017 ilbers GmbH +# Copyright (C) 2015-2018 ilbers GmbH DESCRIPTION = "Isar target filesystem" LICENSE = "gpl-2.0" LIC_FILES_CHKSUM = "file://${LAYERDIR_isar}/licenses/COPYING.GPLv2;md5=751419260aa954499f7abaabaa882bbe" -FILESPATH =. "${LAYERDIR_isar}/recipes-core/images/files:" -SRC_URI = "file://${DISTRO_CONFIG_SCRIPT}" - PV = "1.0" -inherit image -inherit isar-bootstrap-helper - -DEPENDS += "${IMAGE_INSTALL} ${IMAGE_TRANSIENT_PACKAGES}" - -IMAGE_TRANSIENT_PACKAGES += "isar-cfg-localepurge" - -WORKDIR = "${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}/${PN}" - -ISAR_RELEASE_CMD_DEFAULT = "git -C ${LAYERDIR_isar} describe --tags --dirty --match 'v[0-9].[0-9]*'" -ISAR_RELEASE_CMD ?= "${ISAR_RELEASE_CMD_DEFAULT}" - -do_rootfs[root_cleandirs] = "${IMAGE_ROOTFS} \ - ${IMAGE_ROOTFS}/isar-apt" - -do_rootfs() { - cat > ${WORKDIR}/fstab << EOF -# Begin /etc/fstab -/dev/root / auto defaults 0 0 -proc /proc proc nosuid,noexec,nodev 0 0 -sysfs /sys sysfs nosuid,noexec,nodev 0 0 -devpts /dev/pts devpts gid=5,mode=620 0 0 -tmpfs /run tmpfs defaults 0 0 -devtmpfs /dev devtmpfs mode=0755,nosuid 0 0 - -# End /etc/fstab -EOF - - setup_root_file_system --clean --keep-apt-cache \ - --fstab "${WORKDIR}/fstab" \ - "${IMAGE_ROOTFS}" ${IMAGE_PREINSTALL} ${IMAGE_INSTALL} - - # Configure root filesystem - sudo install -m 755 "${WORKDIR}/${DISTRO_CONFIG_SCRIPT}" "${IMAGE_ROOTFS}" - sudo chroot ${IMAGE_ROOTFS} /${DISTRO_CONFIG_SCRIPT} ${MACHINE_SERIAL} \ - ${BAUDRATE_TTY} - - # Cleanup - sudo rm "${IMAGE_ROOTFS}/${DISTRO_CONFIG_SCRIPT}" - sudo rm "${IMAGE_ROOTFS}/etc/apt/sources.list.d/isar-apt.list" - test ! -e "${IMAGE_ROOTFS}/usr/share/doc/qemu-user-static" && \ - sudo find "${IMAGE_ROOTFS}/usr/bin" \ - -maxdepth 1 -name 'qemu-*-static' -type f -delete - sudo umount -l ${IMAGE_ROOTFS}/isar-apt - sudo rmdir ${IMAGE_ROOTFS}/isar-apt - sudo umount -l ${IMAGE_ROOTFS}/dev - sudo umount -l ${IMAGE_ROOTFS}/proc - sudo rm -f "${IMAGE_ROOTFS}/etc/apt/apt.conf.d/55isar-fallback.conf" -} +inherit isar-image -- 2.11.0