Skip to contentSkip to conversation

Finding out the IMAGE_BASENAME of the image beeing built

DISCUSSION Ulf Samuelsson 3 participants 6 messages Mar 30, 2013 – Apr 1, 2013

lore
Share & tools
lore
#0 lore raw

Trying create a programming script recipe and need to find out the IMAGE_BASENAME of the bitbake target so I can get the filename of the image

${MACHINE}-${IMAGE_BASENAME}.ubi

I.E: if I do

$ MACHINE=beagleboard  bitbake some-image

and "some-image_1.0.bb" contains

IMAGE_BASENAME = "renamed-image"

Then the resulting image will be

"beagleboard-renamed-image.ubi"

How get this info from another recipe?

BR
Ulf Samuelsson

#1 lore raw

Hi Ulf,

$ MACHINE=beagleboard  bitbake -e some-image

shows all variables including $IMAGE_BASENAME without actually building the image.
Using grep you can take the value of IMAGE_BASENAME, like as:

$ MACHINE=beagleboard  bitbake -e some-image | grep ^IMAGE_BASENAME

Does it help you?

If possible, consider to use hooks, for example, IMAGE_POSTPROCESS_COMMAND . Refer image.bbclass for details. It might make things straiter.

Regards,

Signature · 3 lines
Takeshi Hamasaki

2013/3/30 Ulf Samuelsson <[email protected]>:
Quoted 28 lines

Trying create a programming script recipe and need to find out the IMAGE_BASENAME of the bitbake target
so I can get the filename of the image

${MACHINE}-${IMAGE_BASENAME}.ubi

I.E: if I do

$ MACHINE=beagleboard  bitbake some-image

and "some-image_1.0.bb" contains

IMAGE_BASENAME = "renamed-image"

Then the resulting image will be

"beagleboard-renamed-image.ubi"

How get this info from another recipe?

BR
Ulf Samuelsson

_______________________________________________
Openembedded-devel mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-devel

#2 lore raw
Quoted 7 lines · Takeshi Hamasaki

Hi Ulf,

$ MACHINE=beagleboard  bitbake -e some-image

shows all variables including $IMAGE_BASENAME without actually building the image.
Using grep you can take the value of IMAGE_BASENAME, like as:

Thanks,

bitbake is already running to build my recipe.
Not sure that running "bitbake -e" is OK while bitbake is already running.

IMAGE_BASENAME is set to my recipe, so I cannot use this directly.

Quoted 8 lines
$ MACHINE=beagleboard  bitbake -e some-image | grep ^IMAGE_BASENAME

Does it help you?

If possible, consider to use hooks, for example, IMAGE_POSTPROCESS_COMMAND . Refer image.bbclass for details. It might make things straiter.

Regards,

I know I can do it inside the "some-image.bb" recipe, but I would like to do it inside my recipe. Otherwise all images must be customized for my recipe, which is not a good idea.

If I could do an IMAGE_POSTPROCESS_COMMAND in my recipe, then that would be OK, but I then still need to find out what the image name is.

BR
Ulf Samuelsson

#3 lore raw
In reply to Ulf Samuelsson
Quoted 12 lines · On Saturday 30 March 2013 13:32:51 Ulf Samuelsson wrote:

Trying create a programming script recipe and need to find out the IMAGE_BASENAME of the bitbake target
so I can get the filename of the image

${MACHINE}-${IMAGE_BASENAME}.ubi

I.E: if I do

$ MACHINE=beagleboard  bitbake some-image

and "some-image_1.0.bb" contains

Quoted 7 lines

IMAGE_BASENAME = "renamed-image"

Then the resulting image will be

"beagleboard-renamed-image.ubi"

How get this info from another recipe?

You can't. The way to handle this is as part of do_rootfs itself (e.g. from a script called from ROOTFS_POSTPROCESS_COMMAND or IMAGE_POSTPROCESS_COMMAND).

Cheers,
Paul

Signature · 2 lines
Paul Eggleton
Intel Open Source Technology Centre
#4 lore raw
Quoted 17 lines · Paul Eggleton
Quoted 16 lines · On Saturday 30 March 2013 13:32:51 Ulf Samuelsson wrote:

Trying create a programming script recipe and need to find out the IMAGE_BASENAME of the bitbake target
so I can get the filename of the image

${MACHINE}-${IMAGE_BASENAME}.ubi

I.E: if I do

$ MACHINE=beagleboard  bitbake some-image

and "some-image_1.0.bb" contains

IMAGE_BASENAME = "renamed-image"

Then the resulting image will be

Quoted 9 lines
Quoted 3 lines

"beagleboard-renamed-image.ubi"

How get this info from another recipe?

You can't. The way to handle this is as part of do_rootfs itself (e.g. from a script called from ROOTFS_POSTPROCESS_COMMAND or IMAGE_POSTPROCESS_COMMAND).

Cheers,
Paul

OK, thanks

I tried to define "configure-sam-ba.bbclass" which is inherited by my image.

configure-sam-ba.bbclass:
----------------------------------------------------------------------------------------------------------

SCRIPTFILE_TEMPLATE = "${DEPLOY_DIR_IMAGE}/scripts/${MACHINE}.tcl"
SCRIPTFILE = "${DEPLOY_DIR_IMAGE}/scripts/${IMAGE_LINK_NAME}-${MACHINE}.tcl"
PROGFILE_TEMPLATE = "${DEPLOY_DIR_IMAGE}/scripts/prog.sh"
PROGFILE = "${DEPLOY_DIR_IMAGE}/scripts/prog-${IMAGE_LINK_NAME}-${MACHINE}.sh"

sam-ba_setup () {

    if [ -e  ${PROGFILE_TEMPLATE} ] ; then
        sed    -i    s/#MACHINE#/${MACHINE}/ ${PROGFILE_TEMPLATE}
        sed    -i    s/#IMAGE#/${IMAGE_LINK_NAME}/ ${PROGFILE_TEMPLATE}
    fi
    cp    ${PROGFILE_TEMPLATE}    ${PROGFILE}

    if [ -e  ${SCRIPTFILE_TEMPLATE} ] ; then
        sed    -i    s/rootfs.ubi/${IMAGE_LINK_NAME}-${MACHINE}/ 
${SCRIPTFILE_TEMPLATE}
    fi
    cp    ${SCRIPTFILE_TEMPLATE}    ${SCRIPTFILE}
}

EXPORT_FUNCTIONS sam-ba_setup

EXTRA_IMAGEDEPENDS_append_mymachine = ' sam-ba' IMAGE_POSTPROCESS_COMMAND_append_mymachine = " sam-ba_setup; "
----------------------------------------------------------------------------------------------------------
myimage.bb: contains.

inherit configure-sam-ba
----------------------------
It appears that the "configure-sam-ba.bbclass" file is found. If I change the filename in the inherit statement I get an error message.

inherit configure-sam-ba-x
I get an error message.

Another indication is that the call to "sam-ba_setup;" is inserted in the "run.do_rootfs.*" script, but the script does not contain the "sam-ba_setup" subroutine.

In some places IMAGE_POSTPROCESS_COMMAND contains " rootfs_update_timestamp ", from image.bbclass which *is* included in the "run.do_rootfs.*" script.

Should you not be able to use commands from a bbclass as PRE/POSTPROCESS_COMMAND?

A standard shell command will work, but since I need a number of commands, it seems cleaner to implement it in a bbclass file.
This is my first bbclass file, so there may be things, I don't understand...

BR
Ulf Samuelsson

#5 lore raw
In reply to Ulf Samuelsson

Hi Ulf,

I couldn't find the reason your recipe is stand alone, because it doesn't generate image by itself. Does it?

My idea is written under the quote. How is it?

Let me go back to your question in first mail.

2013/3/30 Ulf Samuelsson <[email protected]>:

Quoted 12 lines

Trying create a programming script recipe and need to find out the IMAGE_BASENAME of the bitbake target
so I can get the filename of the image

${MACHINE}-${IMAGE_BASENAME}.ubi

I.E: if I do

$ MACHINE=beagleboard  bitbake some-image

and "some-image_1.0.bb" contains

Quoted 7 lines

IMAGE_BASENAME = "renamed-image"

Then the resulting image will be

"beagleboard-renamed-image.ubi"

How get this info from another recipe?

---- your-image.bb ---- from here ----
include some-image.bb

((( use ${IMAGE_BASENAME} and ${MACHINE} for your process )))

((( after that, redefine IMAGE_BASENAME and other variables if necessary. )))

---- your-image.bb ---- to here ----

Signature · 1 line
Takeshi Hamasaki