public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Benedikt Niedermayr <benbrenson89@googlemail.com>
To: isar-users@googlegroups.com
Cc: Benedikt Niedermayr <Benedikt.Niedermayr@mixed-mode.de>
Subject: [PATCH 3/6] Added apt-cache functionality for buildchroot.
Date: Tue,  6 Feb 2018 11:09:36 +0100	[thread overview]
Message-ID: <1517911779-30507-4-git-send-email-Benedikt.Niedermayr@mixed-mode.de> (raw)
In-Reply-To: <1517911779-30507-1-git-send-email-Benedikt.Niedermayr@mixed-mode.de>

ESSENTIAL_INSTALL was added since multistrap won't pick up all required packages
when calculating the initial package list.
It seems that multiconfig silently drops some packages if they where not present at the repository.

The completion hook was added in order to support fetching from local repository within chroot environment.

Signed-off-by: Benedikt Niedermayr <Benedikt.Niedermayr@mixed-mode.de>
---
 meta/recipes-devtools/buildchroot/buildchroot.bb   | 35 ++++++++++++++++++----
 .../buildchroot/files/multistrap.conf.in           | 17 ++++++-----
 2 files changed, 39 insertions(+), 13 deletions(-)

diff --git a/meta/recipes-devtools/buildchroot/buildchroot.bb b/meta/recipes-devtools/buildchroot/buildchroot.bb
index 79e6773..dd306f6 100644
--- a/meta/recipes-devtools/buildchroot/buildchroot.bb
+++ b/meta/recipes-devtools/buildchroot/buildchroot.bb
@@ -16,7 +16,17 @@ SRC_URI = "file://multistrap.conf.in \
            file://build.sh"
 PV = "1.0"
 
-BUILDCHROOT_PREINSTALL ?= "gcc \
+inherit apt-cache
+
+do_build[depends] = "isar-apt:do_cache_config"
+
+ESSENTIAL_INSTALL ?= "base-files base-passwd bash bsdutils coreutils bash debianutils \
+                      diffutils apt findutils grep gzip hostname init-system-helpers \
+                      libc-bin perl-base sed tar util-linux mawk diffutils \
+                      "
+
+BUILDCHROOT_PREINSTALL ?= "${ESSENTIAL_INSTALL} \
+                           gcc \
                            make \
                            build-essential \
                            debhelper \
@@ -32,11 +42,11 @@ BUILDCHROOT_PREINSTALL ?= "gcc \
 WORKDIR = "${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}/${PN}"
 
 do_prepare[nostamp] = "1"
-do_prepare[dirs] = "${BUILDCHROOT_DIR}/isar-apt"
+do_prepare[dirs] = "${BUILDCHROOT_DIR}${CHROOT_CACHE_DIR}"
 do_prepare[depends] = "isar-apt:do_cache_config"
 
 do_prepare() {
-    sudo mount --bind ${DEPLOY_DIR_APT}/${DISTRO} ${BUILDCHROOT_DIR}/isar-apt
+    sudo mount --bind ${TOPDIR}/apt-cache ${BUILDCHROOT_DIR}${CHROOT_CACHE_DIR}
 }
 
 addtask prepare before do_build after do_unpack
@@ -55,17 +65,31 @@ do_build() {
     cd ${TOPDIR}
     WORKDIR_REL=${@ os.path.relpath(d.getVar("WORKDIR", True))}
 
+    # Replace directory of apt caches for using within chroots and
+    # set the trusted=yes option for local unsigned cache repository.
+    cat<<-__EOF__ > $WORKDIR_REL/hooks_multistrap/completion_sources
+		for section in ${DISTRO_MULTICONF_APTSOURCES} isar; do
+			sed -i -e 's|${TOPDIR}/apt-cache|${CHROOT_CACHE_DIR}|g' \
+				-e 's|\[|\[ trusted=yes |g' \
+				${BUILDCHROOT_DIR}/etc/apt/sources.list.d/multistrap-\$section.list
+		done
+
+		__EOF__
+    chmod 0755 $WORKDIR_REL/hooks_multistrap/completion_sources
+
     # Adjust multistrap config
     sed -e 's|##BUILDCHROOT_PREINSTALL##|${BUILDCHROOT_PREINSTALL}|g' \
         -e 's|##DISTRO_MULTICONF_BOOTSTRAP##|${DISTRO_MULTICONF_BOOTSTRAP}|g' \
         -e 's|##DISTRO_MULTICONF_APTSOURCES##|${DISTRO_MULTICONF_APTSOURCES}|g' \
-        -e 's|##DISTRO_APT_SOURCE##|${DISTRO_APT_SOURCE}|g' \
-        -e 's|##DISTRO_APT_SOURCE_SEC##|${DISTRO_APT_SOURCE_SEC}|g' \
+        -e 's|##DISTRO_APT_SOURCE##|copy:///${TOPDIR}/apt-cache/${DISTRO}/public/${ISAR_MIRROR_PREFIX}|g' \
+        -e 's|##DISTRO_APT_SOURCE_SEC##|copy:///${TOPDIR}/apt-cache/${DISTRO}/public/${ISAR_MIRROR_PREFIX}-security|g' \
         -e 's|##DISTRO_SUITE##|${DISTRO_SUITE}|g' \
         -e 's|##DISTRO_COMPONENTS##|${DISTRO_COMPONENTS}|g' \
         -e 's|##CONFIG_SCRIPT##|./'"$WORKDIR_REL"'/configscript.sh|g' \
         -e 's|##SETUP_SCRIPT##|./'"$WORKDIR_REL"'/setup.sh|g' \
         -e 's|##DIR_HOOKS##|./'"$WORKDIR_REL"'/hooks_multistrap|g' \
+        -e 's|##DEPLOY_DIR_APT##|copy:///${TOPDIR}/apt-cache/${DISTRO}/public/${ISAR_REPO_PREFIX}|g' \
+        -e 's|##ISAR_DISTRO_SUITE##|${DEBDISTRONAME}|g' \
            "${WORKDIR}/multistrap.conf.in" > "${WORKDIR}/multistrap.conf"
 
     [ ! -d ${BUILDCHROOT_DIR}/proc ] && install -d -m 555 ${BUILDCHROOT_DIR}/proc
@@ -87,3 +111,4 @@ do_build() {
     sudo chroot ${BUILDCHROOT_DIR} /configscript.sh
     _do_build_cleanup
 }
+do_build[dirs] += "${TOPDIR}/apt-cache/${DISTRO} ${BUILDCHROOT_DIR}/apt-cache"
\ No newline at end of file
diff --git a/meta/recipes-devtools/buildchroot/files/multistrap.conf.in b/meta/recipes-devtools/buildchroot/files/multistrap.conf.in
index 480a4b8..ffb7023 100644
--- a/meta/recipes-devtools/buildchroot/files/multistrap.conf.in
+++ b/meta/recipes-devtools/buildchroot/files/multistrap.conf.in
@@ -5,8 +5,8 @@
 noauth=true
 unpack=true
 ignorenativearch=true
-bootstrap=##DISTRO_MULTICONF_BOOTSTRAP##
-aptsources=isar-apt ##DISTRO_MULTICONF_APTSOURCES##
+bootstrap=##DISTRO_MULTICONF_BOOTSTRAP## Isar
+aptsources=##DISTRO_MULTICONF_APTSOURCES## Isar
 configscript=##CONFIG_SCRIPT##
 setupscript=##SETUP_SCRIPT##
 hookdir=##DIR_HOOKS##
@@ -19,19 +19,20 @@ packages=##BUILDCHROOT_PREINSTALL##
 omitdebsrc=true
 
 [updates]
-source=##DISTRO_APT_SOURCE##
-suite=##DISTRO_SUITE##-updates
+source=##DISTRO_APT_SOURCE##-updates
+suite=##DISTRO_SUITE##
 components=##DISTRO_COMPONENTS##
 omitdebsrc=true
 
 [security]
 source=##DISTRO_APT_SOURCE_SEC##
-suite=##DISTRO_SUITE##/updates
+suite=##DISTRO_SUITE##
 components=##DISTRO_COMPONENTS##
 omitdebsrc=true
 
-[isar-apt]
-source=file:///isar-apt
-suite=isar
+[Isar]
+packages=##BUILDCHROOT_PREINSTALL##
+source=##DEPLOY_DIR_APT##
+suite=##ISAR_DISTRO_SUITE##
 components=main
 omitdebsrc=true
-- 
2.7.4


  parent reply	other threads:[~2018-02-06 10:09 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-06 10:09 [PATCH 0/6] Local apt cache with aptly Benedikt Niedermayr
2018-02-06 10:09 ` [PATCH 1/6] Implement support for setting up the local apt mirror and isar repository " Benedikt Niedermayr
2018-02-06 10:09 ` [PATCH 2/6] Added API class for apt cache Benedikt Niedermayr
2018-02-06 10:09 ` Benedikt Niedermayr [this message]
2018-02-06 10:09 ` [PATCH 4/6] Added apt-cache functionality for image rootfs Benedikt Niedermayr
2018-02-06 10:09 ` [PATCH 5/6] Added do_finalize_image task Benedikt Niedermayr
2018-02-06 10:09 ` [PATCH 6/6] Added support for installing isar packages to local isar repository Benedikt Niedermayr
2018-02-06 12:39 ` [PATCH 0/6] Local apt cache with aptly Jan Kiszka
2018-02-06 13:28   ` Jan Kiszka
2018-02-06 14:03     ` Benedikt Niedermayr
2018-02-06 14:26       ` Hombourger, Cedric
2018-02-06 13:00 ` 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=1517911779-30507-4-git-send-email-Benedikt.Niedermayr@mixed-mode.de \
    --to=benbrenson89@googlemail.com \
    --cc=Benedikt.Niedermayr@mixed-mode.de \
    --cc=isar-users@googlegroups.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