Message ID | 20240703133602.412984-1-festevam@gmail.com |
---|---|
State | Accepted |
Headers | show |
Series | swupdate: Remove True parameter from getVar() and getVarFlag() | expand |
Hi Fabio, On 03.07.24 15:36, Fabio Estevam wrote: > True is default since 2016 and most layers were already updated > not to pass this parameter where not necessary, e.g. oe-core was > updated couple times, first in: > > https://git.openembedded.org/openembedded-core/commit/?id=7c552996597faaee2fbee185b250c0ee30ea3b5f > > and later in: > > https://git.openembedded.org/openembedded-core/commit/?id=26c74fd10614582e177437608908eb43688ab510 > > Do the same in the swupdate layer. > > Signed-off-by: Fabio Estevam <festevam@gmail.com> > --- > classes-recipe/swupdate-common.bbclass | 66 +++++++++++++------------- > classes-recipe/swupdate-image.bbclass | 6 +-- > 2 files changed, 36 insertions(+), 36 deletions(-) > > diff --git a/classes-recipe/swupdate-common.bbclass b/classes-recipe/swupdate-common.bbclass > index ad3c0a023936..0367f812e28f 100644 > --- a/classes-recipe/swupdate-common.bbclass > +++ b/classes-recipe/swupdate-common.bbclass > @@ -29,13 +29,13 @@ python () { > > def get_pwd_file_args(d, passfile): > pwd_args = [] > - pwd_file = d.getVar(passfile, True) > + pwd_file = d.getVar(passfile) > if pwd_file: > pwd_args = ["-passin", "file:%s" % pwd_file] > return pwd_args > > def get_certfile_args(d): > - extra_certs = d.getVar('SWUPDATE_CMS_EXTRA_CERTS', True) > + extra_certs = d.getVar('SWUPDATE_CMS_EXTRA_CERTS') > if not extra_certs: > return [] > certfile_args = [] > @@ -53,7 +53,7 @@ def swupdate_getdepends(d): > deps.append(i) > > deps = [] > - images = (d.getVar('IMAGE_DEPENDS', True) or "").split() > + images = (d.getVar('IMAGE_DEPENDS') or "").split() > for image in images: > adddep(image , deps) > > @@ -169,19 +169,19 @@ def prepare_sw_description(d): > import shutil > import subprocess > > - s = d.getVar('S', True) > + s = d.getVar('S') > swupdate_expand_bitbake_variables(d, s) > > swupdate_write_sha256(s) > > - encrypt = d.getVar('SWUPDATE_ENCRYPT_SWDESC', True) > + encrypt = d.getVar('SWUPDATE_ENCRYPT_SWDESC') > if encrypt: > bb.note("Encryption of sw-description") > shutil.copyfile(os.path.join(s, 'sw-description'), os.path.join(s, 'sw-description.plain')) > - key,iv = swupdate_extract_keys(d.getVar('SWUPDATE_AES_FILE', True)) > + key,iv = swupdate_extract_keys(d.getVar('SWUPDATE_AES_FILE')) > swupdate_encrypt_file(os.path.join(s, 'sw-description.plain'), os.path.join(s, 'sw-description'), key, iv) > > - signing = d.getVar('SWUPDATE_SIGNING', True) > + signing = d.getVar('SWUPDATE_SIGNING') > if signing == "1": > bb.warn('SWUPDATE_SIGNING = "1" is deprecated, falling back to "RSA". It is advised to set it to "RSA" if using RSA signing.') > signing = "RSA" > @@ -192,26 +192,26 @@ def prepare_sw_description(d): > > if signing == "CUSTOM": > signcmd = [] > - sign_tool = d.getVar('SWUPDATE_SIGN_TOOL', True) > + sign_tool = d.getVar('SWUPDATE_SIGN_TOOL') > signtool = sign_tool.split() > for i in range(len(signtool)): > signcmd.append(signtool[i]) > if not signcmd: > bb.fatal("Custom SWUPDATE_SIGN_TOOL is not given") > elif signing == "RSA": > - privkey = d.getVar('SWUPDATE_PRIVATE_KEY', True) > + privkey = d.getVar('SWUPDATE_PRIVATE_KEY') > if not privkey: > bb.fatal("SWUPDATE_PRIVATE_KEY isn't set") > if not os.path.exists(privkey): > bb.fatal("SWUPDATE_PRIVATE_KEY %s doesn't exist" % (privkey)) > signcmd = ["openssl", "dgst", "-sha256", "-sign", privkey] + get_pwd_file_args(d, 'SWUPDATE_PASSWORD_FILE') + ["-out", sw_desc_sig, sw_desc] > elif signing == "CMS": > - cms_cert = d.getVar('SWUPDATE_CMS_CERT', True) > + cms_cert = d.getVar('SWUPDATE_CMS_CERT') > if not cms_cert: > bb.fatal("SWUPDATE_CMS_CERT is not set") > if not os.path.exists(cms_cert): > bb.fatal("SWUPDATE_CMS_CERT %s doesn't exist" % (cms_cert)) > - cms_key = d.getVar('SWUPDATE_CMS_KEY', True) > + cms_key = d.getVar('SWUPDATE_CMS_KEY') > if not cms_key: > bb.fatal("SWUPDATE_CMS_KEY isn't set") > if not os.path.exists(cms_key): > @@ -228,7 +228,7 @@ def prepare_sw_description(d): > def swupdate_add_src_uri(d, list_for_cpio): > import shutil > > - s = d.getVar('S', True) > + s = d.getVar('S') > exclude = (d.getVar("SWUPDATE_SRC_URI_EXCLUDE") or "").split() > > fetch = bb.fetch2.Fetch([], d) > @@ -239,11 +239,11 @@ def swupdate_add_src_uri(d, list_for_cpio): > filename = os.path.basename(local) > if filename in exclude: > continue > - aes_file = d.getVar('SWUPDATE_AES_FILE', True) > + aes_file = d.getVar('SWUPDATE_AES_FILE') > if aes_file: > - key,iv = swupdate_extract_keys(d.getVar('SWUPDATE_AES_FILE', True)) > + key,iv = swupdate_extract_keys(d.getVar('SWUPDATE_AES_FILE')) > if (filename != 'sw-description') and (os.path.isfile(local)): > - encrypted = (d.getVarFlag("SWUPDATE_IMAGES_ENCRYPTED", filename, True) or "") > + encrypted = (d.getVarFlag("SWUPDATE_IMAGES_ENCRYPTED", filename) or "") > dst = os.path.join(s, "%s" % filename ) > if encrypted == '1': > bb.note("Encryption requested for %s" %(filename)) > @@ -263,7 +263,7 @@ def add_image_to_swu(d, deploydir, imagename, s, encrypt, list_for_cpio): > target_imagename = os.path.basename(imagename) # allow images in subfolders of DEPLOY_DIR_IMAGE > dst = os.path.join(s, target_imagename) > if encrypt == '1': > - key,iv = swupdate_extract_keys(d.getVar('SWUPDATE_AES_FILE', True)) > + key,iv = swupdate_extract_keys(d.getVar('SWUPDATE_AES_FILE')) > bb.note("Encryption requested for %s" %(imagename)) > swupdate_encrypt_file(src, dst, key, iv) > else: > @@ -274,21 +274,21 @@ def add_image_to_swu(d, deploydir, imagename, s, encrypt, list_for_cpio): > def swupdate_add_artifacts(d, list_for_cpio): > import shutil > # Search for images listed in SWUPDATE_IMAGES in the DEPLOY directory. > - images = (d.getVar('SWUPDATE_IMAGES', True) or "").split() > - deploydir = d.getVar('DEPLOY_DIR_IMAGE', True) > - imgdeploydir = d.getVar('SWUDEPLOYDIR', True) > - s = d.getVar('S', True) > + images = (d.getVar('SWUPDATE_IMAGES') or "").split() > + deploydir = d.getVar('DEPLOY_DIR_IMAGE') > + imgdeploydir = d.getVar('SWUDEPLOYDIR') > + s = d.getVar('S') > for image in images: > - fstypes = (d.getVarFlag("SWUPDATE_IMAGES_FSTYPES", image, True) or "").split() > - encrypted = (d.getVarFlag("SWUPDATE_IMAGES_ENCRYPTED", image, True) or "") > + fstypes = (d.getVarFlag("SWUPDATE_IMAGES_FSTYPES", image) or "").split() > + encrypted = (d.getVarFlag("SWUPDATE_IMAGES_ENCRYPTED", image) or "") > if fstypes: > - noappend_machine = d.getVarFlag("SWUPDATE_IMAGES_NOAPPEND_MACHINE", image, True) > + noappend_machine = d.getVarFlag("SWUPDATE_IMAGES_NOAPPEND_MACHINE", image) > if noappend_machine == "0": # Search for a file explicitly with MACHINE > - imagebases = [ image + '-' + d.getVar('MACHINE', True) ] > + imagebases = [ image + '-' + d.getVar('MACHINE') ] > elif noappend_machine == "1": # Search for a file explicitly without MACHINE > imagebases = [ image ] > else: # None, means auto mode. Just try to find an image file with MACHINE or without MACHINE > - imagebases = [ image + '-' + d.getVar('MACHINE', True), image ] > + imagebases = [ image + '-' + d.getVar('MACHINE'), image ] > for fstype in fstypes: > image_found = False > for imagebase in imagebases: > @@ -303,13 +303,13 @@ def swupdate_add_artifacts(d, list_for_cpio): > > > def swupdate_create_cpio(d, swudeploydir, list_for_cpio): > - s = d.getVar('S', True) > + s = d.getVar('S') > os.chdir(s) > - updateimage = d.getVar('IMAGE_NAME', True) + '.swu' > + updateimage = d.getVar('IMAGE_NAME') + '.swu' > line = 'for i in ' + ' '.join(list_for_cpio) + '; do echo $i;done | cpio -ov -H crc --reproducible > ' + os.path.join(swudeploydir, updateimage) > os.system(line) > os.chdir(swudeploydir) > - updateimage_link = d.getVar('IMAGE_LINK_NAME', True) > + updateimage_link = d.getVar('IMAGE_LINK_NAME') > if updateimage_link: > updateimage_link += '.swu' > if updateimage_link != updateimage: > @@ -319,16 +319,16 @@ python do_swuimage () { > import shutil > > list_for_cpio = ["sw-description"] > - workdir = d.getVar('WORKDIR', True) > - s = d.getVar('S', True) > - imgdeploydir = d.getVar('SWUDEPLOYDIR', True) > + workdir = d.getVar('WORKDIR') > + s = d.getVar('S') > + imgdeploydir = d.getVar('SWUDEPLOYDIR') > shutil.copyfile(os.path.join(workdir, "sw-description"), os.path.join(s, "sw-description")) > > - if d.getVar('SWUPDATE_SIGNING', True): > + if d.getVar('SWUPDATE_SIGNING'): > list_for_cpio.append('sw-description.sig') > > # Add artifacts added via SRC_URI > - if not d.getVar('INHIBIT_SWUPDATE_ADD_SRC_URI', True): > + if not d.getVar('INHIBIT_SWUPDATE_ADD_SRC_URI'): > swupdate_add_src_uri(d, list_for_cpio) > > # Add artifacts set via SWUPDATE_IMAGES > diff --git a/classes-recipe/swupdate-image.bbclass b/classes-recipe/swupdate-image.bbclass > index e9c67a6ff1a5..175fc4ea61e4 100644 > --- a/classes-recipe/swupdate-image.bbclass > +++ b/classes-recipe/swupdate-image.bbclass > @@ -19,7 +19,7 @@ SRC_URI += "file://sw-description" > SWUPDATE_IMAGES += "${IMAGE_LINK_NAME}" > > python () { > - image = d.getVar('IMAGE_LINK_NAME', True) > + image = d.getVar('IMAGE_LINK_NAME') > if d.getVarFlag("SWUPDATE_IMAGES_FSTYPES", image) is None: > flag = d.getVarFlag("SWUPDATE_IMAGES_FSTYPES", d.getVar('IMAGE_BASENAME')) > if flag: > @@ -38,8 +38,8 @@ python do_swupdate_copy_swdescription() { > > import shutil > > - workdir = d.getVar('S', True) > - image = d.getVar('IMAGE_LINK_NAME', True) > + workdir = d.getVar('S') > + image = d.getVar('IMAGE_LINK_NAME') > filespath = d.getVar('FILESPATH') > sw_desc_path = bb.utils.which(filespath, "sw-description") > shutil.copyfile(sw_desc_path, os.path.join(workdir, "sw-description")) Thanks for cleanup ! Acked-by: Stefano Babic <stefano.babic@swupdate.org> Best regards, Stefano
diff --git a/classes-recipe/swupdate-common.bbclass b/classes-recipe/swupdate-common.bbclass index ad3c0a023936..0367f812e28f 100644 --- a/classes-recipe/swupdate-common.bbclass +++ b/classes-recipe/swupdate-common.bbclass @@ -29,13 +29,13 @@ python () { def get_pwd_file_args(d, passfile): pwd_args = [] - pwd_file = d.getVar(passfile, True) + pwd_file = d.getVar(passfile) if pwd_file: pwd_args = ["-passin", "file:%s" % pwd_file] return pwd_args def get_certfile_args(d): - extra_certs = d.getVar('SWUPDATE_CMS_EXTRA_CERTS', True) + extra_certs = d.getVar('SWUPDATE_CMS_EXTRA_CERTS') if not extra_certs: return [] certfile_args = [] @@ -53,7 +53,7 @@ def swupdate_getdepends(d): deps.append(i) deps = [] - images = (d.getVar('IMAGE_DEPENDS', True) or "").split() + images = (d.getVar('IMAGE_DEPENDS') or "").split() for image in images: adddep(image , deps) @@ -169,19 +169,19 @@ def prepare_sw_description(d): import shutil import subprocess - s = d.getVar('S', True) + s = d.getVar('S') swupdate_expand_bitbake_variables(d, s) swupdate_write_sha256(s) - encrypt = d.getVar('SWUPDATE_ENCRYPT_SWDESC', True) + encrypt = d.getVar('SWUPDATE_ENCRYPT_SWDESC') if encrypt: bb.note("Encryption of sw-description") shutil.copyfile(os.path.join(s, 'sw-description'), os.path.join(s, 'sw-description.plain')) - key,iv = swupdate_extract_keys(d.getVar('SWUPDATE_AES_FILE', True)) + key,iv = swupdate_extract_keys(d.getVar('SWUPDATE_AES_FILE')) swupdate_encrypt_file(os.path.join(s, 'sw-description.plain'), os.path.join(s, 'sw-description'), key, iv) - signing = d.getVar('SWUPDATE_SIGNING', True) + signing = d.getVar('SWUPDATE_SIGNING') if signing == "1": bb.warn('SWUPDATE_SIGNING = "1" is deprecated, falling back to "RSA". It is advised to set it to "RSA" if using RSA signing.') signing = "RSA" @@ -192,26 +192,26 @@ def prepare_sw_description(d): if signing == "CUSTOM": signcmd = [] - sign_tool = d.getVar('SWUPDATE_SIGN_TOOL', True) + sign_tool = d.getVar('SWUPDATE_SIGN_TOOL') signtool = sign_tool.split() for i in range(len(signtool)): signcmd.append(signtool[i]) if not signcmd: bb.fatal("Custom SWUPDATE_SIGN_TOOL is not given") elif signing == "RSA": - privkey = d.getVar('SWUPDATE_PRIVATE_KEY', True) + privkey = d.getVar('SWUPDATE_PRIVATE_KEY') if not privkey: bb.fatal("SWUPDATE_PRIVATE_KEY isn't set") if not os.path.exists(privkey): bb.fatal("SWUPDATE_PRIVATE_KEY %s doesn't exist" % (privkey)) signcmd = ["openssl", "dgst", "-sha256", "-sign", privkey] + get_pwd_file_args(d, 'SWUPDATE_PASSWORD_FILE') + ["-out", sw_desc_sig, sw_desc] elif signing == "CMS": - cms_cert = d.getVar('SWUPDATE_CMS_CERT', True) + cms_cert = d.getVar('SWUPDATE_CMS_CERT') if not cms_cert: bb.fatal("SWUPDATE_CMS_CERT is not set") if not os.path.exists(cms_cert): bb.fatal("SWUPDATE_CMS_CERT %s doesn't exist" % (cms_cert)) - cms_key = d.getVar('SWUPDATE_CMS_KEY', True) + cms_key = d.getVar('SWUPDATE_CMS_KEY') if not cms_key: bb.fatal("SWUPDATE_CMS_KEY isn't set") if not os.path.exists(cms_key): @@ -228,7 +228,7 @@ def prepare_sw_description(d): def swupdate_add_src_uri(d, list_for_cpio): import shutil - s = d.getVar('S', True) + s = d.getVar('S') exclude = (d.getVar("SWUPDATE_SRC_URI_EXCLUDE") or "").split() fetch = bb.fetch2.Fetch([], d) @@ -239,11 +239,11 @@ def swupdate_add_src_uri(d, list_for_cpio): filename = os.path.basename(local) if filename in exclude: continue - aes_file = d.getVar('SWUPDATE_AES_FILE', True) + aes_file = d.getVar('SWUPDATE_AES_FILE') if aes_file: - key,iv = swupdate_extract_keys(d.getVar('SWUPDATE_AES_FILE', True)) + key,iv = swupdate_extract_keys(d.getVar('SWUPDATE_AES_FILE')) if (filename != 'sw-description') and (os.path.isfile(local)): - encrypted = (d.getVarFlag("SWUPDATE_IMAGES_ENCRYPTED", filename, True) or "") + encrypted = (d.getVarFlag("SWUPDATE_IMAGES_ENCRYPTED", filename) or "") dst = os.path.join(s, "%s" % filename ) if encrypted == '1': bb.note("Encryption requested for %s" %(filename)) @@ -263,7 +263,7 @@ def add_image_to_swu(d, deploydir, imagename, s, encrypt, list_for_cpio): target_imagename = os.path.basename(imagename) # allow images in subfolders of DEPLOY_DIR_IMAGE dst = os.path.join(s, target_imagename) if encrypt == '1': - key,iv = swupdate_extract_keys(d.getVar('SWUPDATE_AES_FILE', True)) + key,iv = swupdate_extract_keys(d.getVar('SWUPDATE_AES_FILE')) bb.note("Encryption requested for %s" %(imagename)) swupdate_encrypt_file(src, dst, key, iv) else: @@ -274,21 +274,21 @@ def add_image_to_swu(d, deploydir, imagename, s, encrypt, list_for_cpio): def swupdate_add_artifacts(d, list_for_cpio): import shutil # Search for images listed in SWUPDATE_IMAGES in the DEPLOY directory. - images = (d.getVar('SWUPDATE_IMAGES', True) or "").split() - deploydir = d.getVar('DEPLOY_DIR_IMAGE', True) - imgdeploydir = d.getVar('SWUDEPLOYDIR', True) - s = d.getVar('S', True) + images = (d.getVar('SWUPDATE_IMAGES') or "").split() + deploydir = d.getVar('DEPLOY_DIR_IMAGE') + imgdeploydir = d.getVar('SWUDEPLOYDIR') + s = d.getVar('S') for image in images: - fstypes = (d.getVarFlag("SWUPDATE_IMAGES_FSTYPES", image, True) or "").split() - encrypted = (d.getVarFlag("SWUPDATE_IMAGES_ENCRYPTED", image, True) or "") + fstypes = (d.getVarFlag("SWUPDATE_IMAGES_FSTYPES", image) or "").split() + encrypted = (d.getVarFlag("SWUPDATE_IMAGES_ENCRYPTED", image) or "") if fstypes: - noappend_machine = d.getVarFlag("SWUPDATE_IMAGES_NOAPPEND_MACHINE", image, True) + noappend_machine = d.getVarFlag("SWUPDATE_IMAGES_NOAPPEND_MACHINE", image) if noappend_machine == "0": # Search for a file explicitly with MACHINE - imagebases = [ image + '-' + d.getVar('MACHINE', True) ] + imagebases = [ image + '-' + d.getVar('MACHINE') ] elif noappend_machine == "1": # Search for a file explicitly without MACHINE imagebases = [ image ] else: # None, means auto mode. Just try to find an image file with MACHINE or without MACHINE - imagebases = [ image + '-' + d.getVar('MACHINE', True), image ] + imagebases = [ image + '-' + d.getVar('MACHINE'), image ] for fstype in fstypes: image_found = False for imagebase in imagebases: @@ -303,13 +303,13 @@ def swupdate_add_artifacts(d, list_for_cpio): def swupdate_create_cpio(d, swudeploydir, list_for_cpio): - s = d.getVar('S', True) + s = d.getVar('S') os.chdir(s) - updateimage = d.getVar('IMAGE_NAME', True) + '.swu' + updateimage = d.getVar('IMAGE_NAME') + '.swu' line = 'for i in ' + ' '.join(list_for_cpio) + '; do echo $i;done | cpio -ov -H crc --reproducible > ' + os.path.join(swudeploydir, updateimage) os.system(line) os.chdir(swudeploydir) - updateimage_link = d.getVar('IMAGE_LINK_NAME', True) + updateimage_link = d.getVar('IMAGE_LINK_NAME') if updateimage_link: updateimage_link += '.swu' if updateimage_link != updateimage: @@ -319,16 +319,16 @@ python do_swuimage () { import shutil list_for_cpio = ["sw-description"] - workdir = d.getVar('WORKDIR', True) - s = d.getVar('S', True) - imgdeploydir = d.getVar('SWUDEPLOYDIR', True) + workdir = d.getVar('WORKDIR') + s = d.getVar('S') + imgdeploydir = d.getVar('SWUDEPLOYDIR') shutil.copyfile(os.path.join(workdir, "sw-description"), os.path.join(s, "sw-description")) - if d.getVar('SWUPDATE_SIGNING', True): + if d.getVar('SWUPDATE_SIGNING'): list_for_cpio.append('sw-description.sig') # Add artifacts added via SRC_URI - if not d.getVar('INHIBIT_SWUPDATE_ADD_SRC_URI', True): + if not d.getVar('INHIBIT_SWUPDATE_ADD_SRC_URI'): swupdate_add_src_uri(d, list_for_cpio) # Add artifacts set via SWUPDATE_IMAGES diff --git a/classes-recipe/swupdate-image.bbclass b/classes-recipe/swupdate-image.bbclass index e9c67a6ff1a5..175fc4ea61e4 100644 --- a/classes-recipe/swupdate-image.bbclass +++ b/classes-recipe/swupdate-image.bbclass @@ -19,7 +19,7 @@ SRC_URI += "file://sw-description" SWUPDATE_IMAGES += "${IMAGE_LINK_NAME}" python () { - image = d.getVar('IMAGE_LINK_NAME', True) + image = d.getVar('IMAGE_LINK_NAME') if d.getVarFlag("SWUPDATE_IMAGES_FSTYPES", image) is None: flag = d.getVarFlag("SWUPDATE_IMAGES_FSTYPES", d.getVar('IMAGE_BASENAME')) if flag: @@ -38,8 +38,8 @@ python do_swupdate_copy_swdescription() { import shutil - workdir = d.getVar('S', True) - image = d.getVar('IMAGE_LINK_NAME', True) + workdir = d.getVar('S') + image = d.getVar('IMAGE_LINK_NAME') filespath = d.getVar('FILESPATH') sw_desc_path = bb.utils.which(filespath, "sw-description") shutil.copyfile(sw_desc_path, os.path.join(workdir, "sw-description"))
True is default since 2016 and most layers were already updated not to pass this parameter where not necessary, e.g. oe-core was updated couple times, first in: https://git.openembedded.org/openembedded-core/commit/?id=7c552996597faaee2fbee185b250c0ee30ea3b5f and later in: https://git.openembedded.org/openembedded-core/commit/?id=26c74fd10614582e177437608908eb43688ab510 Do the same in the swupdate layer. Signed-off-by: Fabio Estevam <festevam@gmail.com> --- classes-recipe/swupdate-common.bbclass | 66 +++++++++++++------------- classes-recipe/swupdate-image.bbclass | 6 +-- 2 files changed, 36 insertions(+), 36 deletions(-)