From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 7237382541983875072 X-Received: by 2002:a05:6870:a8a6:b0:192:4e13:8d58 with SMTP id eb38-20020a056870a8a600b001924e138d58mr221044oab.8.1685084436666; Fri, 26 May 2023 00:00:36 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a05:6870:7711:b0:195:d294:2d3d with SMTP id dw17-20020a056870771100b00195d2942d3dls205547oab.0.-pod-prod-09-us; Fri, 26 May 2023 00:00:36 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5iLokcDpXteAmB+DJ/8JxYIsNg/HQMw6GggH5uM0PUqMnjUBT6qiYm+jTZDSOGjRkZ5CTW X-Received: by 2002:a05:6870:b211:b0:199:ccad:7dcc with SMTP id a17-20020a056870b21100b00199ccad7dccmr275588oam.48.1685084436037; Fri, 26 May 2023 00:00:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685084436; cv=none; d=google.com; s=arc-20160816; b=HO09c+c0Tb3L9W+lubj1M1hfvcr0R/aQKrm0QDgTl6PN+NQiwNS3yqbSCFXDkAjorV s+/bEi4RGqYcmFyAy0ZcNEneeCxM24yvZr/HQ/t1aeqhvm3VvrmhYllB9I7l/zrHTdvR CKEWgy7ivTL0Wc8VrM8Am1tfbMPRrzO7cICt8qbJg32WRGzYeT+ekBJE8GYY1ChQxjmO FQYapX+zNA7CvRMp0+2NpFkfd1SMwzrBZhxfmUQ7yllPVZdpHSOQWCw/dfmfe7U1Q0eW cUCeTVTjcaVM29TO5Wtxq70ngzv85hGjZwLE4THzApgduG6Bf1zs9lsK3YjP1o8nntqX eoEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from; bh=wk/RA20AwaT5IYEiG7iqhNXKF2d4XIehMTXhYvEThPc=; b=xpspfZMt/i5JKmHuQyD6kjVHguZoAxd50XggauN0UaeWqKywiNckW424IwcsKNKB6X 1e6sHDZDt8M+7KE4SRgvKs66DO7r+5QJfBVp5lL9ryPDk9gb40ieElBuW2yrEWW4ENIL 1fNKaq57sHBajfaD3QoxtkB5xO5d9XqjHJAXkeUzF+7Jqlqeo+XT3nzb79PEeUj2BMdN olpiOCdTpYucAnAvpuEnR8HEwsxTI+3RC81X78EnICBEP6dLbWEVkSnKkQMNI0sLl+78 h0PvJC+2GZnL6cf/smfuozg8p64XwIk7KNVg6USgCg5OrYCurT0MqQ/VY9srLkXsKD3M CITw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of ubely@ilbers.de designates 85.214.156.166 as permitted sender) smtp.mailfrom=ubely@ilbers.de Return-Path: Received: from shymkent.ilbers.de (shymkent.ilbers.de. [85.214.156.166]) by gmr-mx.google.com with ESMTPS id d15-20020a4ad34f000000b005552377a831si256498oos.1.2023.05.26.00.00.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 26 May 2023 00:00:36 -0700 (PDT) Received-SPF: pass (google.com: domain of ubely@ilbers.de designates 85.214.156.166 as permitted sender) client-ip=85.214.156.166; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of ubely@ilbers.de designates 85.214.156.166 as permitted sender) smtp.mailfrom=ubely@ilbers.de Received: from baighyz.m.ilbers.de (host-80-81-17-52.static.customer.m-online.net [80.81.17.52]) (authenticated bits=0) by shymkent.ilbers.de (8.15.2/8.15.2/Debian-8+deb9u1) with ESMTPSA id 34Q70R3a013306 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 26 May 2023 09:00:30 +0200 From: Uladzimir Bely To: isar-users@googlegroups.com Subject: [PATCH v5 06/12] meta: Use cached base-apt repo to debootstrap Date: Fri, 26 May 2023 09:00:21 +0200 Message-Id: <20230526070027.16890-7-ubely@ilbers.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230526070027.16890-1-ubely@ilbers.de> References: <20230526070027.16890-1-ubely@ilbers.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shymkent.ilbers.de X-TUID: IlqqtjtykJjm This patch makes local base-apt repo to be created before debootstrap task. So, debootstrap is then done from it. The required packages are downloaded via python-apt and reprepro creates debian-like repository from .deb files. For debian targets host keyring is used while ubuntu/raspbian targets use keys specified by DISTRO_BOOTSTRAP_KEYS variable. The goal is have workable base-apt repo before first build completed. Signed-off-by: Uladzimir Bely --- .../isar-bootstrap/isar-bootstrap.inc | 99 +++++++++++++++++-- 1 file changed, 91 insertions(+), 8 deletions(-) diff --git a/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc b/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc index 0cfe82ab..e1ddac42 100644 --- a/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc +++ b/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc @@ -29,6 +29,8 @@ DISTRO_BOOTSTRAP_BASE_PACKAGES:append:https-support = ",ca-certificates" DISTRO_VARS_PREFIX ?= "${@'HOST_' if d.getVar('BOOTSTRAP_FOR_HOST') == '1' else ''}" BOOTSTRAP_DISTRO = "${@d.getVar('HOST_DISTRO' if d.getVar('BOOTSTRAP_FOR_HOST') == '1' else 'DISTRO')}" BOOTSTRAP_BASE_DISTRO = "${@d.getVar('HOST_BASE_DISTRO' if d.getVar('BOOTSTRAP_FOR_HOST') == '1' else 'BASE_DISTRO')}" +BOOTSTRAP_DISTRO_ARCH = "${@d.getVar('HOST_ARCH' if d.getVar('BOOTSTRAP_FOR_HOST') == '1' else 'DISTRO_ARCH')}" + FILESEXTRAPATHS:append = ":${BBPATH}" inherit deb-dl-dir @@ -278,12 +280,73 @@ do_bootstrap[network] = "${TASK_USE_NETWORK_AND_SUDO}" inherit compat +inherit debrepo + +debrepo_bootstrap_prepare() { + if [ "${ISAR_PREFETCH_BASE_APT}" != "1" ]; then + return + fi + + if [ "${ISAR_USE_CACHED_BASE_REPO}" = "1" ]; then + return + fi + + debrepo_args="" + if [ "${BASE_DISTRO}" != "debian" ]; then + if [ "${BASE_DISTRO}" != "raspbian" ] && [ "${BASE_DISTRO}" != "raspios" ] || [ "${BOOTSTRAP_FOR_HOST}" = "0" ]; then + debrepo_args="$debrepo_args --keydir=${WORKDIR}" + fi + else + if [ "${BASE_DISTRO_CODENAME}" = "sid" ]; then + debrepo_args="$debrepo_args --keydir=${WORKDIR}" + fi + fi + #if [ "${ISAR_USE_CACHED_BASE_REPO}" = "1" ]; then + debrepo_args="$debrepo_args --no-check-gpg" + #fi + if [ "${ISAR_ENABLE_COMPAT_ARCH}" = "1" ]; then + debrepo_args="$debrepo_args --compatarch=${COMPAT_DISTRO_ARCH}" + fi + + debrepo_workdir=${DEBREPO_TARGET_DIR} + if [ "${BOOTSTRAP_FOR_HOST}" = "1" ]; then + debrepo_args="$debrepo_args --crossarch=${DISTRO_ARCH}" + if [ ${HOST_ARCH} != ${DISTRO_ARCH} ]; then + debrepo_workdir=${DEBREPO_HOST_DIR} + fi + else + debrepo_args="$debrepo_args --isaraptdir=${REPO_ISAR_DIR}/${DISTRO}" + fi + mkdir -p "${DEBREPO_WORKDIR}" + + if [ -n "${GNUPGHOME}" ]; then + export GNUPGHOME="${GNUPGHOME}" + fi + + flock -x "${DEBREPO_WORKDIR}/repo.lock" -c " + ${SCRIPTSDIR}/debrepo --init \ + --workdir=\"${debrepo_workdir}\" \ + --aptsrcsfile=\"${APTSRCS_INIT}\" \ + --repodir=\"${REPO_BASE_DIR}\" \ + --repodbdir=\"${REPO_BASE_DB_DIR}\" \ + --mirror=\"${@get_distro_source(d)}\" \ + --arch=\"${BOOTSTRAP_DISTRO_ARCH}\" \ + --distro=\"${BOOTSTRAP_BASE_DISTRO}\" \ + --codename=\"${BASE_DISTRO_CODENAME}\" \ + ${debrepo_args} \ + gnupg locales usr-is-merged + " +} + do_bootstrap() { if [ "${ISAR_ENABLE_COMPAT_ARCH}" = "1" ]; then if [ -z "${COMPAT_DISTRO_ARCH}" ]; then bbfatal "${DISTRO_ARCH} does not have a compat arch" fi fi + + debrepo_bootstrap_prepare + debootstrap_args="--verbose --variant=minbase --include=${DISTRO_BOOTSTRAP_BASE_PACKAGES}" if [ -f "${DISTRO_BOOTSTRAP_KEYRING}" ]; then debootstrap_args="$debootstrap_args --keyring=${DISTRO_BOOTSTRAP_KEYRING}" @@ -301,8 +364,19 @@ do_bootstrap() { sudo -E -s <<'EOSUDO' set -e if [ "${BOOTSTRAP_FOR_HOST}" = "0" ]; then - arch_param="--arch=${DISTRO_ARCH}" + arch_param="--arch=${BOOTSTRAP_DISTRO_ARCH}" fi + if [ "${ISAR_PREFETCH_BASE_APT}" = "1" ]; then + flock -x "${REPO_BASE_DIR}/repo.lock" -c " + ${DEBOOTSTRAP} $debootstrap_args \ + $arch_param \ + ${@get_distro_components_argument(d)} \ + ${@get_distro_suite(d)} \ + ${ROOTFSDIR} \ + file://${REPO_BASE_DIR}/${BOOTSTRAP_BASE_DISTRO} \ + ${DISTRO_DEBOOTSTRAP_SCRIPT} + " + else ${DEBOOTSTRAP} $debootstrap_args \ $arch_param \ ${@get_distro_components_argument(d)} \ @@ -310,7 +384,7 @@ do_bootstrap() { "${ROOTFSDIR}" \ "${@get_distro_source(d)}" \ ${DISTRO_DEBOOTSTRAP_SCRIPT} - + fi # Install apt config mkdir -p "${ROOTFSDIR}/etc/apt/preferences.d" install -v -m644 "${APTPREFS}" \ @@ -382,12 +456,21 @@ do_bootstrap() { if [ "${ISAR_ENABLE_COMPAT_ARCH}" = "1" ]; then chroot "${ROOTFSDIR}" /usr/bin/dpkg --add-architecture ${COMPAT_DISTRO_ARCH} fi - - chroot "${ROOTFSDIR}" /usr/bin/apt-get update -y \ - -o APT::Update::Error-Mode=any - chroot "${ROOTFSDIR}" /usr/bin/apt-get install -y -f - chroot "${ROOTFSDIR}" /usr/bin/apt-get dist-upgrade -y \ - -o Debug::pkgProblemResolver=yes + if [ "${ISAR_PREFETCH_BASE_APT}" = "1" ]; then + flock -x "${REPO_BASE_DIR}/repo.lock" -c " + chroot ${ROOTFSDIR} /usr/bin/apt-get update -y \ + -o APT::Update::Error-Mode=any + chroot ${ROOTFSDIR} /usr/bin/apt-get install -y -f + chroot ${ROOTFSDIR} /usr/bin/apt-get dist-upgrade -y \ + -o Debug::pkgProblemResolver=yes + " + else + chroot ${ROOTFSDIR} /usr/bin/apt-get update -y \ + -o APT::Update::Error-Mode=any + chroot ${ROOTFSDIR} /usr/bin/apt-get install -y -f + chroot ${ROOTFSDIR} /usr/bin/apt-get dist-upgrade -y \ + -o Debug::pkgProblemResolver=yes + fi umount -l "${ROOTFSDIR}/dev/shm" umount -l "${ROOTFSDIR}/dev/pts" -- 2.20.1