Skip to contentSkip to conversation

Question regarding executing an install script during the build of an image

DISCUSSION Felix Kuhlmann 3 participants 4 messages Oct 19, 2024 – Oct 21, 2024

lore
Share & tools
lore
#0 lore raw

Hello everybody,

I need your help with a project I'm currently working on.
I want to create an image that contains the OpenPLC runtime, which is an open source soft PLC solution.

The creators of this project provide a handy install script, which can be aquired through their project's GitHub repository.

My question now is, what would I have to write in a custom recipe in order to install this piece of software? From what I can tell, it also compiles code on the go, so Bitbake would have to do that with the cross compiler used for other aspects of the build as well.

The solutions I've found online so far mostly centered around post-install scripts, which isn't what I'm looking for.

My goal is to have a soft PLC system that boots up and starts the necessary services straight away. Usually, this is taken care of by the script.

If you have any better ideas or if you need further information, feel free to reply.

Thanks in advance and best regards
Felix Kuhlmann

#1 lore raw

Hello Felix,
probably I don't have enough details to give you a complete hint.
However, the solution usually suggested is to create your own recipe, perhaps using "recipetool create" [1] and then adapt its content (this is what I usually explain during my Yocto training courses). Then you can include in your recipe the installation and the management of a launcher script and its systemd service for example (if you are using systemd) [2].

[1] https://docs.yoctoproject.org/next/dev-manual/new-recipe.html?highlight=systemd
[2] https://wiki.koansoftware.com/index.php/Add_a_systemd_service_file_into_a_Yocto_image

Marco Cavallini
Yocto Project ambassador

#2 lore raw

Hi Felix,

I presume you are talking about
https://github.com/thiagoralves/OpenPLC_v3/tree/master? In that case, what *actually* runs in that installation script is
https://github.com/thiagoralves/OpenPLC_v3/blob/master/background_installer.sh,
which is a highly general purpose distribution targeted approach, which basically relies on being able to pull in packages at random. This is nowhere near reproducible, and therefore will cause you a lot of pain if you want to put it into a recipe. So what you really need to do is:
1. make sure that all dependencies are already available as recipes so you can treat them as DEPENDS/RDEPENDS. The entry point for working through it is probably
https://github.com/thiagoralves/OpenPLC_v3/blob/b2ef6d15d0ec92110cf44ad3f58e364db60dec72/background_installer.sh#L241
2. factor out the hidden systemd service into a proper file and use the systemd.bbclass mechanisms to install it:
https://github.com/thiagoralves/OpenPLC_v3/blob/b2ef6d15d0ec92110cf44ad3f58e364db60dec72/background_installer.sh#L215
3. understand whatever magic is needed additionally, starting point probably is
https://github.com/thiagoralves/OpenPLC_v3/blob/b2ef6d15d0ec92110cf44ad3f58e364db60dec72/background_installer.sh#L250

Plus whatever goes wrong along the way. :-(

Greetz,
Josef

Quoted 29 lines · Marco Cavallini via lists.yoctoproject.org

Hello Felix,
probably I don't have enough details to give you a complete hint. However, the solution usually suggested is to create your own recipe, perhaps using "recipetool create" [1] and then adapt its content (this is what I usually explain during my Yocto training courses).
Then you can include in your recipe the installation and the management of a launcher script and its systemd service for example (if you are using systemd) [2].

[1]
https://docs.yoctoproject.org/next/dev-manual/new-recipe.html?highlight=systemd
[2]
https://wiki.koansoftware.com/index.php/Add_a_systemd_service_file_into_a_Yocto_image

Marco Cavallini
Yocto Project ambassador

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
You automatically follow any topics you start or reply to. View/Reply Online (#64055):
https://lists.yoctoproject.org/g/yocto/message/64055
Mute This Topic: https://lists.yoctoproject.org/mt/109099192/4689568
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#3 lore raw

Hi Marco, hi Josef,

thank you very much for your input.

I greatly underestimated the work needed for using the given installer script in the yocto context. I'm glad that you showed me the implications of my plan beforehand, this saves me a few wasted hours :D

Greetings,
Felix

Am Mon, Oct 21, 2024 at 11:39:14AM +0200 schrieb Josef Holzmayr:

Quoted 58 lines

Hi Felix,

I presume you are talking about
https://github.com/thiagoralves/OpenPLC_v3/tree/master? In that case, what *actually* runs in that installation script is
https://github.com/thiagoralves/OpenPLC_v3/blob/master/background_installer.sh,
which is a highly general purpose distribution targeted approach, which basically relies on being able to pull in packages at random. This is nowhere near reproducible, and therefore will cause you a lot of pain if you want to put it into a recipe. So what you really need to do is:
1. make sure that all dependencies are already available as recipes so you can treat them as DEPENDS/RDEPENDS. The entry point for working through it is probably
https://github.com/thiagoralves/OpenPLC_v3/blob/b2ef6d15d0ec92110cf44ad3f58e364db60dec72/background_installer.sh#L241
2. factor out the hidden systemd service into a proper file and use the systemd.bbclass mechanisms to install it:
https://github.com/thiagoralves/OpenPLC_v3/blob/b2ef6d15d0ec92110cf44ad3f58e364db60dec72/background_installer.sh#L215
3. understand whatever magic is needed additionally, starting point probably is
https://github.com/thiagoralves/OpenPLC_v3/blob/b2ef6d15d0ec92110cf44ad3f58e364db60dec72/background_installer.sh#L250

Plus whatever goes wrong along the way. :-(

Greetz,
Josef

Quoted 29 lines · Marco Cavallini via lists.yoctoproject.org

Hello Felix,
probably I don't have enough details to give you a complete hint. However, the solution usually suggested is to create your own recipe, perhaps using "recipetool create" [1] and then adapt its content (this is what I usually explain during my Yocto training courses).
Then you can include in your recipe the installation and the management of a launcher script and its systemd service for example (if you are using systemd) [2].

[1]
https://docs.yoctoproject.org/next/dev-manual/new-recipe.html?highlight=systemd
[2]
https://wiki.koansoftware.com/index.php/Add_a_systemd_service_file_into_a_Yocto_image

Marco Cavallini
Yocto Project ambassador

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
You automatically follow any topics you start or reply to. View/Reply Online (#64055):
https://lists.yoctoproject.org/g/yocto/message/64055
Mute This Topic: https://lists.yoctoproject.org/mt/109099192/4689568
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-