All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gylstorff Quirin <quirin.gylstorff@siemens.com>
To: Jan Kiszka <jan.kiszka@siemens.com>,
	cip-dev@lists.cip-project.org, felix.moessbauer@siemens.com
Subject: Re: [cip-dev][isar-cip-core][PATCH v2 4/4] fix do not add files to each image recipe
Date: Tue, 5 Mar 2024 15:34:25 +0100	[thread overview]
Message-ID: <2f0ac283-22c2-4c06-a90c-d874a803139b@siemens.com> (raw)
In-Reply-To: <13f6bab4-0b95-429a-b6e5-b4859a111bc2@siemens.com>



On 3/5/24 3:17 PM, Jan Kiszka wrote:
> On 05.03.24 12:02, Quirin Gylstorff wrote:
>> From: Quirin Gylstorff <quirin.gylstorff@siemens.com>
>>
>> Due to the use of an anonym python function each image recipe was
> 
> anonymous
> 
>> partial build even if not requested.
> 
> built
> 
>> To avoid this remove the anonym image function by adding
> 
> anonymous
> 
>> it as an prefunc to do_image_swu and do_transform_template.
>>
>> The SRC_URI is appended with a function.
>>
>> Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com>
>> ---
>>   classes/efibootguard.bbclass |  1 -
>>   classes/swupdate.bbclass     | 42 ++++++++++++++++++++++++------------
>>   2 files changed, 28 insertions(+), 15 deletions(-)
>>
>> diff --git a/classes/efibootguard.bbclass b/classes/efibootguard.bbclass
>> index 31fcdcc..2b4f09e 100644
>> --- a/classes/efibootguard.bbclass
>> +++ b/classes/efibootguard.bbclass
>> @@ -67,5 +67,4 @@ python add_ebg_update(){
>>      ebg_update = d.getVar('SWU_EBG_UPDATE') or ""
>>      if ebg_update:
>>        d.appendVar('SWU_FILE_NODES', "," + swu_ebg_update_node)
> 
> Indention looks fishy, but that is nothing this patch caused.

I will fix it in a separate patch.

Quirin
> 
>> -   d.appendVar('SWU_ADDITIONAL_FILES', " " + efi_boot_loader_file)
>>   }
>> diff --git a/classes/swupdate.bbclass b/classes/swupdate.bbclass
>> index c62f43f..c82d20c 100644
>> --- a/classes/swupdate.bbclass
>> +++ b/classes/swupdate.bbclass
>> @@ -63,7 +63,7 @@ IMAGE_TEMPLATE_VARS:swu = " \
>>   # TARGET_IMAGE_UUID needs to be generated before completing the template
>>   addtask do_transform_template after do_generate_image_uuid
>>   
>> -python(){
>> +python do_extend_sw_description(){
> 
> () {
> 
>>       cmds = d.getVar("SWU_EXTEND_SW_DESCRIPTION")
>>       if cmds is None or not cmds.strip():
>>           return
>> @@ -71,6 +71,7 @@ python(){
>>       for cmd in cmds:
>>           bb.build.exec_func(cmd, d)
>>   }
>> +do_transform_template[prefuncs] += "do_extend_sw_description"
>>   
>>   SWU_EXTEND_SW_DESCRIPTION += "add_swu_hw_compat"
>>   python add_swu_hw_compat(){
>> @@ -94,9 +95,22 @@ python add_swu_compression(){
>>           d.setVar('SWU_COMPRESSION_NODE', '')
>>   }
>>   
>> +def add_scripts_to_src_uri(d):
>> +    swu_scripts = d.getVar('SWU_SCRIPTS')
>> +    if not swu_scripts:
>> +        return ""
>> +    swu_script_entries = swu_scripts.split()
>> +    script_file_list = []
>> +    for entry in swu_script_entries:
>> +        script_entry = f"SWU_SCRIPT_{entry}"
>> +        script_file = d.getVarFlag(script_entry, "file")
>> +        script_file_list.append(f" file://{script_file}")
>> +    return ' '.join([n for n in script_file_list])
>>   
>> -SWU_EXTEND_SW_DESCRIPTION += "add_scripts"
>> -python add_scripts(){
>> +SRC_URI += "${@add_scripts_to_src_uri(d)}"
>> +
>> +SWU_EXTEND_SW_DESCRIPTION += "add_scripts_node"
>> +python add_scripts_node(){
>>       swu_scripts = d.getVar('SWU_SCRIPTS')
>>       if not swu_scripts:
>>           return
>> @@ -129,8 +143,6 @@ python add_scripts(){
>>             sha256 = "{script_file}-sha256";
>>           }}"""
>>           script_node_list.append(node)
>> -        d.appendVar('SWU_ADDITIONAL_FILES', " " + script_file)
>> -        d.appendVar('SRC_URI', f" file://{script_file}")
>>   
>>       swu_scripts_node = "scripts: (" + ','.join([n for n in script_node_list]) + ");"
>>       d.appendVar('SWU_SCRIPTS_NODE', swu_scripts_node)
>> @@ -155,6 +167,7 @@ FILESEXTRAPATHS:append = ":${LAYERDIR_cip-core}/recipes-core/images/swu"
>>   do_image_swu[depends] += "${PN}:do_transform_template"
>>   do_image_swu[stamp-extra-info] = "${DISTRO}-${MACHINE}"
>>   do_image_swu[cleandirs] += "${WORKDIR}/swu ${WORKDIR}/swu-${SWU_BOOTLOADER}"
>> +do_image_swu[prefuncs] = "do_extend_sw_description"
>>   IMAGE_CMD:swu() {
>>       rm -f '${DEPLOY_DIR_IMAGE}/${SWU_IMAGE_FILE}'*.swu
>>       cp '${WORKDIR}/${SWU_DESCRIPTION_FILE}' '${WORKDIR}/swu/${SWU_DESCRIPTION_FILE}'
>> @@ -165,13 +178,14 @@ IMAGE_CMD:swu() {
>>       for swu_file in "${WORKDIR}"/swu*; do
>>           swu_file_base=$(basename $swu_file)
>>           # Create symlinks for files used in the update image
>> -        for file in ${SWU_ADDITIONAL_FILES}; do
>> -            if grep -q "$file" "${WORKDIR}/$swu_file_base/${SWU_DESCRIPTION_FILE}"; then
>> -                if [ -e "${WORKDIR}/$file" ]; then
>> -                    ln -s "${PP_WORK}/$file" "${WORKDIR}/$swu_file_base/$file"
>> -                else
>> -                    ln -s "${PP_DEPLOY}/$file" "${WORKDIR}/$swu_file_base/$file"
>> -                fi
>> +        swu_files=$(awk '$1=="filename"{gsub(/[",;]/, "", $3); print $3}' \
>> +            "${WORKDIR}/$swu_file_base/${SWU_DESCRIPTION_FILE}")
>> +        export swu_files
>> +        for file in $swu_files; do
>> +            if [ -e "${WORKDIR}/$file" ]; then
>> +                ln -s "${PP_WORK}/$file" "${WORKDIR}/$swu_file_base/$file"
>> +            else
>> +                ln -s "${PP_DEPLOY}/$file" "${WORKDIR}/$swu_file_base/$file"
>>               fi
>>           done
>>   
>> @@ -186,7 +200,7 @@ IMAGE_CMD:swu() {
>>           export swu_file_extension
>>           imager_run -p -d ${PP_WORK} -u root <<'EOIMAGER'
>>               # Fill in file check sums
>> -            for file in ${SWU_ADDITIONAL_FILES}; do
>> +            for file in $swu_files; do
>>                   sed -i "s:$file-sha256:$(sha256sum "${PP_WORK}/$swu_file_base/"$file | cut -f 1 -d " "):g" \
>>                       "${PP_WORK}/$swu_file_base/${SWU_DESCRIPTION_FILE}"
>>               done
>> @@ -205,7 +219,7 @@ IMAGE_CMD:swu() {
>>               fi
>>   
>>               # sw-description must be first file in *.swu
>> -            for cpio_file in $cpio_files ${SWU_ADDITIONAL_FILES}; do
>> +            for cpio_file in $cpio_files $swu_files; do
>>                   if [ -f "$cpio_file" ]; then
>>                       # Set file timestamps for reproducible builds
>>                       if [ -n "${SOURCE_DATE_EPOCH}" ]; then
> 
> Jan
> 


      reply	other threads:[~2024-03-05 14:34 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-05 11:02 [cip-dev][isar-cip-core][PATCH v2 0/4] Make swupdate signing more robust Quirin Gylstorff
2024-03-05 11:02 ` [cip-dev][isar-cip-core][PATCH v2 1/4] swupdate: check output of sign-swu Quirin Gylstorff
2024-03-05 13:50   ` Jan Kiszka
2024-03-05 14:33     ` Gylstorff Quirin
2024-03-05 11:02 ` [cip-dev][isar-cip-core][PATCH v2 2/4] sign-swu-cms: check if key and cert are valid Quirin Gylstorff
2024-03-05 11:02 ` [cip-dev][isar-cip-core][PATCH v2 3/4] doc: Add section about SWUpdate signing to README.swupdate.md Quirin Gylstorff
2024-03-05 11:02 ` [cip-dev][isar-cip-core][PATCH v2 4/4] fix do not add files to each image recipe Quirin Gylstorff
2024-03-05 14:17   ` Jan Kiszka
2024-03-05 14:34     ` Gylstorff Quirin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2f0ac283-22c2-4c06-a90c-d874a803139b@siemens.com \
    --to=quirin.gylstorff@siemens.com \
    --cc=cip-dev@lists.cip-project.org \
    --cc=felix.moessbauer@siemens.com \
    --cc=jan.kiszka@siemens.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.