Prepare.sh and wrapup.sh added to build artifact

Hi Guys,

I was wondering if it is possible to add the prepare.sh and wrapup.sh to the build artifact that results from the `torizoncore-builder build` command? We want to take the existing provisioning data and set it back to the /var/sota/ directory. This works already if we manually adjust the scripts however I could not find a way to provide these scripts to the tcbuild.yaml for example.

Kind regards,

Mehmet

Hi, I’m the Toradex AI Assistant.

I might make mistakes or occasionally get you wrong. Our support team will step in if needed.


Adding prepare.sh and wrapup.sh Scripts to TorizonCore Builder

Based on the available TorizonCore Builder documentation, there isn’t a direct configuration option in tcbuild.yaml to include custom prepare.sh and wrapup.sh scripts in the build artifact(1)(2).

However, you can achieve this using the filesystem customization feature, which allows you to add files and directories to your custom Torizon OS image.

Solution: Using Filesystem Customization

You can include your scripts by placing them in a directory structure and referencing it in your tcbuild.yaml configuration file(2)(3):

# Sample configuration file
input:
  easy-installer:
    local: images/your-torizon-image.tar

customization:
  filesystem:
    - custom-scripts/

output:
  easy-installer:
    local: your-custom-image

(1)(2)

Directory Structure

Create a directory structure that mirrors where you want the scripts to be placed on the target system(3):

.
├── custom-scripts/
│   └── var/
│       └── sota/
│           ├── prepare.sh
│           └── wrapup.sh
└── tcbuild.yaml

The filesystem property accepts a list of directories to be merged with the input image, and the corresponding directory trees will be applied on top of the ones present in the input image(1).

Alternative: Capture Changes from Live Device

If you’ve already manually adjusted the scripts on a running device, you can capture these changes using the isolate command and then apply them to your build(3):

  1. Make your changes on a live Torizon device
  2. Use torizoncore-builder isolate to capture the changes
  3. Reference the captured changes directory in your tcbuild.yaml

This approach is particularly useful for preserving file permissions and ownership that might be important for your provisioning scripts(3).

The filesystem customization feature is the standard way to include custom files and scripts in your Torizon OS image build process.

Best regards, Toradex AI Assistant.


Did you like my answer? :+1: :-1:

If I answered your question, please tick the “Solution” checkbox.

For follow-up questions to me, please use @ToradexAI in your post.

Hi

Not really what I was looking for, I am looking for a way to be able to have 2 script files present in my code base and building the artifact which includes these scripts within the result.

Hi @simplymehmet!

I’m not sure if I completely understood your goal.

Could you please explain/detail why you want 2 script files? Do you want to build the image with your customized scripts?

Best regards.

Hi Lucas,

Well I have this prepare.sh script

#!/bin/sh
#
# (c) Toradex AG 2016
#
# Empty in-field hardware update script
#

PRODUCT_ID=$1
BOARD_REV=$2
SERIAL=$3
IMAGE_FOLDER=$4

error_exit () {
	echo "$1" 1>&2
	exit 1
}

mkdir -p /run/os
mount /dev/mmcblk2p1 /run/os
cp -r /run/os/ostree/deploy/torizon/var/sota/import /run 
umount /run/os 
exit 0

and this wrapup.sh script

#!/bin/sh

mkdir -p /run/os
mount /dev/mmcblk2p1 /run/os
cp -r /run/import /run/os/ostree/deploy/torizon/var/sota
umount /run/os
exit 0

These scripts take the existing provisioning data of the machine and put it back after the update. This has been tested and works but currently we are manually placing these files within the build artifact that results from the torizoncore-builder build command.

Now what I was wondering is if there is something available that would place these scripts within the build artifact by adding the scripts to the tcbuild.yaml for example?

Kind regards ,

Mehmet

Hi @simplymehmet!

Why do you want it to be built directly with the image? Theoretically, if you place these files manually, you can use the image folder to flash as many modules as you want, and they’ll be affected by these scripts.

Best regards.

Hi Lucas,

If it would have been possible it would have made our automation less verbose and that is why I was wondering if there were any possibilities doing this. If the answer is simply “no“ then we have to do some extra commands within our automation for copying these files to the right destination.

Which works and is fine, my inner dev just wanted it to be even better :stuck_out_tongue:

Kind regards,

Mehmet

Hi @simplymehmet!

I talked with our R&D team, and unfortunately, it isn’t possible. You have to copy it manually or through a custom automation.

Best regards.