From patchwork Thu May 11 10:50:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Mikanovich X-Patchwork-Id: 2802 Return-Path: Received: from shymkent.ilbers.de ([unix socket]) by shymkent (Cyrus 2.5.10-Debian-2.5.10-3+deb9u2) with LMTPA; Thu, 11 May 2023 12:50:43 +0200 X-Sieve: CMU Sieve 2.4 Received: from mail-vk1-f187.google.com (mail-vk1-f187.google.com [209.85.221.187]) by shymkent.ilbers.de (8.15.2/8.15.2/Debian-8+deb9u1) with ESMTPS id 34BAof3t011899 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 May 2023 12:50:42 +0200 Received: by mail-vk1-f187.google.com with SMTP id 71dfb90a1353d-44fb5fd0489sf1750795e0c.1; Thu, 11 May 2023 03:50:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1683802236; cv=pass; d=google.com; s=arc-20160816; b=KySCqZMQokCpSmaMwzuU+kPYC8Qw74SbQdumLopqz7z5WPYnxc59kaP17XE2DYw806 Pg9htYSJJ6+yQaMpUvC2MxIZpQSalAV/AFE5wPzGmDyrSTi9kVT3iZopZmupL8uF/A0G REGhTOh8b1dKJYkIe42vOmkAG5KbAN9m/PB+2OwMy6CadW+XNWZqnYn/XUIUWZY9G6JZ GpmX7AbpXkhhwG4eBlKVpq1mJABPSnCSvy8rmNFsEhlZdJwgSqn/EvMZPILpVwig4Fjc xXNG8hX5sHQrHVweIaVbEPVmExYUCtUfEIx+1NhmCx/iqUWYruc+dasg2smaFYbba+oL Gy6Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=4FIe7xtK8Rowts7pDSOT0q2tfrVmqxuBNErXvmABL4M=; b=V2hyK/QeE/i9guIsdv5iKajDgDel5UYsqcAZQTAuwxS3EzuKwiRNQdaEKZo8LYOp3E yrmHJA26VYFHtZlnfXL0v0TfligdURcPDhBmhUEagQheNB7FMs0X7wOt1YPTc1eAcSnK TFdfSsBUcMheJBZYuxP3cmhZdqn+NDVWzvetx0EKneUTBRLWG82ou4Ni+rJf55jTSl+y r5HRli7sk3ThMe7jIjlb7ixdOB7aAwqCAUW3Aawm9S/dFU6Nm4m3uBFqGW/FvSVfnQmS /1VoHb6zQrrKlh5jJA/jbd2Ni3wA/a1jx2YGTmva8ycl385AAWLsKTiEYwNAzXHHWvkS Atlg== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of amikan@ilbers.de designates 85.214.156.166 as permitted sender) smtp.mailfrom=amikan@ilbers.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20221208; t=1683802236; x=1686394236; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:sender:from:to:cc:subject:date:message-id :reply-to; bh=4FIe7xtK8Rowts7pDSOT0q2tfrVmqxuBNErXvmABL4M=; b=jMDZ+mz32VPOlDrsTwiPVgwomKcp/sTRFmh0mMbgZrWaps8fu1AgUCjsa9MF+s3Kd6 Dx8DweewTxDFWStb5VsF6zflkwB/UfYQY5OZvtS/ewLobXEPdyYbfP3Xd3kLIW7KsvWU EyZGL1JY0JSRx7b3qnvHYo8ycAgajShd52vEUmWhSgH4yPTn/EDavGYGZ5OrnWTmOx/v yotupfcKqwSjuAFMk3RUry7kiljE5scMthXWw67OV9B8J38bab71mUsgJ12TdRKQlRzg If1iXfxEXacMzVVf0aQn9YCkFnCY6EYEzVZk5Sbt0DkCLHxMgucp3a4q+QNwDCmD6xgm XXHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683802236; x=1686394236; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :x-beenthere:x-gm-message-state:sender:from:to:cc:subject:date :message-id:reply-to; bh=4FIe7xtK8Rowts7pDSOT0q2tfrVmqxuBNErXvmABL4M=; b=QpMp1tjuuvctUCHbB0P5Xo15Hag5ifwG79sP1TloeQEzZxUcTMzobM/V4TQKxQXK7F KeEkxQtB933uY50JzmCSi8x9WQ4R0/iQzO0pZ5dB90DjFmZRhpUDtQoO8Ybw6BPWNBOg z5SavP/iMKRqMoxRwyq2Z76R37yn9GNsUi9bjeBBK70gQ/HwzHuTqm8zqmNdiPF8BadR Foe3cD0phcRxzKu8ZjDT/wALbjjsFlznc3j6xyIliWb6HALKKT7qSEaJXH5vjoTSqhkY 9I0NPdBrSE/pMBXVtQROjCh/JJTjjKqp8P288x7Y14A8WlxTk6d4bq2HgN6tPhQfGaGA H1xA== Sender: isar-users@googlegroups.com X-Gm-Message-State: AC+VfDx5AgqiunDYI8xZSjAI5s+lkiLZCr9TqLzj6hwpUnbVBygQbK3f jx2RfGEWnF8VCreuDgOYzy0= X-Google-Smtp-Source: ACHHUZ6Kb1KtJjxmIN03Cm42f+vrhNwdLPqSue7gFUSlotTgmgMzoCXgWrUcZWx9KUImyS5goucNxA== X-Received: by 2002:a67:e10f:0:b0:436:dc9:c409 with SMTP id d15-20020a67e10f000000b004360dc9c409mr2320164vsl.5.1683802236228; Thu, 11 May 2023 03:50:36 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a1f:a0cf:0:b0:440:893c:91c6 with SMTP id j198-20020a1fa0cf000000b00440893c91c6ls4060298vke.7.-pod-prod-gmail; Thu, 11 May 2023 03:50:35 -0700 (PDT) X-Received: by 2002:a1f:bfc4:0:b0:44f:a955:aaa9 with SMTP id p187-20020a1fbfc4000000b0044fa955aaa9mr5536246vkf.5.1683802235603; Thu, 11 May 2023 03:50:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683802235; cv=none; d=google.com; s=arc-20160816; b=j46TfgxNG4M6kFFJkz/hS461O3v6BFUlWfDjj+nic9nSkBshhBVAVbvlEDKXYBzjM5 c4Sx9z/28SD2vXjtg5x9ZVwFCNswzMHqVNUp5hIOxeTSc69Gz6y/yHdyTtmZmwaAvagw Rs7dMKOrYJisDbq5CFRuVWmuqtIsw9L1qVQco8cqZGRCFxRGdry34s+KMjhXs/OxREuE b5hhmkj0u2VNpOdd1izBZGoRdSnry9uIuFdCw34tqIuxU6ZeX1SnLjkJvviQNamswI4B tr3dTpvNDyas5kwI81M/vhXSVPaPmOy1CzsPeYSh9/sTKSqLdHRgS/HfGLoES+E71BLh FLrQ== 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:cc:to:from; bh=waKAq6dAsSMFYDugUljvT9lKAjOdSQAOZTiJofKDal4=; b=RMdXMLuoi+ovmEl8LrTH0HrX/WIAXfgGlzHmoLqedH2/o2taBEHrBiEFBKp6fCcZrn QgImOQfJWRqFHDIe2cBrvdtkqOieRbM96ugciIMvEzlhuiQ4Y28Cd6a8f/YXmxtgwcSw gAnxrrNzUQMNXlwIr0I5Yx0aTzdQtDh0u1bpzh9OtBP7GqsQeMa/Iciotw6QBkKYVOqM VYhmVQ5ka+3gVnvhCgVLnjg2Fvzi6g5iSfLaImj6ssAjNfzXp1lnRlzMKmjpwOBXHLKN bzQGb+8eIyOuY1y5mHbqfrxKdge7y45sZDcdodaZ87D/vex+8TryA20Htj8+m67+DnUB +kjQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of amikan@ilbers.de designates 85.214.156.166 as permitted sender) smtp.mailfrom=amikan@ilbers.de Received: from shymkent.ilbers.de (shymkent.ilbers.de. [85.214.156.166]) by gmr-mx.google.com with ESMTPS id n28-20020a05612213bc00b0044f89ac0658si1076172vkp.0.2023.05.11.03.50.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 11 May 2023 03:50:35 -0700 (PDT) Received-SPF: pass (google.com: domain of amikan@ilbers.de designates 85.214.156.166 as permitted sender) client-ip=85.214.156.166; Received: from user-B660.. ([85.254.75.115]) (authenticated bits=0) by shymkent.ilbers.de (8.15.2/8.15.2/Debian-8+deb9u1) with ESMTPSA id 34BAoQ02011851 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 May 2023 12:50:29 +0200 From: Anton Mikanovich To: isar-users@googlegroups.com Cc: Anton Mikanovich Subject: [PATCH v4 2/7] imager: Migrate from buildchroot to schroot Date: Thu, 11 May 2023 13:50:15 +0300 Message-Id: <20230511105020.1881496-3-amikan@ilbers.de> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230511105020.1881496-1-amikan@ilbers.de> References: <20230511105020.1881496-1-amikan@ilbers.de> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_PASS 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-Original-Sender: amikan@ilbers.de X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of amikan@ilbers.de designates 85.214.156.166 as permitted sender) smtp.mailfrom=amikan@ilbers.de Precedence: list Mailing-list: list isar-users@googlegroups.com; contact isar-users+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: isar-users@googlegroups.com X-Google-Group-Id: 914930254986 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= Install dependencies and perform all imager actions using schroot instead of buildchroot. All the changes made during imager task will be lost after the finish. This requires installing imager dependencies during every run. Signed-off-by: Anton Mikanovich --- meta/classes/image-tools-extension.bbclass | 97 +++++++++++++++------- 1 file changed, 66 insertions(+), 31 deletions(-) diff --git a/meta/classes/image-tools-extension.bbclass b/meta/classes/image-tools-extension.bbclass index 7c84505f..04ed1f84 100644 --- a/meta/classes/image-tools-extension.bbclass +++ b/meta/classes/image-tools-extension.bbclass @@ -5,43 +5,78 @@ # # This file extends the image.bbclass to supply tools for futher imager functions -inherit buildchroot +inherit sbuild IMAGER_INSTALL ??= "" IMAGER_BUILD_DEPS ??= "" DEPENDS += "${IMAGER_BUILD_DEPS}" -do_install_imager_deps[depends] = "${BUILDCHROOT_DEP} isar-apt:do_cache_config" -do_install_imager_deps[deptask] = "do_deploy_deb" -do_install_imager_deps[lockfiles] += "${REPO_ISAR_DIR}/isar.lock" -do_install_imager_deps[network] = "${TASK_USE_NETWORK_AND_SUDO}" -do_install_imager_deps() { - if [ -z "${@d.getVar("IMAGER_INSTALL").strip()}" ]; then - exit - fi +SCHROOT_MOUNTS = "${WORKDIR}:${PP_WORK} ${IMAGE_ROOTFS}:${PP_ROOTFS} ${DEPLOY_DIR_IMAGE}:${PP_DEPLOY}" +SCHROOT_MOUNTS += "${REPO_ISAR_DIR}/${DISTRO}:/isar-apt" + +imager_run() { + schroot_create_configs + insert_mounts + + session_id=$(schroot -q -b -c ${SBUILD_CHROOT}) + echo "Started session: ${session_id}" + + # Schroot session mountpoint for deb downloads import/export + schroot_dir="/var/run/schroot/mount/${session_id}" + + # setting up error handler + imager_cleanup() { + set +e + schroot -q -f -e -c ${session_id} > /dev/null 2>&1 + remove_mounts > /dev/null 2>&1 + schroot_delete_configs > /dev/null 2>&1 + } + trap 'exit 1' INT HUP QUIT TERM ALRM USR1 + trap 'imager_cleanup' EXIT + + if [ -n "${@d.getVar("IMAGER_INSTALL").strip()}" ]; then + echo "Installing deps: ${IMAGER_INSTALL}" - distro="${BASE_DISTRO}-${BASE_DISTRO_CODENAME}" - if [ ${ISAR_CROSS_COMPILE} -eq 1 ]; then - distro="${HOST_BASE_DISTRO}-${BASE_DISTRO_CODENAME}" + distro="${BASE_DISTRO}-${BASE_DISTRO_CODENAME}" + if [ ${ISAR_CROSS_COMPILE} -eq 1 ]; then + distro="${HOST_BASE_DISTRO}-${BASE_DISTRO_CODENAME}" + fi + + # prepare isar-apt + schroot -r -c ${session_id} -d / -u root -- sh -c " \ + mkdir -p '/etc/apt/sources.list.d' + echo 'deb [trusted=yes] file:///isar-apt ${DEBDISTRONAME} main' > \ + '/etc/apt/sources.list.d/isar-apt.list' + + mkdir -p '/etc/apt/preferences.d' + cat << EOF > '/etc/apt/preferences.d/isar-apt' +Package: * +Pin: release n=${DEBDISTRONAME} +Pin-Priority: 1000 +EOF" + + E="${@ isar_export_proxies(d)}" + deb_dl_dir_import ${schroot_dir} ${distro} + schroot -r -c ${session_id} -d / -u root -- sh -c " \ + apt-get update \ + -o Dir::Etc::SourceList='sources.list.d/isar-apt.list' \ + -o Dir::Etc::SourceParts='-' \ + -o APT::Get::List-Cleanup='0' + apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y \ + --allow-unauthenticated --allow-downgrades --download-only install \ + ${IMAGER_INSTALL}" + + deb_dl_dir_export ${schroot_dir} ${distro} + schroot -r -c ${session_id} -d / -u root -- sh -c " \ + apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y \ + --allow-unauthenticated --allow-downgrades install \ + ${IMAGER_INSTALL}" fi - buildchroot_do_mounts - - E="${@ isar_export_proxies(d)}" - deb_dl_dir_import ${BUILDCHROOT_DIR} ${distro} - sudo -E chroot ${BUILDCHROOT_DIR} sh -c ' \ - apt-get update \ - -o Dir::Etc::SourceList="sources.list.d/isar-apt.list" \ - -o Dir::Etc::SourceParts="-" \ - -o APT::Get::List-Cleanup="0" - apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y \ - --allow-unauthenticated --allow-downgrades --download-only install \ - ${IMAGER_INSTALL}' - - deb_dl_dir_export ${BUILDCHROOT_DIR} ${distro} - sudo -E chroot ${BUILDCHROOT_DIR} sh -c ' \ - apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y \ - --allow-unauthenticated --allow-downgrades install \ - ${IMAGER_INSTALL}' + schroot -r -c ${session_id} "$@" + + schroot -e -c ${session_id} + + remove_mounts + schroot_delete_configs } -addtask install_imager_deps before do_image_tools