From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6788114222392803328 X-Received: by 2002:a19:5019:: with SMTP id e25mr1053467lfb.68.1584711537158; Fri, 20 Mar 2020 06:38:57 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a2e:96d9:: with SMTP id d25ls1298085ljj.11.gmail; Fri, 20 Mar 2020 06:38:56 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvnkNBPEOKECBB+LrXos9lyXhqp3J2jiKqPS075gp2knTBUFUWhILRbPfmJqSi68V0Dzr3Y X-Received: by 2002:a2e:3818:: with SMTP id f24mr5387236lja.53.1584711536505; Fri, 20 Mar 2020 06:38:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584711536; cv=none; d=google.com; s=arc-20160816; b=sfGdCaHkaJ1MNAjXh5ZDG3Oa+F6/D88aY+wEIqgIF8+IsT4HjBh516oNjJpzSeo33V z4vUwwfjjp9FlEEKUkGpXeiT1OhuqiO2L0XHlBaDUQvMRCbrX3XnHE4f2HWaeiQs1mIr cvPh6UsuyPCvGAfq25MJoM8XAyItv3kuWnvRbnP6bXZSFTEGKpEVBsz+tE4YURNKz7Q8 0jOa/p9tpkymEQdBkL5TNEts5Tga3zw117tT90em2LG9FENp+RPexzCK2jZEbPlkQ8YF yIgaBwj2Jnfo4eXUwStbb9Yhhv3tc+rFIINU/Ay2PpQWqaTWU9mvV3FUgU/hfm6xbJqz chQg== 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=y9fbBU1QI1akJk6wK9qPNRinJAOvXZxeNaFSaNeoAzI=; b=hnMzGl8SdL/FjpOxZPYbjxXq4xwh0SrfvKN0ssvCOIXeJ4OVcVCs4/utJnBTEbx4em 4e9jyVN4TWuh0NhuGkm4vLZT+Z2yKyA4yqGMX+qZGRWugG3sFahe4XA1QINnbjSPE6HU aNxgivLlg7yM9rPHzDs5mh7zY5E5IDxYKnhF50HRPTcH79gbghGHKdVw4NGVZ+EZrRqR RvSS9HzlPLyqDM0/WrtDTnEv7JouhbxTsgOi8zfjBiZRQbTTETp5RPsb7xGbf4c/38QQ BswPMKAOuEmwDq3dA658uEILrxpjdcJCiwb6Pp4kK3MwNIAEQJ5Mi0JvZuuyoMFwSR9n IZjg== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 85.214.156.166 is neither permitted nor denied by best guess record for domain of ibr@radix50.net) smtp.mailfrom=ibr@radix50.net Return-Path: Received: from shymkent.ilbers.de (shymkent.ilbers.de. [85.214.156.166]) by gmr-mx.google.com with ESMTPS id w6si278862lfa.1.2020.03.20.06.38.56 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 20 Mar 2020 06:38:56 -0700 (PDT) Received-SPF: neutral (google.com: 85.214.156.166 is neither permitted nor denied by best guess record for domain of ibr@radix50.net) client-ip=85.214.156.166; Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 85.214.156.166 is neither permitted nor denied by best guess record for domain of ibr@radix50.net) smtp.mailfrom=ibr@radix50.net Received: from yssyq.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) with ESMTPSA id 02KDcsea001017 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 20 Mar 2020 14:38:54 +0100 Received: from yssyq.m.ilbers.de (localhost [127.0.0.1]) by yssyq.m.ilbers.de (8.15.2/8.15.2/Debian-14~deb10u1) with ESMTPS id 02KDcpRS017628 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT) for ; Fri, 20 Mar 2020 14:38:51 +0100 Received: (from ibr@localhost) by yssyq.m.ilbers.de (8.15.2/8.15.2/Submit) id 02KDcpfG017627 for isar-users@googlegroups.com; Fri, 20 Mar 2020 14:38:51 +0100 From: Baurzhan Ismagulov To: isar-users@googlegroups.com Subject: [PATCH v6 23/29] base-apt: pull base-apt population to the front of the build chain Date: Fri, 20 Mar 2020 14:38:51 +0100 Message-Id: <20200320133851.17585-1-ibr@radix50.net> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200317090445.12376552@md1za8fc.ad001.siemens.net> References: <20200317090445.12376552@md1za8fc.ad001.siemens.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,URIBL_BLOCKED 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: OXmh23mAcMUd From: Henning Schild Users had to call a special task before switching to using base-apt. With this commit you flip one switch and the repo will be created as one of the first steps. The base-apt repo gets moved from DL_DIR to DEPLOY_DIR. It is "processed" files and not just a download-cache. Signed-off-by: Henning Schild --- doc/user_manual.md | 8 +-- meta/classes/image-cache-extension.bbclass | 64 ------------------ meta/classes/image.bbclass | 1 - meta/classes/rootfs.bbclass | 2 +- meta/conf/bitbake.conf | 4 +- .../isar-bootstrap/isar-bootstrap.inc | 1 + meta/recipes-devtools/base-apt/base-apt.bb | 67 ++++++++++++++++--- scripts/ci_build.sh | 4 +- 8 files changed, 69 insertions(+), 82 deletions(-) delete mode 100644 meta/classes/image-cache-extension.bbclass diff --git a/doc/user_manual.md b/doc/user_manual.md index 8ba92ee..d13a74e 100644 --- a/doc/user_manual.md +++ b/doc/user_manual.md @@ -836,10 +836,10 @@ path to the public key in `conf/local.conf`, e.g.: BASE_REPO_KEY = "file://"' ``` - - Trigger creation of local apt caching Debian packages during image generation. + - Trigger the download and caching of all required files by doing a warm-up build. ``` -bitbake -c cache_base_repo mc:qemuarm-buster:isar-image-base +bitbake mc:qemuarm-buster:isar-image-base ``` - Set `ISAR_USE_CACHED_BASE_REPO` in `conf/local.conf`: @@ -849,14 +849,14 @@ bitbake -c cache_base_repo mc:qemuarm-buster:isar-image-base #ISAR_USE_CACHED_BASE_REPO ?= "1" #BB_NO_NETWORK ?= "1" ``` - - Remove build artifacts to use only local base-apt: + - Remove build artifacts to use only local base-apt, in fact toggling ISAR_USE_CACHED_BASE_REPO should trigger a full rebuild as well. This is just the way to be extra sure that only the download cache is used. ``` sudo rm -rf tmp ``` - - Trigger again generation of image (now using local caching repo): + - Trigger the generation of your image again (now a local repo will be created out of the download cache from the last run): ``` bitbake mc:qemuarm-buster:isar-image-base diff --git a/meta/classes/image-cache-extension.bbclass b/meta/classes/image-cache-extension.bbclass deleted file mode 100644 index 8df06f3..0000000 --- a/meta/classes/image-cache-extension.bbclass +++ /dev/null @@ -1,64 +0,0 @@ -# This software is a part of ISAR. -# Copyright (C) Siemens AG, 2019 -# -# SPDX-License-Identifier: MIT -# -# This class extends the image.bbclass to supply the creation of cache repositories - -inherit repository - -populate_base_apt() { - find "${DEBDIR}"/"${DISTRO}" -name '*\.deb' | while read package; do - # NOTE: due to packages stored by reprepro are not modified, we can - # use search by filename to check if package is already in repo. In - # addition, md5sums are compared to ensure that the package is the - # same and should not be overwritten. This method is easier and more - # robust than querying reprepro by name. - - # Check if this package is taken from Isar-apt, if so - ingore it. - repo_contains_package "${REPO_ISAR_DIR}/${DISTRO}" "${package}" && \ - continue - - # Check if this package is already in base-apt - ret=0 - repo_contains_package "${REPO_BASE_DIR}/${BASE_DISTRO}" "${package}" || - ret=$? - [ "${ret}" = "0" ] && continue - if [ "${ret}" = "1" ]; then - repo_del_package "${REPO_BASE_DIR}"/"${BASE_DISTRO}" \ - "${REPO_BASE_DB_DIR}"/"${BASE_DISTRO}" \ - "${BASE_DISTRO_CODENAME}" \ - "${base_apt_p}" - fi - - repo_add_packages "${REPO_BASE_DIR}"/"${BASE_DISTRO}" \ - "${REPO_BASE_DB_DIR}"/"${BASE_DISTRO}" \ - "${BASE_DISTRO_CODENAME}" \ - "${package}" - done - - find "${DEBSRCDIR}"/"${DISTRO}" -name '*\.dsc' | while read package; do - repo_add_srcpackage "${REPO_BASE_DIR}"/"${BASE_DISTRO}" \ - "${REPO_BASE_DB_DIR}"/"${BASE_DISTRO}" \ - "${BASE_DISTRO_CODENAME}" \ - "${package}" - done -} - -do_cache_base_repo[depends] = "base-apt:do_cache_config" -do_cache_base_repo[lockfiles] = "${REPO_BASE_DIR}/isar.lock" -do_cache_base_repo[stamp-extra-info] = "${DISTRO}-${MACHINE}" -do_cache_base_repo() { - if [ -d '${BUILDCHROOT_HOST_DIR}/var/cache/apt' ] && - [ '${DISTRO}' != '${HOST_DISTRO}' ]; then - # We would need two separate repository paths for that. - # Otherwise packages (especially the 'all' arch ones) from one - # distribution can influence the package versions of the other - # distribution. - bbfatal "Different host and target distributions are currently not supported." \ - "Try it without cross-build." - fi - - populate_base_apt -} -addtask cache_base_repo after do_rootfs do_install_imager_deps diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass index adaca5d..96ba863 100644 --- a/meta/classes/image.bbclass +++ b/meta/classes/image.bbclass @@ -66,7 +66,6 @@ ROOTFS_MANIFEST_DEPLOY_DIR ?= "${DEPLOY_DIR_IMAGE}" inherit rootfs inherit image-sdk-extension -inherit image-cache-extension inherit image-tools-extension inherit image-postproc-extension inherit image-locales-extension diff --git a/meta/classes/rootfs.bbclass b/meta/classes/rootfs.bbclass index be10189..806e824 100644 --- a/meta/classes/rootfs.bbclass +++ b/meta/classes/rootfs.bbclass @@ -151,7 +151,7 @@ rootfs_install_pkgs_install() { do_rootfs_install[root_cleandirs] = "${ROOTFSDIR}" do_rootfs_install[vardeps] += "${ROOTFS_CONFIGURE_COMMAND} ${ROOTFS_INSTALL_COMMAND}" -do_rootfs_install[depends] = "isar-bootstrap-${@'target' if d.getVar('ROOTFS_ARCH') == d.getVar('DISTRO_ARCH') else 'host'}:do_build isar-apt:do_cache_config" +do_rootfs_install[depends] = "isar-bootstrap-${@'target' if d.getVar('ROOTFS_ARCH') == d.getVar('DISTRO_ARCH') else 'host'}:do_build isar-apt:do_cache_config base-apt:do_cache" do_rootfs_install[deptask] = "do_deploy_deb" python do_rootfs_install() { configure_cmds = (d.getVar("ROOTFS_CONFIGURE_COMMAND", True) or "").split() diff --git a/meta/conf/bitbake.conf b/meta/conf/bitbake.conf index b7c0a8f..848e085 100644 --- a/meta/conf/bitbake.conf +++ b/meta/conf/bitbake.conf @@ -82,8 +82,8 @@ REPO_ISAR_DB_DIR = "${DEPLOY_DIR}/isar-apt/db" THIRD_PARTY_APT_KEYRING = "/etc/apt/trusted.gpg.d/third_party.gpg" # Base apt repository paths -REPO_BASE_DIR = "${DL_DIR}/base-apt/${DISTRO}/apt" -REPO_BASE_DB_DIR = "${DL_DIR}/base-apt/${DISTRO}/db" +REPO_BASE_DIR = "${DEPLOY_DIR}/base-apt/${DISTRO}/apt" +REPO_BASE_DB_DIR = "${DEPLOY_DIR}/base-apt/${DISTRO}/db" BB_HASHBASE_WHITELIST ?= "TMPDIR FILE PATH PWD BB_TASKHASH BBPATH BBSERVER DL_DIR \ SSTATE_DIR THISDIR FILESEXTRAPATHS FILE_DIRNAME HOME LOGNAME SHELL TERM \ diff --git a/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc b/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc index 2078115..a93c4e3 100644 --- a/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc +++ b/meta/recipes-core/isar-bootstrap/isar-bootstrap.inc @@ -219,6 +219,7 @@ def get_host_release(): do_bootstrap[vardeps] += "DISTRO_APT_PREMIRRORS" do_bootstrap[dirs] = "${DEPLOY_DIR_BOOTSTRAP}" +do_bootstrap[depends] = "base-apt:do_cache" isar_bootstrap() { deb_dl_dir_import "${ROOTFSDIR}" diff --git a/meta/recipes-devtools/base-apt/base-apt.bb b/meta/recipes-devtools/base-apt/base-apt.bb index 7c891fa..9e42c04 100644 --- a/meta/recipes-devtools/base-apt/base-apt.bb +++ b/meta/recipes-devtools/base-apt/base-apt.bb @@ -9,26 +9,77 @@ inherit repository BASE_REPO_KEY ?= "" KEYFILES ?= "" -do_cache_config[stamp-extra-info] = "${DISTRO}" -do_cache_config[lockfiles] = "${REPO_BASE_DIR}/isar.lock" +populate_base_apt() { + find "${DEBDIR}"/"${DISTRO}" -name '*\.deb' | while read package; do + # NOTE: due to packages stored by reprepro are not modified, we can + # use search by filename to check if package is already in repo. In + # addition, md5sums are compared to ensure that the package is the + # same and should not be overwritten. This method is easier and more + # robust than querying reprepro by name. -# Generate reprepro config for current distro if it doesn't exist. Once it's -# generated, this task should do nothing. -repo_config() { + # Check if this package is taken from Isar-apt, if so - ingore it. + repo_contains_package "${REPO_ISAR_DIR}/${DISTRO}" "${package}" && \ + continue + + # Check if this package is already in base-apt + ret=0 + repo_contains_package "${REPO_BASE_DIR}/${BASE_DISTRO}" "${package}" || + ret=$? + [ "${ret}" = "0" ] && continue + if [ "${ret}" = "1" ]; then + repo_del_package "${REPO_BASE_DIR}"/"${BASE_DISTRO}" \ + "${REPO_BASE_DB_DIR}"/"${BASE_DISTRO}" \ + "${BASE_DISTRO_CODENAME}" \ + "${base_apt_p}" + fi + + repo_add_packages "${REPO_BASE_DIR}"/"${BASE_DISTRO}" \ + "${REPO_BASE_DB_DIR}"/"${BASE_DISTRO}" \ + "${BASE_DISTRO_CODENAME}" \ + "${package}" + done + + find "${DEBSRCDIR}"/"${DISTRO}" -name '*\.dsc' | while read package; do + repo_add_srcpackage "${REPO_BASE_DIR}"/"${BASE_DISTRO}" \ + "${REPO_BASE_DB_DIR}"/"${BASE_DISTRO}" \ + "${BASE_DISTRO_CODENAME}" \ + "${package}" + done +} + +do_cache[stamp-extra-info] = "${DISTRO}" +do_cache[lockfiles] = "${REPO_BASE_DIR}/isar.lock" + +repo() { repo_create "${REPO_BASE_DIR}"/"${BASE_DISTRO}" \ "${REPO_BASE_DB_DIR}"/"${BASE_DISTRO}" \ "${BASE_DISTRO_CODENAME}" \ "${KEYFILES}" + + if [ -d '${BUILDCHROOT_HOST_DIR}/var/cache/apt' ] && + [ '${DISTRO}' != '${HOST_DISTRO}' ]; then + # We would need two separate repository paths for that. + # Otherwise packages (especially the 'all' arch ones) from one + # distribution can influence the package versions of the other + # distribution. + bbfatal "Different host and target distributions are currently not supported." \ + "Try it without cross-build." + fi + + populate_base_apt } -python do_cache_config() { +python do_cache() { + if not bb.utils.to_boolean(d.getVar('ISAR_USE_CACHED_BASE_REPO')): + return 0 + for key in d.getVar('BASE_REPO_KEY').split(): d.appendVar("SRC_URI", " %s" % key) fetcher = bb.fetch2.Fetch([key], d) filename = fetcher.localpath(key) d.appendVar("KEYFILES", " %s" % filename) - bb.build.exec_func('repo_config', d) + bb.build.exec_func('repo', d) } -addtask cache_config after do_unpack before do_build +addtask cache after do_unpack before do_build diff --git a/scripts/ci_build.sh b/scripts/ci_build.sh index 71adea8..1061226 100755 --- a/scripts/ci_build.sh +++ b/scripts/ci_build.sh @@ -145,7 +145,7 @@ if [ -n "$REPRO_BUILD" ]; then # Enable use of signed cached base repository echo BASE_REPO_KEY=\"file://$ISAR_TESTSUITE_GPG_PUB_KEY_FILE\" >> conf/local.conf - bitbake $BB_ARGS -c cache_base_repo $REPRO_TARGETS_SET_SIGNED + bitbake $BB_ARGS $REPRO_TARGETS_SET_SIGNED while [ -e bitbake.sock ]; do sleep 1; done sudo rm -rf tmp sed -i -e 's/#ISAR_USE_CACHED_BASE_REPO ?= "1"/ISAR_USE_CACHED_BASE_REPO ?= "1"/g' conf/local.conf @@ -159,7 +159,7 @@ if [ -n "$REPRO_BUILD" ]; then sed -i -e 's/^BASE_REPO_KEY/#BASE_REPO_KEY/g' conf/local.conf # Enable use of unsigned cached base repository - bitbake $BB_ARGS -c cache_base_repo $REPRO_TARGETS_SET + bitbake $BB_ARGS $REPRO_TARGETS_SET while [ -e bitbake.sock ]; do sleep 1; done sudo rm -rf tmp sed -i -e 's/#ISAR_USE_CACHED_BASE_REPO ?= "1"/ISAR_USE_CACHED_BASE_REPO ?= "1"/g' conf/local.conf -- 2.20.1