* [Buildroot] BR variable that points the built kernel
@ 2015-06-09 11:41 Marco Pastorelli
2015-06-09 12:03 ` Thomas Petazzoni
0 siblings, 1 reply; 9+ messages in thread
From: Marco Pastorelli @ 2015-06-09 11:41 UTC (permalink / raw)
To: buildroot
Hello everybody,
I'm writing a post build script and I'm looking for a variable that points
to the directory where the kernel has been built.
So far I have used ${BUILD_DIR}/linux-custom/ but this is not portable
since it depends on the kernel version.
Does anyone know a better way to address my problem?
Additional info:
I'm using buildroot-2014.08
Thank you!
Regards,
Marco.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20150609/13e0c6ef/attachment.html>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Buildroot] BR variable that points the built kernel
2015-06-09 11:41 [Buildroot] BR variable that points the built kernel Marco Pastorelli
@ 2015-06-09 12:03 ` Thomas Petazzoni
2015-06-09 13:58 ` Marco Pastorelli
0 siblings, 1 reply; 9+ messages in thread
From: Thomas Petazzoni @ 2015-06-09 12:03 UTC (permalink / raw)
To: buildroot
Dear Marco Pastorelli,
On Tue, 9 Jun 2015 13:41:41 +0200, Marco Pastorelli wrote:
> I'm writing a post build script and I'm looking for a variable that points
> to the directory where the kernel has been built.
>
> So far I have used ${BUILD_DIR}/linux-custom/ but this is not portable
> since it depends on the kernel version.
>
> Does anyone know a better way to address my problem?
Use $(LINUX_DIR).
Best regards,
Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Buildroot] BR variable that points the built kernel
2015-06-09 12:03 ` Thomas Petazzoni
@ 2015-06-09 13:58 ` Marco Pastorelli
2015-06-09 14:03 ` Thomas Petazzoni
0 siblings, 1 reply; 9+ messages in thread
From: Marco Pastorelli @ 2015-06-09 13:58 UTC (permalink / raw)
To: buildroot
Thanks Thomas,
I've used $(LINUX_DIR) in the past but now I'm running into the following
error:
line 8: LINUX_DIR: command not found
I'm using buildroot-2014.08, should it works also on that version?
Thank you!
Marco.
On 9 June 2015 at 14:03, Thomas Petazzoni <
thomas.petazzoni@free-electrons.com> wrote:
> Dear Marco Pastorelli,
>
> On Tue, 9 Jun 2015 13:41:41 +0200, Marco Pastorelli wrote:
>
> > I'm writing a post build script and I'm looking for a variable that
> points
> > to the directory where the kernel has been built.
> >
> > So far I have used ${BUILD_DIR}/linux-custom/ but this is not portable
> > since it depends on the kernel version.
> >
> > Does anyone know a better way to address my problem?
>
> Use $(LINUX_DIR).
>
> Best regards,
>
> Thomas
> --
> Thomas Petazzoni, CTO, Free Electrons
> Embedded Linux, Kernel and Android engineering
> http://free-electrons.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20150609/fdcd8408/attachment.html>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Buildroot] BR variable that points the built kernel
2015-06-09 13:58 ` Marco Pastorelli
@ 2015-06-09 14:03 ` Thomas Petazzoni
2015-06-10 8:29 ` Marco Pastorelli
0 siblings, 1 reply; 9+ messages in thread
From: Thomas Petazzoni @ 2015-06-09 14:03 UTC (permalink / raw)
To: buildroot
Dear Marco Pastorelli,
On Tue, 9 Jun 2015 15:58:42 +0200, Marco Pastorelli wrote:
> I've used $(LINUX_DIR) in the past but now I'm running into the following
> error:
>
> line 8: LINUX_DIR: command not found
You're using it in the wrong place then. Hard to be more specific
without seeing exactly the code you're using.
If $(LINUX_DIR) tells you command not found, it means it's interpreted
as a shell command, not as a make variable expansion.
> I'm using buildroot-2014.08, should it works also on that version?
Yes, it should.
Best regards,
Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Buildroot] BR variable that points the built kernel
2015-06-09 14:03 ` Thomas Petazzoni
@ 2015-06-10 8:29 ` Marco Pastorelli
2015-06-10 8:36 ` Thomas Petazzoni
0 siblings, 1 reply; 9+ messages in thread
From: Marco Pastorelli @ 2015-06-10 8:29 UTC (permalink / raw)
To: buildroot
Dear Thomas,
You're right, is there a way to use make variables inside the post-build
script? Or this is a wrong approach?
Thanks,
Marco.
On 9 June 2015 at 16:03, Thomas Petazzoni <
thomas.petazzoni@free-electrons.com> wrote:
> Dear Marco Pastorelli,
>
> On Tue, 9 Jun 2015 15:58:42 +0200, Marco Pastorelli wrote:
>
> > I've used $(LINUX_DIR) in the past but now I'm running into the following
> > error:
> >
> > line 8: LINUX_DIR: command not found
>
> You're using it in the wrong place then. Hard to be more specific
> without seeing exactly the code you're using.
>
> If $(LINUX_DIR) tells you command not found, it means it's interpreted
> as a shell command, not as a make variable expansion.
>
> > I'm using buildroot-2014.08, should it works also on that version?
>
> Yes, it should.
>
> Best regards,
>
> Thomas
> --
> Thomas Petazzoni, CTO, Free Electrons
> Embedded Linux, Kernel and Android engineering
> http://free-electrons.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20150610/9f7c810c/attachment.html>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Buildroot] BR variable that points the built kernel
2015-06-10 8:29 ` Marco Pastorelli
@ 2015-06-10 8:36 ` Thomas Petazzoni
2015-06-10 10:06 ` Marco Pastorelli
0 siblings, 1 reply; 9+ messages in thread
From: Thomas Petazzoni @ 2015-06-10 8:36 UTC (permalink / raw)
To: buildroot
Dear Marco Pastorelli,
On Wed, 10 Jun 2015 10:29:16 +0200, Marco Pastorelli wrote:
> You're right, is there a way to use make variables inside the post-build
> script? Or this is a wrong approach?
Some of the make variables are passed in the environment of post build
script, but clearly not all of them. Especially the <pkg>_DIR variable
for each packages is not passed.
You're probably trying to do something that should be done in a
different way. You should have a package installing whatever you need
from $(LINUX_DIR) to $(TARGET_DIR) rather than doing it from a
post-build script.
However, your provide so little details about what you're trying to do
that it's quite impossible to give a good advice.
Best regards,
Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Buildroot] BR variable that points the built kernel
2015-06-10 8:36 ` Thomas Petazzoni
@ 2015-06-10 10:06 ` Marco Pastorelli
2015-06-10 17:15 ` Yann E. MORIN
0 siblings, 1 reply; 9+ messages in thread
From: Marco Pastorelli @ 2015-06-10 10:06 UTC (permalink / raw)
To: buildroot
Dear Thomas,
Thanks for your help, now it's more clear.
Just to give more details I'm trying to write a post-build script in order
to create a log file of the build. One information that is important for me
is the kernel version, so I wrote the following line:
LINUX_VERSION=$(cat $(LINUX_DIR)/include/config/kernel.release)
That's where I run into the error.
So far the only way I've found is to add a makefile based package, but I
guess using a post build script could be a better solution...
Regards,
Marco.
On 10 June 2015 at 10:36, Thomas Petazzoni <
thomas.petazzoni@free-electrons.com> wrote:
> Dear Marco Pastorelli,
>
> On Wed, 10 Jun 2015 10:29:16 +0200, Marco Pastorelli wrote:
>
> > You're right, is there a way to use make variables inside the post-build
> > script? Or this is a wrong approach?
>
> Some of the make variables are passed in the environment of post build
> script, but clearly not all of them. Especially the <pkg>_DIR variable
> for each packages is not passed.
>
> You're probably trying to do something that should be done in a
> different way. You should have a package installing whatever you need
> from $(LINUX_DIR) to $(TARGET_DIR) rather than doing it from a
> post-build script.
>
> However, your provide so little details about what you're trying to do
> that it's quite impossible to give a good advice.
>
> Best regards,
>
> Thomas
> --
> Thomas Petazzoni, CTO, Free Electrons
> Embedded Linux, Kernel and Android engineering
> http://free-electrons.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20150610/43e3041f/attachment.html>
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Buildroot] BR variable that points the built kernel
2015-06-10 10:06 ` Marco Pastorelli
@ 2015-06-10 17:15 ` Yann E. MORIN
2015-06-12 6:28 ` Marco Pastorelli
0 siblings, 1 reply; 9+ messages in thread
From: Yann E. MORIN @ 2015-06-10 17:15 UTC (permalink / raw)
To: buildroot
Marco, All,
On 2015-06-10 12:06 +0200, Marco Pastorelli spake thusly:
> Thanks for your help, now it's more clear.
> Just to give more details I'm trying to write a post-build script in order
> to create a log file of the build. One information that is important for me
> is the kernel version, so I wrote the following line:
>
> LINUX_VERSION=$(cat $(LINUX_DIR)/include/config/kernel.release)
>
> That's where I run into the error.
That's because you're writting a shell script, not a Makefile. And in
shell script, $(foo) means running the command 'foo', not evaluating the
variable foo.
Besides, as Thomas said, not all variables are exported, and especially
the variables cotaining the packages build directories are not exported.
So, you can't refer to them from a post-build or post-image script.
However, there *is* a way to get them, which is asking Buildroot for
them. I have a similar need, and here's what I do:
linux_dir_as_shell_variable=$(
make printvars 2>/dev/null \
|sed -r -e '/^LINUX_DIR=([^[:space:]]+)[[:space:]]+.*/!d; s//\1/;'
)
printf "LINUX_DIR from Buildroot is '%s'\n" "${linux_dir_as_shell_variable}"
And since you are only interested in the Linux version, you can replace
LINUX_DIR with LINUX_VERSION (or even LINUX_VERSION_PROBED).
However, it takes quite some time to run, because it is evaluating *all*
variables for *all* enabled packages, so it works OK if all you need is
only a few variable. If you need more, then you'd need a more complex
solution (or pay the price of calling make for each variable you need).
Regards,
Yann E. MORIN.
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Buildroot] BR variable that points the built kernel
2015-06-10 17:15 ` Yann E. MORIN
@ 2015-06-12 6:28 ` Marco Pastorelli
0 siblings, 0 replies; 9+ messages in thread
From: Marco Pastorelli @ 2015-06-12 6:28 UTC (permalink / raw)
To: buildroot
Thomas, Yann
You gave me really good hints, thank you so much!
Best,
Marco.
On 10 June 2015 at 19:15, Yann E. MORIN <yann.morin.1998@free.fr> wrote:
> Marco, All,
>
> On 2015-06-10 12:06 +0200, Marco Pastorelli spake thusly:
> > Thanks for your help, now it's more clear.
> > Just to give more details I'm trying to write a post-build script in
> order
> > to create a log file of the build. One information that is important for
> me
> > is the kernel version, so I wrote the following line:
> >
> > LINUX_VERSION=$(cat $(LINUX_DIR)/include/config/kernel.release)
> >
> > That's where I run into the error.
>
> That's because you're writting a shell script, not a Makefile. And in
> shell script, $(foo) means running the command 'foo', not evaluating the
> variable foo.
>
> Besides, as Thomas said, not all variables are exported, and especially
> the variables cotaining the packages build directories are not exported.
> So, you can't refer to them from a post-build or post-image script.
>
> However, there *is* a way to get them, which is asking Buildroot for
> them. I have a similar need, and here's what I do:
>
> linux_dir_as_shell_variable=$(
> make printvars 2>/dev/null \
> |sed -r -e '/^LINUX_DIR=([^[:space:]]+)[[:space:]]+.*/!d; s//\1/;'
> )
>
> printf "LINUX_DIR from Buildroot is '%s'\n"
> "${linux_dir_as_shell_variable}"
>
> And since you are only interested in the Linux version, you can replace
> LINUX_DIR with LINUX_VERSION (or even LINUX_VERSION_PROBED).
>
> However, it takes quite some time to run, because it is evaluating *all*
> variables for *all* enabled packages, so it works OK if all you need is
> only a few variable. If you need more, then you'd need a more complex
> solution (or pay the price of calling make for each variable you need).
>
> Regards,
> Yann E. MORIN.
>
> --
>
> .-----------------.--------------------.------------------.--------------------.
> | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics'
> conspiracy: |
> | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___
> |
> | +33 223 225 172 `------------.-------: X AGAINST | \e/ There
> is no |
> | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v
> conspiracy. |
>
> '------------------------------^-------^------------------^--------------------'
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20150612/5bddfd60/attachment.html>
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2015-06-12 6:28 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-09 11:41 [Buildroot] BR variable that points the built kernel Marco Pastorelli
2015-06-09 12:03 ` Thomas Petazzoni
2015-06-09 13:58 ` Marco Pastorelli
2015-06-09 14:03 ` Thomas Petazzoni
2015-06-10 8:29 ` Marco Pastorelli
2015-06-10 8:36 ` Thomas Petazzoni
2015-06-10 10:06 ` Marco Pastorelli
2015-06-10 17:15 ` Yann E. MORIN
2015-06-12 6:28 ` Marco Pastorelli
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox