From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6617812835611181056 X-Received: by 2002:adf:f907:: with SMTP id b7-v6mr26978wrr.21.1541596071788; Wed, 07 Nov 2018 05:07:51 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a1c:a782:: with SMTP id q124-v6ls285586wme.14.gmail; Wed, 07 Nov 2018 05:07:51 -0800 (PST) X-Google-Smtp-Source: AJdET5c3wQyl5uzNz/xd1eQP2ndMI2L8b8QbQHPYtY+yQhCTLWLSaMvnymsGi3KfAn9OSJOUK0Df X-Received: by 2002:a1c:1d0:: with SMTP id 199-v6mr25557wmb.14.1541596071321; Wed, 07 Nov 2018 05:07:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541596071; cv=none; d=google.com; s=arc-20160816; b=HNCTnhvQ512Ofj/KQxgUh9rFaq5x1M3o64rJUnRO1vEsM1cFmNi0+bY6ZhM9z3fJ0f Cg6eRSzAuQkzzMfsTLV4D/x+gq3myKVyYQUxu+rB4wfJs+bFJWdzR2v/c/pt8EKUoL2/ LyGHNgDbA09D5d3HxLwAWRZzgqAHsmIcO+DJY+zHr0zof/v/pAadAr4bsW5fqMiYzPqb JXX/MAssEJfnWKnRVnceP7tUcpJC4Fn2G8a6t0EOM3QIb/Pde0OV3YYoI3LC83WzDzUN zhqkU+i3sflkLjilSuz+o3azSiLzXNoctv6NSIEcuSCEH2UtGKgTKNf4Om7FWE2jXKGl FgxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:organization:from:references:to:subject; bh=Ri6FdRpL1aCYprMsQ/U04gDH6HpjdCz9l4dgRkm0oLM=; b=wa075wGXk7QOBQyXJpZcO2Ekk0ZnwGW/adxhVZTzXNkk2bIeMQz7ILR3Q4KKTnTR3Q mflefPPGX3Kuc3T4sj+yGvpCtw5QRMcIeUeNLqgfBO2IA1enJBmhCgZlpEHWAam3LaB9 o151ryGJisfJwru8y3+X0hovEld9kD8Dp5D/HK2l6mhV+HKK9oKrnl5PJiU7AIyqDlra gERzmv57817jrvWRQj0hK/D0RvIWyffyw2UZUSa5vhdYIpLjx2bc9zA/XsPmXiSGbJWm LDP9DC/bU/Fiwki2xawU+jvQPv6+GVU/i5HXowEf/D6bkeIRhZO2g8XqY2cjXVS6GPqb sj8g== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: best guess record for domain of mosipov@ilbers.de designates 85.214.62.211 as permitted sender) smtp.mailfrom=mosipov@ilbers.de Return-Path: Received: from aqmola.ilbers.de (aqmola.ilbers.de. [85.214.62.211]) by gmr-mx.google.com with ESMTPS id n6-v6si21565wrj.4.2018.11.07.05.07.51 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Nov 2018 05:07:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of mosipov@ilbers.de designates 85.214.62.211 as permitted sender) client-ip=85.214.62.211; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: best guess record for domain of mosipov@ilbers.de designates 85.214.62.211 as permitted sender) smtp.mailfrom=mosipov@ilbers.de Received: from [192.168.50.180] (nat-ppp-217.71.235.199-satnet-spb.ru [217.71.235.199] (may be forged)) (authenticated bits=0) by aqmola.ilbers.de (8.14.4/8.14.4/Debian-4+deb7u1) with ESMTP id wA7D7m3u009769 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT); Wed, 7 Nov 2018 14:07:50 +0100 Subject: Re: [PATCH v3 1/2] isar-image-base: introduce and use isar-image class To: Cedric Hombourger , isar-users@googlegroups.com References: <57847f7a-9b85-65ef-b11e-8952bf532e0f@siemens.com> <20181101101302.8674-1-Cedric_Hombourger@mentor.com> From: "Maxim Yu. Osipov" Organization: ilbers GmbH Message-ID: <7e90179d-d53b-e735-4be1-818d3f13121c@ilbers.de> Date: Wed, 7 Nov 2018 16:07:43 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20181101101302.8674-1-Cedric_Hombourger@mentor.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-TUID: LqUrsLy+tZyX On 11/1/18 1:13 PM, Cedric Hombourger wrote: > 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. Applied V3 series to the 'next', Thanks, Maxim. > Signed-off-by: Cedric Hombourger > --- > doc/user_manual.md | 33 ++++++++++++ > .../files => conf/distro}/debian-configscript.sh | 0 > .../files => conf/distro}/raspbian-configscript.sh | 0 > meta-isar/recipes-core/images/isar-image-base.bb | 57 ++------------------- > meta/classes/isar-image.bbclass | 59 ++++++++++++++++++++++ > 5 files changed, 95 insertions(+), 54 deletions(-) > 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%) > create mode 100644 meta/classes/isar-image.bbclass > > 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/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 > diff --git a/meta/classes/isar-image.bbclass b/meta/classes/isar-image.bbclass > new file mode 100644 > index 0000000..ec2b9e3 > --- /dev/null > +++ b/meta/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" > +} > -- Maxim Osipov ilbers GmbH Maria-Merian-Str. 8 85521 Ottobrunn Germany +49 (151) 6517 6917 mosipov@ilbers.de http://ilbers.de/ Commercial register Munich, HRB 214197 General Manager: Baurzhan Ismagulov