public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Claudius Heine <claudius.heine.ext@siemens.com>
To: "[ext] Jan Kiszka" <jan.kiszka@siemens.com>,
	isar-users <isar-users@googlegroups.com>
Subject: Re: [PATCH 3/5] Set up target image fstab prior to installing any packages
Date: Thu, 7 Jun 2018 08:38:05 +0200	[thread overview]
Message-ID: <bf0d8a0d-3810-a53a-e0b4-60e80f79654b@siemens.com> (raw)
In-Reply-To: <662dc5f081a493c4c7fa3e00af728c8b19f8ff3e.1528286332.git.jan.kiszka@siemens.com>

Hi,

On 2018-06-06 13:58, [ext] Jan Kiszka wrote:
> From: Jan Kiszka <jan.kiszka@siemens.com>
> 
> Package postinst hooks may need the fstab or may want to modify it,
> including customization packages or the upcoming u-boot-script
> generator. So extract the already identical setup pattern from the
> distro config scripts, generate the fstab prior to calling
> setup_root_file_system and let the latter inject the file before
> starting the package installation. By specifying "-" as fstab file, we
> can skip the injection for the buildchroot which does not need it.
> 
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>   .../recipes-core/images/files/debian-configscript.sh   | 14 --------------
>   .../recipes-core/images/files/raspbian-configscript.sh | 14 --------------
>   meta-isar/recipes-core/images/isar-image-base.bb       | 18 ++++++++++++++----
>   meta/classes/isar-bootstrap-helper.bbclass             |  5 +++--
>   meta/recipes-devtools/buildchroot/buildchroot.bb       |  2 +-
>   5 files changed, 18 insertions(+), 35 deletions(-)
> 
> diff --git a/meta-isar/recipes-core/images/files/debian-configscript.sh b/meta-isar/recipes-core/images/files/debian-configscript.sh
> index 136918c..bcd5507 100755
> --- a/meta-isar/recipes-core/images/files/debian-configscript.sh
> +++ b/meta-isar/recipes-core/images/files/debian-configscript.sh
> @@ -7,20 +7,6 @@ set -e
>   
>   readonly MACHINE_SERIAL="$1"
>   readonly BAUDRATE_TTY="$2"
> -readonly ROOTFS_DEV="$3"
> -readonly ROOTFS_TYPE="$4"
> -
> -cat > /etc/fstab << EOF
> -# Begin /etc/fstab
> -/dev/$ROOTFS_DEV	/		$ROOTFS_TYPE		defaults		1	1
> -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
>   
>   # Create console device
>   if [ ! -e /dev/console ]; then
> diff --git a/meta-isar/recipes-core/images/files/raspbian-configscript.sh b/meta-isar/recipes-core/images/files/raspbian-configscript.sh
> index 04ea571..3631c26 100644
> --- a/meta-isar/recipes-core/images/files/raspbian-configscript.sh
> +++ b/meta-isar/recipes-core/images/files/raspbian-configscript.sh
> @@ -7,20 +7,6 @@ set -e
>   
>   readonly MACHINE_SERIAL="$1"
>   readonly BAUDRATE_TTY="$2"
> -readonly ROOTFS_DEV="$3"
> -readonly ROOTFS_TYPE="$4"
> -
> -cat > /etc/fstab << EOF
> -# Begin /etc/fstab
> -/dev/$ROOTFS_DEV	/		$ROOTFS_TYPE		defaults		1	1
> -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
>   
>   # Enable tty conditionally, systemd does not have the file but its own magic
>   if [ -f /etc/inittab ]; then
> diff --git a/meta-isar/recipes-core/images/isar-image-base.bb b/meta-isar/recipes-core/images/isar-image-base.bb
> index f91dfb0..bf90e30 100644
> --- a/meta-isar/recipes-core/images/isar-image-base.bb
> +++ b/meta-isar/recipes-core/images/isar-image-base.bb
> @@ -28,15 +28,25 @@ do_rootfs[root_cleandirs] = "${IMAGE_ROOTFS} \
>                                ${IMAGE_ROOTFS}/isar-apt"
>   
>   do_rootfs() {
> -    setup_root_file_system "${IMAGE_ROOTFS}" "clean" \
> +    cat > ${WORKDIR}/fstab << EOF
> +# Begin /etc/fstab
> +/dev/${ROOTFS_DEV}	/		${ROOTFS_TYPE}		defaults		1	1
> +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 "${IMAGE_ROOTFS}" "clean" "${WORKDIR}/fstab" \
>           ${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} \
> -                                                         ${ROOTFS_DEV} \
> -                                                         ${ROOTFS_TYPE}
> +                                                         ${BAUDRATE_TTY}
>   
>       # Cleanup
>       sudo rm "${IMAGE_ROOTFS}/${DISTRO_CONFIG_SCRIPT}"
> diff --git a/meta/classes/isar-bootstrap-helper.bbclass b/meta/classes/isar-bootstrap-helper.bbclass
> index a3f1686..5d4dca0 100644
> --- a/meta/classes/isar-bootstrap-helper.bbclass
> +++ b/meta/classes/isar-bootstrap-helper.bbclass
> @@ -17,8 +17,8 @@ def reverse_bb_array(d, varname):
>   setup_root_file_system() {
>       ROOTFSDIR="$1"
>       CLEAN="$2"
> -    shift
> -    shift
> +    FSTAB="$3"
> +    shift 3

If that starts getting this complex with the second optional parameter, 
maybe we should look into using getopt or just the normal shell 'case' 
loop over the options. I would prefer that instead of introducing more 
and more '-' positional parameter.

With 'clean' and 'noclean' we could sort of get away with it because we 
always specify 'noclean' in those places instead of just '-'. It wasn't 
ideal, but since it was the only one it was sort of ok. Now since we are 
expanding this we should really switch to something easier to use and 
understand.

Claudius

>       PACKAGES="$@"
>       APT_ARGS="install --yes -o Debug::pkgProblemResolver=yes"
>       CLEAN_FILES="${ROOTFSDIR}/etc/hostname ${ROOTFSDIR}/etc/resolv.conf"
> @@ -26,6 +26,7 @@ setup_root_file_system() {
>       sudo cp -Trpfx \
>           "${DEPLOY_DIR_IMAGE}/isar-bootstrap-${DISTRO}-${DISTRO_ARCH}/" \
>           "$ROOTFSDIR"
> +    [ "${FSTAB}" != "-" ] && cat ${FSTAB} | sudo tee "$ROOTFSDIR/etc/fstab"
>   
>       echo "deb [trusted=yes] file:///isar-apt ${DEBDISTRONAME} main" | \
>           sudo tee "$ROOTFSDIR/etc/apt/sources.list.d/isar-apt.list" >/dev/null
> diff --git a/meta/recipes-devtools/buildchroot/buildchroot.bb b/meta/recipes-devtools/buildchroot/buildchroot.bb
> index e405509..10142b7 100644
> --- a/meta/recipes-devtools/buildchroot/buildchroot.bb
> +++ b/meta/recipes-devtools/buildchroot/buildchroot.bb
> @@ -69,7 +69,7 @@ do_build[root_cleandirs] = "${BUILDCHROOT_DIR} \
>   do_build[depends] = "isar-apt:do_cache_config isar-bootstrap:do_deploy"
>   
>   do_build() {
> -    setup_root_file_system "${BUILDCHROOT_DIR}" "noclean" \
> +    setup_root_file_system "${BUILDCHROOT_DIR}" "noclean" "-" \
>           ${BUILDCHROOT_PREINSTALL}
>   
>       # Install package builder script
> 

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-54 Fax: (+49)-8142-66989-80 Email: ch@denx.de

  reply	other threads:[~2018-06-07  6:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-06 11:58 [PATCH 0/5] Enable U-Boot-based images, add Banana Pi demo Jan Kiszka
2018-06-06 11:58 ` [PATCH 1/5] Add DISTRO and DISTRO_ARCH as OVERRIDES suffixes Jan Kiszka
2018-06-06 11:58 ` [PATCH 2/5] buildchroot: Break up wic build deps into common and arch-specific ones Jan Kiszka
2018-06-06 11:58 ` [PATCH 3/5] Set up target image fstab prior to installing any packages Jan Kiszka
2018-06-07  6:38   ` Claudius Heine [this message]
2018-06-06 11:58 ` [PATCH 4/5] Add u-boot script generator Jan Kiszka
2018-06-06 18:31   ` Jan Kiszka
2018-06-06 18:48   ` Jan Kiszka
2018-06-06 11:58 ` [PATCH 5/5] Add Banana Pi SD-card image Jan Kiszka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bf0d8a0d-3810-a53a-e0b4-60e80f79654b@siemens.com \
    --to=claudius.heine.ext@siemens.com \
    --cc=isar-users@googlegroups.com \
    --cc=jan.kiszka@siemens.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox