Torizon-minimal: location of pkg_postinst_ontarget-scripts

Hello,

I have built a torizon-minimal image with a custom recipe in which a pkg_postinst_ontarget:${PN} script is defined. But this script is not executed at the first start. Now I wonder where this script is located in the Torizon file system.
In a Toradex reference image they are located in /var/lib/opkg/. In the Torizon file system this directory is missing.

Best regards,
Markus

Hi, I’m the Toradex AI Assistant. I’m in early beta, and I would appreciate your feedback.
The Toradex Support team will follow up with you shortly!

Did you like my answer?

:+1: :-1:


Hello,

In TorizonCore, which is based on OSTree and container technologies, the traditional package management system found in standard Linux distributions (like opkg in the Yocto Project) is not used in the same way. This means that the directory /var/lib/opkg/, where post-installation scripts (pkg_postinst_ontarget) would typically be located in a Yocto-based system, does not exist.

For managing containers and deploying applications on TorizonCore, the recommended approach is to encapsulate your applications and their dependencies within Docker containers. If you need to execute scripts similar to pkg_postinst_ontarget for application setup or configuration, you should include these scripts within your container and manage their execution through your container’s entrypoint script or command.

If your custom recipe needs to perform actions on the host system outside of a container, consider alternative approaches such as creating a systemd service within your container that interacts with the host system, or using TorizonCore Builder to customize the base TorizonCore image with necessary scripts or modifications.

Remember, the architecture of TorizonCore is designed to minimize direct interactions with the host file system to maintain system integrity and reliability, favoring containerized applications for most use cases.

Best regards, Toradex AI Assistant

Please, also check if these links can help you solve your problem:

Basic Linux Commands | Toradex Developer Center.

Hello @Mowlwurf,

The @ToradexAI provided a decent answer. Since TorizonOS is based on OSTree its filesystem is structured differently. Most likely you will indeed need to create a systemd service to perform your script. TorizonCore Builder will be difficult, since you are using the torizon-minimal image.
To create a script I recommend looking at the following entry on our developer page:

Please let me know how you fare with this.

Best regards
Collin

But this script is not executed at the first start. Now I wonder where this script is located in the Torizon file system.

I believe the following recipe gets used to handle post-install scripts: run-postinsts « recipes-devtools « meta - openembedded-core - OpenEmbedded Core layer

As you can see there is a systemd service that runs one time and executes a script that executes all the post-install scripts found. In our case since Torizon does not have a package manager by default the scripts should be located in /etc/ipk-postinsts. Now the problem is that if you look at the script that executes the post-install scripts: run-postinsts « run-postinsts « run-postinsts « recipes-devtools « meta - openembedded-core - OpenEmbedded Core layer

It looks like it deletes the post-install scripts after executing them. Makes it a bit difficult to debug after the fact. That said, I can say for sure this mechanism does work properly as we use it ourselves: meta-toradex-torizon/recipes-core/torizon-users/torizon-users_1.0.bb at kirkstone-6.x.y · torizon/meta-toradex-torizon · GitHub

This is how we enforce changing the password on first login.

Best Regards,
Jeremias

Hello @collin.tx and @jeremias.tx,

thanks a lot for your answers.

It looks like it deletes the post-install scripts after executing them. Makes it a bit difficult to debug after the fact. That said, I can say for sure this mechanism does work properly as we use it ourselves: meta-toradex-torizon/recipes-core/torizon-users/torizon-users_1.0.bb at kirkstone-6.x.y · torizon/meta-toradex-torizon · GitHub

This is how we enforce changing the password on first login.

@jeremias.tx When I build torizon-minimal and log in via ssh, I don’t have to change the password for the torizon user. I also do not see the directory /etc/ipkg-postinst neither in the image file nor on the device.

Best regards,
Markus

When I build torizon-minimal and log in via ssh, I don’t have to change the password for the torizon user. I also do not see the directory /etc/ipkg-postinst neither in the image file nor on the device.

That’s odd. Are you sure you’re building the torizon-minimal.bb recipe in Yocto? Or maybe you did some changes already to the default build?

The torizon-users recipe I linked prior should be a part of the torizon-minimal.bb image by default. Also when you say you log in as the torizon user, without having to change the password, what is the password? The default torizon password?

Best Regards,
Jeremias

@jeremias.tx Your’re right. I just setup a clean build environment and build torizon-minimal without changes.
In the image I found the directory /etc/ipkg-postinst with the file 000-torizon-users. When I flash it to my SOM and login in as torizon I have to change the password.

So there must be a change I did that broke something.

Best regards,
Markus

Thank you for double-checking. That clears up any mysteries there then.

Best Regards,
Jeremias

Hello @jeremias.tx and @drew.tx,

I’ve found my error.
In my image recipe I had the following:

IMAGE_FEATURES += "\
	debug-tweaks \
	package-management \
	eclipse-debug \
	tools-debug \
"

The package-management is the problem. When I remove it, I get the post-install scripts in /etc/ipkg-postinst like in the torizon-minimal image.

Best regards,
Markus

The package-management is the problem. When I remove it, I get the post-install scripts in /etc/ipkg-postinst like in the torizon-minimal image.

Oh that makes sense. If you look at the run-postinsts script I referenced earlier in the thread you’ll see there are multiple locations post-install scripts can be found. If there is a package manager in your image then the scripts will be located in file paths relevant to those package managers. Otherwise if no package manager is on your image it defaults to /etc/ipkg-postinst.

Glad to see you figured it out though.

Best Regards,
Jeremias