From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6563939828400914432 X-Received: by 2002:a50:e613:: with SMTP id y19-v6mr296416edm.2.1528353486692; Wed, 06 Jun 2018 23:38:06 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a50:fc19:: with SMTP id i25-v6ls390667edr.0.gmail; Wed, 06 Jun 2018 23:38:06 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLtpwD3g3Aeaf3Yy5p9c7Jwu/9gFwRyvZxMidazj7H12wFSuppovZ7DNt39MJYwRjXCs/IB X-Received: by 2002:a50:fc04:: with SMTP id i4-v6mr295044edr.10.1528353486284; Wed, 06 Jun 2018 23:38:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528353486; cv=none; d=google.com; s=arc-20160816; b=y1KpT7P8m2RxePZtGRXVkVeaLrYqSvULORR5Bbo2W6ODls0+FhUErmQ3oUQ5oraD/W caTiWbSq5rcRpkK1wtJ/tgaL0A5tI1kD0MWYpZfhjkfg1HMtyqfls3Fx5D390XbDiL6X 8+D57znfFqvbVJ7rK3baSfpi+BNJB2/wJ/A7fFA0pFoJm3zS1Y1227XdulSX9DDKf9iQ oMwJJEitCzQJzUSE6hjFts9KxiMzye75w23YK0p5gxoQAXcQjZPUlfrXIS821WvrOpm/ 6WiYCni2IXpEnzNLcq5Q3WSejCFikwDM2MvMWINI+c5iSBc8ikX21WRKaWzUXG0PCwzD RNyQ== 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:from:references:to:subject :arc-authentication-results; bh=6+8ec4Id42MfLFkN729VeFFNlLQ78KhqpLgkCvZrhR8=; b=hhWQ/UkNb7P4y3LoEudSvF5l3SLSBq/ZI3CfsOxSwRHAiVEsRbWTM5mKptx50ZCGvX bCWtbG0igMwD0FC47E5/7fCNFGlbmH5QUlYG/YUn8yHspV8tVUngNYpBwQmAafkm/7u8 q3Mrpx9l8PDLQbe+4Hfr173UHTPda9Declj0CmnpVVx60S77xsN4HKY1N9OplJv8deGy 8Ss9+pr+R5IHvbx2n/qZuJtFmKDaDyrY/jkeVThuVzLFkZFGx31vTrSBwuYs0ICgahJH WV5XEguK/xsQ/8TUtY5Pw5qETdlM0YlHILkzOP7EEsyp+xx13KsmWFHRPZKACD5YuBFn K+iw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of claudius.heine.ext@siemens.com designates 194.138.37.39 as permitted sender) smtp.mailfrom=claudius.heine.ext@siemens.com Return-Path: Received: from lizzard.sbs.de (lizzard.sbs.de. [194.138.37.39]) by gmr-mx.google.com with ESMTPS id u7-v6si356971edo.2.2018.06.06.23.38.06 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Jun 2018 23:38:06 -0700 (PDT) Received-SPF: pass (google.com: domain of claudius.heine.ext@siemens.com designates 194.138.37.39 as permitted sender) client-ip=194.138.37.39; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of claudius.heine.ext@siemens.com designates 194.138.37.39 as permitted sender) smtp.mailfrom=claudius.heine.ext@siemens.com Received: from mail1.sbs.de (mail1.sbs.de [192.129.41.35]) by lizzard.sbs.de (8.15.2/8.15.2) with ESMTPS id w576c5s2006707 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 7 Jun 2018 08:38:05 +0200 Received: from [139.25.69.69] (linux-ses-ext02.ppmd.siemens.net [139.25.69.69]) by mail1.sbs.de (8.15.2/8.15.2) with ESMTP id w576c4pG015803; Thu, 7 Jun 2018 08:38:05 +0200 Subject: Re: [PATCH 3/5] Set up target image fstab prior to installing any packages To: "[ext] Jan Kiszka" , isar-users References: <662dc5f081a493c4c7fa3e00af728c8b19f8ff3e.1528286332.git.jan.kiszka@siemens.com> From: Claudius Heine Message-ID: Date: Thu, 7 Jun 2018 08:38:05 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <662dc5f081a493c4c7fa3e00af728c8b19f8ff3e.1528286332.git.jan.kiszka@siemens.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-TUID: 1MYrx9/n7lQc Hi, On 2018-06-06 13:58, [ext] Jan Kiszka wrote: > From: Jan Kiszka > > 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 > --- > .../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