Skip to contentSkip to conversation

Where should I append Yocto bitbake task to create work folder symlink ?

DISCUSSION Woronicz, Bartosz ( NSN - PL/Wroclaw) 3 participants 14 messages Feb 3, 2016 – Feb 10, 2016

lore
Share & tools
lore
#0 lore raw

Let's say I have my package at

    host-64/tmp/work/x86_64-poky-linux/mypackage/1.2.3-r4/

I would like to have symlink created

    host-64/tmp/work/x86_64-poky-linux/mypackage/latest -> 1.2.3-r4/

each time the new version is fetched and unpacked. How can I achieve that ? Which class, task should I append, extend ?

Optionally, I would like to have that for all packages or at least packages in my meta.

P.S. I asked the same question here: http://stackoverflow.com/questions/35158764/where-should-i-append-yocto-bitbake-task-to-create-work-folder-symlink

Signature · 4 lines
Kind regards,
Bartosz Woronicz
Engineer, Software Configuration (SCM)
NSN - PL/Wroclaw
#1 lore raw
Quoted 11 lines · Bartosz ( NSN - PL/Wroclaw)

Let's say I have my package at

    host-64/tmp/work/x86_64-poky-linux/mypackage/1.2.3-r4/

I would like to have symlink created

    host-64/tmp/work/x86_64-poky-linux/mypackage/latest -> 1.2.3-r4/

each time the new version is fetched and unpacked. How can I achieve that ? Which class, task should I append, extend ?

One way would be to create a new task that comes after unpack and creates the symlink.

You may be interested in the rm_old_work class that can remove old work trees so there's only ever one work tree, and I believe due to how master does sysroot cleanup there's only ever one version in work/ now.

Ross

#5 lore raw
In reply to Woronicz, Bartosz ( NSN - PL/Wroclaw)
Quoted 11 lines · Bartosz ( NSN - PL/Wroclaw)

Let's say I have my package at

     host-64/tmp/work/x86_64-poky-linux/mypackage/1.2.3-r4/

I would like to have symlink created

     host-64/tmp/work/x86_64-poky-linux/mypackage/latest -> 1.2.3-r4/

each time the new version is fetched and unpacked. How can I achieve that ? Which class, task should I append, extend ?

Quoted 8 lines

Optionally, I would like to have that for all packages or at least packages in my meta.

P.S. I asked the same question here:
http://stackoverflow.com/questions/35158764/where-should-i-append-yocto-bitbake-task-to-
create-work-folder-symlink

Put that into a class in your layer, ex. latest-link.bbclass (untested):

do_latest_link() {
	if [ -n "${WORKDIR}" ]; then
		linkname="$(dirname ${WORKDIR})/latest"
		rm -f $linkname
		ln -s ${WORKDIR} $linkname
	fi
}

addtask latest_link after do_unpack

If you want that applied to all the recipes then add INHERIT += "latest-link" in your local.conf. The other way is just to 'inherit latest-link' in individual recipes.

Signature · 19 lines
Maciej Borzęcki
Senior Software Developer at Open-RnD Sp. z o.o., Poland
www.open-rnd.pl
mobile: +48 889 117 365, fax: +48 42 657 9079

Niniejsza wiadomość wraz z załącznikami może zawierać chronione prawem
lub poufne informacje i została wysłana wyłącznie do wiadomości i
użytku osób, do których została zaadresowana. Jeśli wiadomość została
otrzymana przypadkowo zabrania się jej kopiowania lub rozsyłania do
osób trzecich. W takim przypadku uprasza się o natychmiastowe
zniszczenie wiadomości oraz poinformowanie nadawcy o zaistniałej
sytuacji za pomocą wiadomości zwrotnej. Dziękujemy.

This message, including any attachments hereto, may contain privileged
or confidential information and is sent solely for the attention and
use of the intended addressee(s). If you are not an intended addressee,
you may neither use this message nor copy or deliver it to anyone. In
such case, you should immediately destroy this message and kindly notify
the sender by reply email. Thank you.
#2 lore raw
In reply to Burton, Ross
Quoted 15 lines · Ross

On 3 February 2016 at 10:13, Woronicz, Bartosz ( NSN - PL/Wroclaw) <[email protected] <mailto:[email protected]>> wrote:

Let's say I have my package at

host-64/tmp/work/x86_64-poky-linux/mypackage/1.2.3-r4/

I would like to have symlink created

host-64/tmp/work/x86_64-poky-linux/mypackage/latest -> 1.2.3-r4/

each time the new version is fetched and unpacked. How can I achieve that ? Which class, task should I append, extend ?

Quoted 5 lines

One way would be to create a new task that comes after unpack and creates the symlink.

You may be interested in the rm_old_work class that can remove old work trees so there's only ever one work tree, and I believe due to how master does sysroot cleanup there's only ever one version in work/ now.

Ross

But I need to the sysroot cleanup deliberately, right ?

----

Kind regards,
Bartosz Woronicz
Engineer, Software Configuration (SCM)
NSN - PL/Wroclaw

#3 lore raw
Quoted 2 lines · Bartosz ( NSN - PL/Wroclaw)

But I need to the sysroot cleanup deliberately, right ?

No, that happens on startup (in master and the jethro release).

Ross

#4 lore raw

I will check that out, thanks!

Kind regards,
Bartosz Woronicz
Engineer, Software Configuration (SCM)
NSN - PL/Wroclaw

Quoted 9 lines · Ross

On 3 February 2016 at 14:16, Woronicz, Bartosz ( NSN - PL/Wroclaw) <[email protected] <mailto:[email protected]>> wrote:

But I need to the sysroot cleanup deliberately, right ?

No, that happens on startup (in master and the jethro release).

Ross

#6 lore raw
In reply to Maciek Borzecki

Whoa,

That's great! However I modified it, so the link will be relative

The problem is that it works until you have sstate cache empty, because after that it doesn't fetch and unpack when already have it in

do_latest_link() {
	if [ -n "${WORKDIR}" ]; then
		linkname="$(basename $(dirname ${WORKDIR}))/latest"
		rm -f $linkname
		ln -s ${WORKDIR} $linkname
	fi
}

addtask latest_link after do_unpack

Kind regards,
Bartosz Woronicz
Engineer, Software Configuration (SCM)
NSN - PL/Wroclaw

Quoted 36 lines · EXT Maciek Borzecki
Quoted 11 lines · Bartosz ( NSN - PL/Wroclaw)

Let's say I have my package at

      host-64/tmp/work/x86_64-poky-linux/mypackage/1.2.3-r4/

I would like to have symlink created

      host-64/tmp/work/x86_64-poky-linux/mypackage/latest -> 1.2.3-r4/

each time the new version is fetched and unpacked. How can I achieve that ? Which class, task should I append, extend ?

Quoted 8 lines

Optionally, I would like to have that for all packages or at least packages in my meta.

P.S. I asked the same question here:
http://stackoverflow.com/questions/35158764/where-should-i-append-yocto-bitbake-task-to-
create-work-folder-symlink

Put that into a class in your layer, ex. latest-link.bbclass (untested):

do_latest_link() {
	if [ -n "${WORKDIR}" ]; then
		linkname="$(dirname ${WORKDIR})/latest"
		rm -f $linkname
		ln -s ${WORKDIR} $linkname
	fi
}

addtask latest_link after do_unpack

If you want that applied to all the recipes then add INHERIT += "latest-link" in your local.conf. The other way is just to 'inherit latest-link' in individual recipes.

#7 lore raw

The problem is, it doesn't doit delirebately,

when I run

bitbake -f -c latest_link myrecipe , it works

when the process is in the tasks batch running
bitbake myrecipe
it doesn't
What am I doing wrong ?

Kind regards,
Bartosz Woronicz
Engineer, Software Configuration (SCM)
NSN - PL/Wroclaw

Quoted 60 lines · Bartosz ( NSN - PL/Wroclaw)

Whoa,

That's great! However I modified it, so the link will be relative

The problem is that it works until you have sstate cache empty, because after that it doesn't fetch and unpack when already have it in

do_latest_link() {
    if [ -n "${WORKDIR}" ]; then
        linkname="$(basename $(dirname ${WORKDIR}))/latest"
        rm -f $linkname
        ln -s ${WORKDIR} $linkname
    fi
}

addtask latest_link after do_unpack

Kind regards,
Bartosz Woronicz
Engineer, Software Configuration (SCM)
NSN - PL/Wroclaw

Quoted 37 lines · EXT Maciek Borzecki
Quoted 11 lines · Bartosz ( NSN - PL/Wroclaw)

Let's say I have my package at

      host-64/tmp/work/x86_64-poky-linux/mypackage/1.2.3-r4/

I would like to have symlink created

      host-64/tmp/work/x86_64-poky-linux/mypackage/latest -> 1.2.3-r4/

each time the new version is fetched and unpacked. How can I achieve that ? Which class, task should I append, extend ?

Quoted 9 lines

Optionally, I would like to have that for all packages or at least packages in my meta.

P.S. I asked the same question here:
http://stackoverflow.com/questions/35158764/where-should-i-append-yocto-bitbake-task-to-

create-work-folder-symlink

Put that into a class in your layer, ex. latest-link.bbclass (untested):

do_latest_link() {
    if [ -n "${WORKDIR}" ]; then
        linkname="$(dirname ${WORKDIR})/latest"
        rm -f $linkname
        ln -s ${WORKDIR} $linkname
    fi
}

addtask latest_link after do_unpack

If you want that applied to all the recipes then add INHERIT += "latest-link" in your local.conf. The other way is just to 'inherit latest-link' in individual recipes.

#8 lore raw
Quoted 10 lines · Bartosz ( NSN - PL/Wroclaw)

The problem is, it doesn't doit delirebately,

when I run

bitbake -f -c latest_link myrecipe , it works

when the process is in the tasks batch running
bitbake myrecipe
it doesn't
What am I doing wrong ?

Try adding:

do_latest_link[nostamp] = "1"

This should cause the task to be run each time.

Signature · 19 lines
Maciej Borzęcki
Senior Software Developer at Open-RnD Sp. z o.o., Poland
www.open-rnd.pl
mobile: +48 889 117 365, fax: +48 42 657 9079

Niniejsza wiadomość wraz z załącznikami może zawierać chronione prawem
lub poufne informacje i została wysłana wyłącznie do wiadomości i
użytku osób, do których została zaadresowana. Jeśli wiadomość została
otrzymana przypadkowo zabrania się jej kopiowania lub rozsyłania do
osób trzecich. W takim przypadku uprasza się o natychmiastowe
zniszczenie wiadomości oraz poinformowanie nadawcy o zaistniałej
sytuacji za pomocą wiadomości zwrotnej. Dziękujemy.

This message, including any attachments hereto, may contain privileged
or confidential information and is sent solely for the attention and
use of the intended addressee(s). If you are not an intended addressee,
you may neither use this message nor copy or deliver it to anyone. In
such case, you should immediately destroy this message and kindly notify
the sender by reply email. Thank you.
#9 lore raw
Quoted 11 lines · EXT Maciek Borzecki
Quoted 10 lines · Bartosz ( NSN - PL/Wroclaw)

The problem is, it doesn't doit delirebately,

when I run

bitbake -f -c latest_link myrecipe , it works

when the process is in the tasks batch running
bitbake myrecipe
it doesn't
What am I doing wrong ?

Quoted 6 lines

Try adding:

do_latest_link[nostamp] = "1"

This should cause the task to be run each time.

Ok, but I don't want to run it everytime, just after the do_unpack. What I need to put it in requirements for each recipe ? Maybe something like

do_unpack[require] = "latest_link"

but I cannot find such thing

Kind regards,
Bartosz Woronicz
Engineer, Software Configuration (SCM)
NSN - PL/Wroclaw

#10 lore raw
Quoted 6 lines · Bartosz ( NSN - PL/Wroclaw)

Ok, but I don't want to run it everytime, just after the do_unpack. What I need to put it in requirements for each recipe ?
Maybe something like

do_unpack[require] = "latest_link"

do_unpack[postfuncs] += "latest_link" will run latest_link after unpack has executed.

Ross

#11 lore raw

Cheers, mate!

That solves my issue (but with small fix).
/do_unpack[postfuncs] += "do_latest_link"
/instead/
//do_unpack[postfuncs] += "latest_link"

Because, without "do_" it says
WARNING: Function latest_link doesn't exist

/Here is the whole bbclass/:
/

DESCRIPTION = "Creates symlink to the latest version workdir of the package"

   do_latest_link() {
        if [ -n "${WORKDIR}" ]; then
            linkname="$(dirname ${WORKDIR})/latest"
            rm -f $linkname
            ln -s $(basename ${WORKDIR}) $linkname
        fi
   }
   addtask latest_link after do_unpack

do_unpack[postfuncs] += "do_latest_link"

But for better understanding I made the more throughout look into the documentations. I found the information about "postfuncs" you talk about [1]. However, the tasks description [2] doesn't say anything about including the task in the process, it just describes the demanded order that the task is put ( addtask something after|before othertask ).

That is so, until I read "3.6. Variable Flags" [3]. Where is quite clearly stated those variables control functionality and *dependencies*. The documentation is quite unclear in that case.

[1] http://www.yoctoproject.org/docs/current/bitbake-user-manual/bitbake-user-manual.html#executing-tasks
[2] http://www.yoctoproject.org/docs/current/bitbake-user-manual/bitbake-user-manual.html#tasks
[3] http://www.yoctoproject.org/docs/current/bitbake-user-manual/bitbake-user-manual.html#variable-flags

Kind regards,
Bartosz Woronicz
Engineer, Software Configuration (SCM)
NSN - PL/Wroclaw

Quoted 13 lines · Ross

On 9 February 2016 at 08:37, Woronicz, Bartosz ( NSN - PL/Wroclaw) <[email protected] <mailto:[email protected]>> wrote:

Ok, but I don't want to run it everytime, just after the do_unpack. What I need to put it in requirements for each recipe ? Maybe something like

do_unpack[require] = "latest_link"

do_unpack[postfuncs] += "latest_link" will run latest_link after unpack has executed.

Ross

#12 lore raw
Quoted 24 lines · Bartosz ( NSN - PL/Wroclaw)

Here is the whole bbclass
*: *

DESCRIPTION = "Creates symlink to the latest version workdir of the package"

do_latest_link() {
    if [ -n "${WORKDIR}" ]; then
        linkname="$(dirname ${WORKDIR})/latest"
        rm -f $linkname
        ln -s $(basename ${WORKDIR}) $linkname
    fi
}

addtask latest_link after do_unpack

do_unpack[postfuncs] += "do_latest_link"

But for better understanding I made the more throughout look into the documentations. I found the information about "postfuncs" you talk about [1]. However, the tasks description [2] doesn't say anything about including the task in the process, it just describes the demanded order that the task is put ( addtask something after|before othertask ).

Quoted 4 lines

That is so, until I read "3.6. Variable Flags" [3]. Where is quite clearly stated those variables control functionality and *dependencies*. The documentation is quite unclear in that case.

If you're using a postfunc you don't need to addtask at all: using postfuncs means you don't need to have a separate task at all.

Ross

#13 lore raw
Quoted 34 lines · Ross

On 9 February 2016 at 13:51, Woronicz, Bartosz ( NSN - PL/Wroclaw) <[email protected] <mailto:[email protected]>> wrote:

Here is the whole bbclass/:
/

DESCRIPTION = "Creates symlink to the latest version workdir of the package"

do_latest_link() {
if [ -n "${WORKDIR}" ]; then
linkname="$(dirname ${WORKDIR})/latest" rm -f $linkname
ln -s $(basename ${WORKDIR}) $linkname
fi
}
addtask latest_link after do_unpack

do_unpack[postfuncs] += "do_latest_link"

But for better understanding I made the more throughout look into the documentations. I found the information about "postfuncs" you talk about [1]. However, the tasks description [2] doesn't say anything about including the task in the process, it just describes the demanded order that the task is put ( addtask something after|before othertask ).

That is so, until I read "3.6. Variable Flags" [3]. Where is quite clearly stated those variables control functionality and *dependencies*.
The documentation is quite unclear in that case.

Quoted 3 lines

If you're using a postfunc you don't need to addtask at all: using postfuncs means you don't need to have a separate task at all.

Ross

Ok, I understand now that 'addtask' is only necessary when I need seperate task to run. I think you solved my issue. Thanks again!

Kind regards,
Bartosz Woronicz
Engineer, Software Configuration (SCM)
NSN - PL/Wroclaw