From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6458972999552860160 X-Received: by 10.28.92.208 with SMTP id q199mr310720wmb.2.1503846845524; Sun, 27 Aug 2017 08:14:05 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 10.25.229.14 with SMTP id c14ls23571lfh.47.gmail; Sun, 27 Aug 2017 08:14:05 -0700 (PDT) X-Received: by 10.46.9.71 with SMTP id 68mr240109ljj.34.1503846845068; Sun, 27 Aug 2017 08:14:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503846845; cv=none; d=google.com; s=arc-20160816; b=iZFS/Uhfr69ruGLbOLi0/5hKAwDy1O+Xg0wDNOMYNVk3n/dx83/5iSQNC88RR1L6ei zCWR9b/YWpA0N4hNgML92/nE9r8gv7t8VWnJa7mEwFh8iD9M2HNSzglRZevjC2DDnb9J HgK1Wm4Q+aIr0hvnm8V8znqSq7yWLnxSyRqHxPQl5LxrDbqJMD0gCHuD7hTldp1Hr4h8 hrOcmbJOFC0Hl8kx3nDBLTeN181PVmp8dqQqo108hhgfkq+ovGzDexaVbxbfESFdRbgk xwqULJZ4Qc+0d7jKNL5UBvKfOD47xUt4jI4csvy44cJNamNpNC6jAUyBitYnl7ZJsgiX 4Y8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=U4iGEIOJs6yMBPdmfIAGyYgWevzyXu6OyMaspA1/gJA=; b=wnBbFH3KyqmEmu1+WNjwWjFDqIk8jeY0AWQbsFJAX2wZToqsS0CwLcJ764a+zHs/YE PUFN2kbh+euv4gxMmopQ+mKCYKjoiiShj3cskPdclH6KWbevbLGu+MPbRn9Tk7tXPEH4 fK/m3foOo8Z+rzvFIl3qUe9IokcIM4SkTos+TTWa8WzVHoSDU7hAAZ0LMutOzup+l0WW XF1jJjqr5N0coygTDnDvej4uvTehwrpTyXvsl+R4nB9JiYqX4xKMU2tLWpjFt43AfpjE Wjdlcg6hpAFoBj0CvfNF1HmjsUgGTRBJKd9e2I+RG0Z1oYA0SaGE9KSppW/4Wn2jpvxc NsLw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: best guess record for domain of asmirnov@ilbers.de designates 85.214.62.211 as permitted sender) smtp.mailfrom=asmirnov@ilbers.de Return-Path: Received: from aqmola.ilbers.de (aqmola.ilbers.de. [85.214.62.211]) by gmr-mx.google.com with ESMTPS id 192si316939wmy.2.2017.08.27.08.14.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 27 Aug 2017 08:14:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of asmirnov@ilbers.de designates 85.214.62.211 as permitted sender) client-ip=85.214.62.211; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: best guess record for domain of asmirnov@ilbers.de designates 85.214.62.211 as permitted sender) smtp.mailfrom=asmirnov@ilbers.de Received: from localhost.localdomain ([188.227.110.165]) (authenticated bits=0) by aqmola.ilbers.de (8.14.4/8.14.4/Debian-4+deb7u1) with ESMTP id v7RFDkeh006455 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 27 Aug 2017 17:13:54 +0200 From: Alexander Smirnov To: isar-users@googlegroups.com Cc: Alexander Smirnov Subject: [PATCH 3/6] classes/dpkg: Split install for cache Date: Sun, 27 Aug 2017 18:13:36 +0300 Message-Id: <20170827151339.12806-4-asmirnov@ilbers.de> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170827151339.12806-1-asmirnov@ilbers.de> References: <20170827151339.12806-1-asmirnov@ilbers.de> X-TUID: JEcE2pIa20Cg Split install function into two parts: - install_to_cache: if caching is enabled - install_to_deploy: if caching is disabled This patch brings flexibility to the implementation and makes it possible to move all the caching implementation code to dedicated class. The magic behavior depending on the value of DEBCACHE_ENABLED is now transparent in the bitbake pipeline (can be inspected via "bitbake -g"). Signed-off-by: Alexander Smirnov --- meta/classes/dpkg.bbclass | 66 ++++++++++++++++++++++++++-------------------- meta/classes/image.bbclass | 2 +- 2 files changed, 38 insertions(+), 30 deletions(-) diff --git a/meta/classes/dpkg.bbclass b/meta/classes/dpkg.bbclass index b1e201d..118ba2f 100644 --- a/meta/classes/dpkg.bbclass +++ b/meta/classes/dpkg.bbclass @@ -56,46 +56,53 @@ do_build() { } # Install package to dedicated deploy directory -do_binary_deb_install() { +do_install_to_deploy() { + # Deb caching is disabled, simply copy all binary packages to the deploy + # directory + install -m 644 "${BUILDROOT}"/*.deb "${DEPLOY_DIR_DEB}/" +} + +addtask install_to_deploy after do_build +do_install_to_deploy[dirs] = "${DEPLOY_DIR_DEB}" +do_install_to_deploy[stamp-extra-info] = "${DISTRO}-${DISTRO_ARCH}" +do_install_to_deploy[noexec] = "1" + +# Install package to dedicated apt repo +do_install_to_cache() { readonly DIR_CACHE="${DEBCACHEDIR}/${DISTRO}" readonly DIR_DB="${DEBDBDIR}/${DISTRO}" - if [ "${DEBCACHE_ENABLED}" != "0" ]; then - # If `bitbake` is running for the first time, the cache doesn't exist - # yet and needs to be configured using a `distributions` file. - # A template stored in the layer directory is pre-processed to - # generate the configuration file, which is then placed in the - # appropriate directory. - if [ ! -e "${DIR_CACHE}/conf/distributions" ]; then - mkdir -p "${DIR_CACHE}/conf" - sed -e "s#{DISTRO_NAME}#${DEBDISTRONAME}#g" \ - "${DEBFILESDIR}/distributions.in" \ - > "${DIR_CACHE}/conf/distributions" - fi - - # Add binary and source packages to the deb cache - # If the cache doesn't exist yet, it will be created using the - # `distributions` file generated above. - ls -1 "${BUILDROOT}"/*.deb "${BUILDROOT}"/*.dsc | while read -r p; do - reprepro --waitforlock 3 -b "${DIR_CACHE}" --dbdir "${DIR_DB}" \ - -C main "include${p##*.}" "${DEBDISTRONAME}" "${p}" - done - else - # Deb caching is disabled, simply copy all binary packages to the - # deploy directory - mkdir -p "${DEPLOY_DIR_DEB}" - install -m 644 "${BUILDROOT}"/*.deb "${DEPLOY_DIR_DEB}/" + # If `bitbake` is running for the first time, the cache doesn't exist + # yet and needs to be configured using a `distributions` file. + # A template stored in the layer directory is pre-processed to + # generate the configuration file, which is then placed in the + # appropriate directory. + if [ ! -e "${DIR_CACHE}/conf/distributions" ]; then + mkdir -p "${DIR_CACHE}/conf" + sed -e "s#{DISTRO_NAME}#${DEBDISTRONAME}#g" \ + "${DEBFILESDIR}/distributions.in" \ + > "${DIR_CACHE}/conf/distributions" fi + + # Add binary and source packages to the deb cache + # If the cache doesn't exist yet, it will be created using the + # `distributions` file generated above. + ls -1 "${BUILDROOT}"/*.deb "${BUILDROOT}"/*.dsc | while read -r p; do + reprepro --waitforlock 3 -b "${DIR_CACHE}" --dbdir "${DIR_DB}" \ + -C main "include${p##*.}" "${DEBDISTRONAME}" "${p}" + done } -addtask binary_deb_install after do_build -do_binary_deb_install[stamp-extra-info] = "${DISTRO}-${DISTRO_ARCH}" +addtask install_to_cache after do_build +do_install_to_cache[stamp-extra-info] = "${DISTRO}-${DISTRO_ARCH}" +do_install_to_cache[noexec] = "1" # Deb caching lambda run during the parsing phase that checks whether the # current package has to be rebuilt, or taken from the cache python __anonymous () { if d.getVar("DEBCACHE_ENABLED", True) == "0": - # Deb caching is disabled, do nothing + # Deb caching is disabled + d.delVarFlag('do_install_to_deploy', 'noexec') return True PN = d.getVar("PN", True) @@ -108,6 +115,7 @@ python __anonymous () { path_cache = os.path.join(DEBCACHEDIR, DISTRO) path_databases = os.path.join(DEBDBDIR, DISTRO) path_distributions = os.path.join(path_cache, "conf", "distributions") + d.delVarFlag('do_install_to_cache', 'noexec') # The distributions file is needed by `reprepro` to know what types # of packages are supported, what the distribution name is, etc. diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass index c2ff453..6b1b5eb 100644 --- a/meta/classes/image.bbclass +++ b/meta/classes/image.bbclass @@ -46,4 +46,4 @@ do_populate() { } addtask populate before do_build -do_populate[deptask] = "do_install" +do_populate[deptask] = "do_install_to_cache do_install_to_deploy" -- 2.1.4