From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6995249996219023360 X-Received: by 2002:adf:dc05:: with SMTP id t5mr7849074wri.326.1628708560204; Wed, 11 Aug 2021 12:02:40 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:adf:a191:: with SMTP id u17ls837828wru.3.gmail; Wed, 11 Aug 2021 12:02:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx7y+7rEPJ3UOXNzsHaaOnxupFv0fyy1j+EmNwLjNt7ELAdDmzS6YCmAlv9v05usrGQVPEe X-Received: by 2002:a5d:5302:: with SMTP id e2mr24885856wrv.47.1628708559006; Wed, 11 Aug 2021 12:02:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628708559; cv=none; d=google.com; s=arc-20160816; b=I2uFG7WdpO50FzL+G2s7Koa6IFKtsRZXrZXoV4ExiIsi2dkpN1uIywTnRGYUXLEvr/ URtLiLmyy13FBoHPQn33RzEfKxoI1w3+Jx2K3cMM5eIKZ/r9IHNZoPIWk86x7okbg1Pc LFhTKVjofJE37jj13VhoZE5kFigtG9UqQEyOjf9SNsOfvCzvCAK9Yi/oF10i9egiK9Ze dbltnxY6+b/jNJ3xBXdFQPf7FIFzMCwlbU4+xhIa6rVpTGv9X/hXg+z8jOwz9zVSk4WQ SI8EbXxtWHzzgIhtzBrpGlUtH39cBXEDe+vVmWlcd7fX1YXPAbBJ0J19YiYfdjSE3PVv UiAQ== 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=vuw+80oPDmWubrWyq7ZJ5FYcKT2xvc3aUveLTTP0sDY=; b=xqbP3dl7PF7d+/8EGpg0DY+JbJVTUBLP8I4DM7BYSpLibt0/eccbD2FiXAvoKqljrs ErC3V36/6ZXrPlIR0/rqVxxqQn56Cd1nBbYxBcWtUUbxPV5xTnbzPzTbnl841M3L0aTg 3bK4oj1UjwV3F3GeAlZ4Bv9nvXt0jP5dx927XqR1hJhS36UnxmE2VREUbv2u2mnJTd/d +Y2OaK2GMBNq6sXww6CWNLrc5Z6zb4J4sy+wOnQEhHppdq0QOKiL6mz4POumVfC6Kc05 Onw1mfMXbcEqIs1utvQn1tkQEHBvCsB7zhIai7vivHZPB+ZzU7m4rEI/gntHgxWM/72Y P4dQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of jan.kiszka@siemens.com designates 194.138.37.39 as permitted sender) smtp.mailfrom=jan.kiszka@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Return-Path: Received: from lizzard.sbs.de (lizzard.sbs.de. [194.138.37.39]) by gmr-mx.google.com with ESMTPS id u16si8881wrg.5.2021.08.11.12.02.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Aug 2021 12:02:38 -0700 (PDT) Received-SPF: pass (google.com: domain of jan.kiszka@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 jan.kiszka@siemens.com designates 194.138.37.39 as permitted sender) smtp.mailfrom=jan.kiszka@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: from mail2.sbs.de (mail2.sbs.de [192.129.41.66]) by lizzard.sbs.de (8.15.2/8.15.2) with ESMTPS id 17BJ2c2P031724 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Wed, 11 Aug 2021 21:02:38 +0200 Received: from md1f2u6c.ad001.siemens.net ([167.87.241.87]) by mail2.sbs.de (8.15.2/8.15.2) with ESMTP id 17BJ2bHE028609 for ; Wed, 11 Aug 2021 21:02:38 +0200 From: Jan Kiszka To: isar-users Subject: [PATCH v2 3/4] isar-bootstrap: Further consolidate host and target Date: Wed, 11 Aug 2021 21:02:36 +0200 Message-Id: <8245608b46eb5fc7bdb7acd79c47ab66a8fa4fd7.1628708557.git.jan.kiszka@siemens.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TUID: 2yESFENlZ+Lh From: Jan Kiszka Control the mode via the boolean var BOOTSTRAP_FOR_HOST, deriving DISTRO_VARS_PREFIX from that. Add BOOTSTRAP_DISTRO which resolves to the content of DISTRO or HOST_DISTRO, according to BOOTSTRAP_FOR_HOST. Furthermore, use DISTRO_VARS_PREFIX in get_aptsources_list, rather than passing an is_host parameter down the call chain. There are two cases where is_host has so far hard-coded: - "${@get_distro_suite(d, True)}-${COMPAT_DISTRO_ARCH}" = "stretch-i386" - "${@get_distro_suite(d, True)}" = "stretch" && kernel-major-version < 4" In both cases, it was at least inaccurate to hard-code is_host=True so far. We now use the actual distro that is to be bootstrapped. As the --host parameter of isar_bootstrap is now obsolete, we can fold that function into a common do_bootstrap. Signed-off-by: Jan Kiszka --- .../isar-bootstrap/isar-bootstrap-host.bb | 8 +- .../isar-bootstrap/isar-bootstrap-target.bb | 6 - .../isar-bootstrap/isar-bootstrap.inc | 112 +++++++----------- 3 files changed, 46 insertions(+), 80 deletions(-) diff --git a/meta/recipes-core/isar-bootstrap/isar-bootstrap-host.bb b/meta/recipes-core/isar-bootstrap/isar-bootstrap-host.bb index 8f1fced..4f90fd0 100644 --- a/meta/recipes-core/isar-bootstrap/isar-bootstrap-host.bb +++ b/meta/recipes-core/isar-bootstrap/isar-bootstrap-host.bb @@ -9,15 +9,9 @@ Description = "Minimal host Debian root file system" DEPLOY_ISAR_BOOTSTRAP = "${DEPLOY_DIR_BOOTSTRAP}/${HOST_DISTRO}-host_${DISTRO}-${DISTRO_ARCH}" -DISTRO_VARS_PREFIX = "HOST_" +BOOTSTRAP_FOR_HOST = "1" require isar-bootstrap.inc HOST_DISTRO_BOOTSTRAP_KEYS ?= "" DISTRO_BOOTSTRAP_KEYS = "${HOST_DISTRO_BOOTSTRAP_KEYS}" - -OVERRIDES_append = ":${@get_distro_needs_https_support(d, True)}" - -do_bootstrap() { - isar_bootstrap --host -} diff --git a/meta/recipes-core/isar-bootstrap/isar-bootstrap-target.bb b/meta/recipes-core/isar-bootstrap/isar-bootstrap-target.bb index 7158a86..c66cb3b 100644 --- a/meta/recipes-core/isar-bootstrap/isar-bootstrap-target.bb +++ b/meta/recipes-core/isar-bootstrap/isar-bootstrap-target.bb @@ -10,9 +10,3 @@ Description = "Minimal target Debian root file system" DEPLOY_ISAR_BOOTSTRAP = "${DEPLOY_DIR_BOOTSTRAP}/${DISTRO}-${DISTRO_ARCH}" require isar-bootstrap.inc - -OVERRIDES_append = ":${@get_distro_needs_https_support(d, False)}" - -do_bootstrap() { - isar_bootstrap -} diff --git a/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc b/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc index a846389..f1299f9 100644 --- a/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc +++ b/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc @@ -1,7 +1,7 @@ # Minimal debian root file system # # This software is a part of ISAR. -# Copyright (c) Siemens AG, 2018 +# Copyright (c) Siemens AG, 2018-2021 # # SPDX-License-Identifier: MIT @@ -15,6 +15,8 @@ SRC_URI = " \ file://chroot-setup.sh" PV = "1.0" +BOOTSTRAP_FOR_HOST ?= "0" + DEBOOTSTRAP ?= "qemu-debootstrap" ROOTFSDIR = "${WORKDIR}/rootfs" APTPREFS = "${WORKDIR}/apt-preferences" @@ -26,8 +28,8 @@ DEPLOY_ISAR_BOOTSTRAP ?= "" DISTRO_BOOTSTRAP_BASE_PACKAGES = "locales" DISTRO_BOOTSTRAP_BASE_PACKAGES_append_gnupg = ",gnupg" DISTRO_BOOTSTRAP_BASE_PACKAGES_append_https-support = "${@https_support(d)}" - -DISTRO_VARS_PREFIX ?= "" +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')}" inherit deb-dl-dir @@ -137,15 +139,12 @@ def aggregate_aptsources_list(d, file_list, file_out): out_fd.write("\n".encode()) out_fd.write("\n".encode()) -def get_aptsources_list(d, is_host=False): - if is_host: - apt_sources_list = (d.getVar("HOST_DISTRO_APT_SOURCES", True) or "").split() - else: - apt_sources_list = (d.getVar("DISTRO_APT_SOURCES", True) or "").split() - return apt_sources_list +def get_aptsources_list(d): + apt_sources_var = d.getVar("DISTRO_VARS_PREFIX") + "DISTRO_APT_SOURCES" + return (d.getVar(apt_sources_var, True) or "").split() -def generate_distro_sources(d, is_host=False): - apt_sources_list = get_aptsources_list(d, is_host) +def generate_distro_sources(d): + apt_sources_list = get_aptsources_list(d) for entry in apt_sources_list: entry_real = bb.parse.resolve_file(entry, d) with open(entry_real, "r") as in_fd: @@ -155,28 +154,30 @@ def generate_distro_sources(d, is_host=False): parsed = get_apt_source_mirror(d, parsed) yield parsed -def get_distro_primary_source_entry(d, is_host=False): - apt_sources_list = get_aptsources_list(d, is_host) - for source in generate_distro_sources(d, is_host): +def get_distro_primary_source_entry(d): + apt_sources_list = get_aptsources_list(d) + for source in generate_distro_sources(d): if source[0] == "deb": return source[2:] return ["", "", ""] -def get_distro_have_https_source(d, is_host=False): - return any(source[2].startswith("https://") for source in generate_distro_sources(d, is_host)) +def get_distro_have_https_source(d): + return any(source[2].startswith("https://") for source in generate_distro_sources(d)) -def https_support(d, is_host=False): - if get_distro_suite(d, is_host) == "stretch": +def https_support(d): + if get_distro_suite(d) == "stretch": return ",apt-transport-https,ca-certificates" else: return ",ca-certificates" -def get_distro_needs_https_support(d, is_host=False): - if get_distro_have_https_source(d, is_host): +def get_distro_needs_https_support(d): + if get_distro_have_https_source(d): return "https-support" else: return "" +OVERRIDES_append = ":${@get_distro_needs_https_support(d)}" + def get_distro_needs_gpg_support(d): apt_keys = d.getVar("DISTRO_BOOTSTRAP_KEYS") or "" apt_keys += " " + (d.getVar("THIRD_PARTY_APT_KEYS") or "") @@ -187,14 +188,14 @@ def get_distro_needs_gpg_support(d): OVERRIDES_append = ":${@get_distro_needs_gpg_support(d)}" -def get_distro_source(d, is_host): - return get_distro_primary_source_entry(d, is_host)[0] +def get_distro_source(d): + return get_distro_primary_source_entry(d)[0] -def get_distro_suite(d, is_host): - return get_distro_primary_source_entry(d, is_host)[1] +def get_distro_suite(d): + return get_distro_primary_source_entry(d)[1] -def get_distro_components_argument(d, is_host): - components = get_distro_primary_source_entry(d, is_host)[2] +def get_distro_components_argument(d): + components = get_distro_primary_source_entry(d)[2] if components and components.strip(): return "--components=" + ",".join(components.split()) else: @@ -262,23 +263,12 @@ do_bootstrap[vardeps] += " \ do_bootstrap[dirs] = "${DEPLOY_DIR_BOOTSTRAP}" do_bootstrap[depends] = "base-apt:do_cache isar-apt:do_cache_config" -addtask bootstrap before do_build after do_generate_keyrings - -isar_bootstrap() { - IS_HOST="" - while true; do - case "$1" in - --host) IS_HOST=1 ;; - -*) bbfatal "$0: invalid option specified: $1" ;; - *) break ;; - esac - shift - done +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 - if [ "${@get_distro_suite(d, True)}-${COMPAT_DISTRO_ARCH}" = "stretch-i386" ]; then + if [ "${@get_distro_suite(d)}-${COMPAT_DISTRO_ARCH}" = "stretch-i386" ]; then bbfatal "compat arch build for stretch-i386 not supported" fi fi @@ -290,33 +280,23 @@ isar_bootstrap() { debootstrap_args="$debootstrap_args --no-check-gpg" fi E="${@ isar_export_proxies(d)}" - export IS_HOST debootstrap_args E + export BOOTSTRAP_FOR_HOST debootstrap_args E sudo rm -rf --one-file-system "${ROOTFSDIR}" - if [ "${IS_HOST}" ];then - deb_dl_dir_import "${ROOTFSDIR}" "${HOST_DISTRO}" - else - deb_dl_dir_import "${ROOTFSDIR}" "${DISTRO}" - fi + deb_dl_dir_import "${ROOTFSDIR}" "${BOOTSTRAP_DISTRO}" sudo -E -s <<'EOSUDO' set -e - if [ ${IS_HOST} ]; then - ${DEBOOTSTRAP} $debootstrap_args \ - ${@get_distro_components_argument(d, True)} \ - "${@get_distro_suite(d, True)}" \ - "${ROOTFSDIR}" \ - "${@get_distro_source(d, True)}" \ - ${DISTRO_DEBOOTSTRAP_SCRIPT} - else - ${DEBOOTSTRAP} $debootstrap_args \ - --arch="${DISTRO_ARCH}" \ - ${@get_distro_components_argument(d, False)} \ - "${@get_distro_suite(d, False)}" \ - "${ROOTFSDIR}" \ - "${@get_distro_source(d, False)}" \ - ${DISTRO_DEBOOTSTRAP_SCRIPT} + if [ "${BOOTSTRAP_FOR_HOST}" = "0" ]; then + arch_param="--arch=${DISTRO_ARCH}" fi + ${DEBOOTSTRAP} $debootstrap_args \ + $arch_param \ + ${@get_distro_components_argument(d)} \ + "${@get_distro_suite(d)}" \ + "${ROOTFSDIR}" \ + "${@get_distro_source(d)}" \ + ${DISTRO_DEBOOTSTRAP_SCRIPT} # Install apt config mkdir -p "${ROOTFSDIR}/etc/apt/preferences.d" @@ -363,7 +343,7 @@ isar_bootstrap() { chroot "${ROOTFSDIR}" gpgconf --kill gpg-agent && /bin/rm -rf "${MY_GPGHOME}" fi - if [ "${@get_distro_suite(d, True)}" = "stretch" ] && [ "${@get_host_release().split('.')[0]}" -lt "4" ]; then + if [ "${@get_distro_suite(d)}" = "stretch" ] && [ "${@get_host_release().split('.')[0]}" -lt "4" ]; then install -v -m644 "${WORKDIR}/isar-apt-fallback.conf" \ "${ROOTFSDIR}/etc/apt/apt.conf.d/55isar-fallback.conf" fi @@ -387,7 +367,7 @@ isar_bootstrap() { export DEBIAN_FRONTEND=noninteractive - if [ ${IS_HOST} ]; then + if [ "${BOOTSTRAP_FOR_HOST}" = "1" ]; then chroot "${ROOTFSDIR}" /usr/bin/dpkg --add-architecture ${DISTRO_ARCH} fi @@ -408,13 +388,11 @@ isar_bootstrap() { # Finalize debootstrap by setting the link in deploy ln -Tfsr "${ROOTFSDIR}" "${DEPLOY_ISAR_BOOTSTRAP}" EOSUDO - if [ "${IS_HOST}" ];then - deb_dl_dir_export "${ROOTFSDIR}" "${HOST_DISTRO}" - else - deb_dl_dir_export "${ROOTFSDIR}" "${DISTRO}" - fi + deb_dl_dir_export "${ROOTFSDIR}" "${BOOTSTRAP_DISTRO}" } +addtask bootstrap before do_build after do_generate_keyrings + CLEANFUNCS = "clean_deploy" clean_deploy() { rm -f "${DEPLOY_ISAR_BOOTSTRAP}" -- 2.31.1