public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Claudius Heine <claudius.heine.ext@siemens.com>
To: Alexander Smirnov <asmirnov@ilbers.de>, isar-users@googlegroups.com
Subject: Re: [PATCH 3/6] classes/dpkg: Split install for cache
Date: Wed, 30 Aug 2017 10:54:48 +0200	[thread overview]
Message-ID: <60d3f1ca-67a1-9c43-07f6-d2d89e4c2e51@siemens.com> (raw)
In-Reply-To: <d5752b02-4ce1-87de-c065-4be0325b809d@ilbers.de>

Hi,

On 08/29/2017 09:18 AM, Alexander Smirnov wrote:
> 
> 
> On 08/28/2017 11:00 AM, Claudius Heine wrote:
>> Hi,
>>
>> On 08/27/2017 05:13 PM, Alexander Smirnov wrote:
>>> 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 <asmirnov@ilbers.de>
>>> ---
>>>   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
>>
>> What was the reason why we put stuff after the 'build' task? In OE the 
>> 'build' task is the default task triggering everything necessary for a 
>> recipe. In Isar that changed. Why?
> 
> Actually AFAIK do_build is not OE tasks, it's default bitbake task. 
> Install is after do_build, because in Isar do_build is used to build the 
> packages, so it's not empty.

You are right, its a bitbake task. Since I have much more experience 
with OE than with just bitbake or isar, I referenced my question to the 
experience I had using OE. I cannot remember seeing tasks that are added 
after the do_build task in OE and I still find that very strange. AFAIK 
the 'build' task in bitbake and OE has a similar meaning to the 'all' 
target in make files. The idea to add statements to the 'all' target or 
letting other targets depend on the 'all' target sounds very odd to me. 
And that is what is done here in isar. Just very strange and unusual for 
my eyes and I don't see the advantage of this.

I would like to hear the reason for this decision. Why have you added 
statements to the 'build' task and why are other tasks depend on it?

>>
>>> +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"
>>
>> I would rather still have a, maybe empty, 'do_install' step that just 
>> depends on the 'do_install_to_cache' and 'do_install_to_deploy' tasks. 
>> I don't see why ever small change in one class should change the 
>> complete pipeline for every recipe.
> 
> It's a bit difficult question. In general meaning when building 
> something from sources, the install means a storing of build artifacts 
> to some specific location. So in this case, we  just copy binary deb 
> package to repo, and there is nothing common with installation of 
> artifacts.
> 
> Also Isar has in roadmap cross-compilation, so the pipeline will 
> probably look like:
> 
> fetch - unpack - compile - install - install_to_cache
> 
> so in this case the install task probably should go before 
> install_to_cache.
> 
> So probably it makes sense to avoid _install_ in this task, for example 
> use do_populate_deb_cache, what do you think?

Something like: 'populate_repo' sounds much better for this case. I 
would try to have more abstract names at first and implement them with 
more specific names like 'populate_repo_deb'. In OE there already is a 
'package' and additional sub tasks like 'package_write_deb'.

So a general pipeline for normal recipes like this:

fetch, unpack, configure, compile, install, package, populate_repo

Of course image recipes would have a slightly changed pipeline.

I think the discussion about the build pipeline in isar is very 
important. Maybe we should make an extra thread about this.

Cheers,
Claudius

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-54 Fax: (+49)-8142-66989-80 Email: ch@denx.de

  reply	other threads:[~2017-08-30  8:54 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-27 15:13 [PATCH 0/6] Isar apt cache implementation Alexander Smirnov
2017-08-27 15:13 ` [PATCH 1/6] meta-isar-bin: Enable caching of deb packages Alexander Smirnov
2017-08-28 15:18   ` Henning Schild
2017-08-29  6:40     ` Alexander Smirnov
2017-08-29  7:51       ` Henning Schild
2017-08-29  8:20         ` Alexander Smirnov
2017-08-31 10:55     ` Claudius Heine
2017-08-31 11:20       ` Henning Schild
2017-08-31 12:08         ` Claudius Heine
2017-09-06 14:21   ` Henning Schild
2017-09-07 11:13     ` Claudius Heine
2017-08-27 15:13 ` [PATCH 2/6] classes/image: Provide /dev/null for Stretch apt Alexander Smirnov
2017-08-28 15:20   ` Henning Schild
2017-08-28 15:26     ` Henning Schild
2017-08-27 15:13 ` [PATCH 3/6] classes/dpkg: Split install for cache Alexander Smirnov
2017-08-28  8:00   ` Claudius Heine
2017-08-29  7:18     ` Alexander Smirnov
2017-08-30  8:54       ` Claudius Heine [this message]
2017-08-28 15:30   ` Henning Schild
2017-08-27 15:13 ` [PATCH 4/6] meta-isar-bin: Enable apt repo generation for amd64 Alexander Smirnov
2017-08-27 15:13 ` [PATCH 5/6] classes/dpkg: Properly update packages in the cache Alexander Smirnov
2017-08-28 15:32   ` Henning Schild
2017-08-29  7:20     ` Alexander Smirnov
2017-08-29  7:57       ` Henning Schild
2017-08-29 11:26         ` Jan Kiszka
2017-08-27 15:13 ` [PATCH 6/6] doc/technical_overview: Describe binary cache Alexander Smirnov
2017-08-28 15:36   ` Henning Schild
2017-08-29  7:29     ` Alexander Smirnov
2017-08-29  8:06       ` Henning Schild
2017-08-29 11:29     ` Jan Kiszka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=60d3f1ca-67a1-9c43-07f6-d2d89e4c2e51@siemens.com \
    --to=claudius.heine.ext@siemens.com \
    --cc=asmirnov@ilbers.de \
    --cc=isar-users@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox