typecheck.bbclass: update per current variable typing code
PATCH 1/2 typecheck.bbclass: update per current variable typing code
From: Christopher Larson <[email protected]>
--- meta/classes/typecheck.bbclass | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
meta/classes/typecheck.bbclass +1 -1
@@ -7,6 +7,6 @@ python check_types() { if isinstance(e, bb.event.ConfigParsed): for key in e.data.keys(): if e.data.getVarFlag(key, "type"): - oe.types.value(key, e.data) + oe.data.typed_value(key, e.data) } addhandler check_types
Signature · 1 line
1.7.7
PATCH 2/2 archiver.bbclass: leverage variable typing support
From: Christopher Larson <[email protected]>
This makes use of variable typing to avoid reinventing the wheel in that way and adds default values for a couple of said variables. It also changes PATCHES_ARCHIVE_WITH_SERIES to use ?= rather than =.
Further, doing this fixes a single bug that occurs in many places:
if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() not in 'SRPM':
This is performing a substring search. It should have done "== 'SRPM'"", or if there *were* multiple options for that case (there aren't), it would do "not in ['SRPM']" or similar.
--- meta/classes/archiver.bbclass | 45 +++++++++++++++++-------------------- meta/classes/package_rpm.bbclass | 12 +++++----- 2 files changed, 27 insertions(+), 30 deletions(-)
meta/classes/archiver.bbclass +21 -24
@@ -2,10 +2,19 @@ # It also output building environment to xxx.dump.data and create xxx.diff.gz to record # all content in ${S} to a diff file. -ARCHIVE_EXCLUDE_FROM ?= ".pc autom4te.cache" -ARCHIVE_TYPE ?= "TAR SRPM" DISTRO ?= "poky" -PATCHES_ARCHIVE_WITH_SERIES = 'TRUE' +ARCHIVE_EXCLUDE_FROM ?= ".pc autom4te.cache" + +PATCHES_ARCHIVE_WITH_SERIES ?= "true" +PATCHES_ARCHIVE_WITH_SERIES[type] = "boolean" + +SOURCE_ARCHIVE_PACKAGE_TYPE ?= "tar" +SOURCE_ARCHIVE_PACKAGE_TYPE[type] = "choice" +SOURCE_ARCHIVE_PACKAGE_TYPE[choices] = "tar srpm" + +SOURCE_ARCHIVE_LOG_WITH_SCRIPTS ?= "logs_with_scripts" +SOURCE_ARCHIVE_LOG_WITH_SCRIPTS[type] = "choice" +SOURCE_ARCHIVE_LOG_WITH_SCRIPTS[choices] = "none logs logs_with_scripts" def get_bb_inc(d): '''create a directory "script-logs" including .bb and .inc file in ${WORKDIR}'''
@@ -253,14 +262,6 @@ def move_tarball_deploy(d,tarball_list): os.remove(os.path.join(tar_sources,source)) shutil.move(os.path.join(work_dir,source),tar_sources) -def check_archiving_type(d): - '''check the type for archiving package('tar' or 'srpm')''' - try: - if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() not in d.getVar('ARCHIVE_TYPE', True).split(): - raise AttributeError - except AttributeError: - bb.fatal("\"SOURCE_ARCHIVE_PACKAGE_TYPE\" is \'tar\' or \'srpm\', no other types") - def store_package(d,package_name): '''store tarbablls name to file "tar-package"''' try:
@@ -287,24 +288,21 @@ def archive_sources_patches(d,stage_name): '''archive sources and patches to tarball. stage_name will append strings ${stage_name} to ${PR} as middle name. for example, zlib-1.4.6-prepatch(stage_name).tar.gz ''' import shutil - check_archiving_type(d) if not_tarball(d): return source_tar_name = archive_sources(d,stage_name) if stage_name == "prepatch": - if d.getVar('PATCHES_ARCHIVE_WITH_SERIES',True).upper() == 'TRUE': + if oe.data.typed_value('PATCHES_ARCHIVE_WITH_SERIES', d): patch_tar_name = select_archive_patches(d,"all") - elif d.getVar('PATCHES_ARCHIVE_WITH_SERIES',True).upper() == 'FALSE': - patch_tar_name = select_archive_patches(d,"applying") else: - bb.fatal("Please define 'PATCHES_ARCHIVE_WITH_SERIES' is strings 'True' or 'False' ") + patch_tar_name = select_archive_patches(d,"applying") else: patch_tar_name = '' - if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() not in 'SRPM': + if oe.data.typed_value('SOURCE_ARCHIVE_PACKAGE_TYPE', d) == 'tar': move_tarball_deploy(d,[source_tar_name,patch_tar_name]) - else: + else: # srpm tarpackage = os.path.join(d.getVar('WORKDIR', True),'tar-package') if os.path.exists(tarpackage): os.remove(tarpackage)
@@ -317,7 +315,7 @@ def archive_scripts_logs(d): work_dir = d.getVar('WORKDIR', True) temp_dir = os.path.join(work_dir,'temp') - source_archive_log_with_scripts = d.getVar('SOURCE_ARCHIVE_LOG_WITH_SCRIPTS', True) + source_archive_log_with_scripts = oe.data.typed_value('SOURCE_ARCHIVE_LOG_WITH_SCRIPTS', d) if source_archive_log_with_scripts == 'logs_with_scripts': logdir = get_bb_inc(d) tarlog = archive_logs(d,logdir,True)
@@ -326,10 +324,9 @@ def archive_scripts_logs(d): tarlog = archive_logs(d,temp_dir,False) else: return - - if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() not in 'SRPM': - move_tarball_deploy(d,[tarlog]) + if oe.data.typed_value('SOURCE_ARCHIVE_PACKAGE_TYPE', d) == 'tar': + move_tarball_deploy(d,[tarlog]) else: store_package(d,tarlog)
@@ -427,14 +424,14 @@ python do_archive_linux_yocto(){ s = d.getVar('S', True) if 'linux-yocto' in s: source_tar_name = archive_sources(d,'') - if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() not in 'SRPM': + if oe.data.typed_value('SOURCE_ARCHIVE_PACKAGE_TYPE', d) == 'tar': move_tarball_deploy(d,[source_tar_name,'']) } do_kernel_checkout[postfuncs] += "do_archive_linux_yocto " # remove tarball for sources, patches and logs after creating srpm. python do_remove_tarball(){ - if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() == 'SRPM': + if oe.data.typed_value('SOURCE_ARCHIVE_PACKAGE_TYPE', d) == 'srpm': work_dir = d.getVar('WORKDIR', True) try: for file in os.listdir(os.getcwd()):
meta/classes/package_rpm.bbclass +6 -6
@@ -505,19 +505,19 @@ python write_specfile () { # append information for logs and patches to %prep def add_prep(d,spec_files_bottom): - if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) and d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() == 'SRPM': + if oe.data.typed_value('SOURCE_ARCHIVE_PACKAGE_TYPE', d) == 'srpm': spec_files_bottom.append('%%prep -n %s' % d.getVar('PN', True) ) spec_files_bottom.append('%s' % "echo \"include logs and patches, Please check them in SOURCES\"") spec_files_bottom.append('') # get the name of tarball for sources, patches and logs def get_tarballs(d): - if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) and d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() == 'SRPM': + if oe.data.typed_value('SOURCE_ARCHIVE_PACKAGE_TYPE', d) == 'srpm': return get_package(d) # append the name of tarball to key word 'SOURCE' in xxx.spec. def tail_source(d,source_list=[],patch_list=None): - if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) and d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() == 'SRPM': + if oe.data.typed_value('SOURCE_ARCHIVE_PACKAGE_TYPE', d) == 'srpm': source_number = 0 patch_number = 0 for source in source_list:
@@ -956,7 +956,7 @@ python do_package_rpm () { import os def creat_srpm_dir(d): - if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) and d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() == 'SRPM': + if oe.data.typed_value('SOURCE_ARCHIVE_PACKAGE_TYPE', d) == 'srpm': clean_licenses = get_licenses(d) pkgwritesrpmdir = bb.data.expand('${PKGWRITEDIRSRPM}/${PACKAGE_ARCH_EXTEND}', d) pkgwritesrpmdir = pkgwritesrpmdir + '/' + clean_licenses
@@ -1083,13 +1083,13 @@ python do_package_rpm () { cmd = cmd + " --define 'debug_package %{nil}'" cmd = cmd + " --define '_rpmfc_magic_path " + magicfile + "'" cmd = cmd + " --define '_tmppath " + workdir + "'" - if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) and d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() == 'SRPM': + if oe.data.typed_value('SOURCE_ARCHIVE_PACKAGE_TYPE', d) == 'srpm': cmdsrpm = cmd + " --define '_sourcedir " + workdir + "' --define '_srcrpmdir " + creat_srpm_dir(d) + "'" cmdsrpm = 'fakeroot ' + cmdsrpm + " -bs " + outspecfile cmd = cmd + " -bb " + outspecfile # Build the source rpm package ! - if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) and d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() == 'SRPM': + if oe.data.typed_value('SOURCE_ARCHIVE_PACKAGE_TYPE', d) == 'srpm': d.setVar('SBUILDSPEC', cmdsrpm + "\n") d.setVarFlag('SBUILDSPEC', 'func', '1') bb.build.exec_func('SBUILDSPEC', d)
Signature · 1 line
1.7.7
Re: [PATCH 2/2] archiver.bbclass: leverage variable typing support
Quoted 31 lines · Christopher Larson
From: Christopher Larson<[email protected]>
This makes use of variable typing to avoid reinventing the wheel in that way and adds default values for a couple of said variables. It also changes
PATCHES_ARCHIVE_WITH_SERIESto use ?= rather than =.Further, doing this fixes a single bug that occurs in many places:
if
d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() not in 'SRPM':This is performing a substring search. It should have done "== 'SRPM'"", or if there *were* multiple options for that case (there aren't), it would do "not in ['SRPM']" or similar.
Signed-off-by Christopher Larson<[email protected]>--- meta/classes/archiver.bbclass | 45 +++++++++++++++++-------------------- meta/classes/package_rpm.bbclass | 12 +++++----- 2 files changed, 27 insertions(+), 30 deletions(-)meta/classes/archiver.bbclass +0
-2@@ -2,10 +2,19 @@ # It also output building environment to xxx.dump.data and create xxx.diff.gz to record # all content in ${S} to a diff file. -ARCHIVE_EXCLUDE_FROM ?= ".pc autom4te.cache" -ARCHIVE_TYPE ?= "TAR SRPM" DISTRO ?= "poky"
meta/classes/archiver.bbclass line 14
Quoted 10 lines
meta/classes/archiver.bbclass +9
-1-PATCHES_ARCHIVE_WITH_SERIES = 'TRUE' +ARCHIVE_EXCLUDE_FROM ?= ".pc autom4te.cache" + +PATCHES_ARCHIVE_WITH_SERIES ?= "true" +PATCHES_ARCHIVE_WITH_SERIES[type] = "boolean" + +SOURCE_ARCHIVE_PACKAGE_TYPE ?= "tar" +SOURCE_ARCHIVE_PACKAGE_TYPE[type] = "choice" +SOURCE_ARCHIVE_PACKAGE_TYPE[choices] = "tar srpm" +
Great patch! But:
Moving this here results in the following error if archiver.bbclass is not inherit'ed by default!
ERROR: SOURCE_ARCHIVE_PACKAGE_TYPE: No type specified. Valid types: regex, float, list, choice, boolean, integer
Sau!
Quoted 141 lines
meta/classes/archiver.bbclass +12
-21+SOURCE_ARCHIVE_LOG_WITH_SCRIPTS ?= "logs_with_scripts" +SOURCE_ARCHIVE_LOG_WITH_SCRIPTS[type] = "choice" +SOURCE_ARCHIVE_LOG_WITH_SCRIPTS[choices] = "none logs logs_with_scripts" def get_bb_inc(d): '''create a directory "script-logs" including .bb and .inc file in ${WORKDIR}'''@@ -253,14 +262,6 @@ def move_tarball_deploy(d,tarball_list): os.remove(os.path.join(tar_sources,source)) shutil.move(os.path.join(work_dir,source),tar_sources) -def check_archiving_type(d): - '''check the type for archiving package('tar' or 'srpm')''' - try: - if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() not in d.getVar('ARCHIVE_TYPE', True).split(): - raise AttributeError - except AttributeError: - bb.fatal("\"SOURCE_ARCHIVE_PACKAGE_TYPE\" is \'tar\' or \'srpm\', no other types") - def store_package(d,package_name): '''store tarbablls name to file "tar-package"''' try:@@ -287,24 +288,21 @@ def archive_sources_patches(d,stage_name): '''archive sources and patches to tarball. stage_name will append strings ${stage_name} to ${PR} as middle name. for example, zlib-1.4.6-prepatch(stage_name).tar.gz ''' import shutil - check_archiving_type(d) if not_tarball(d): return source_tar_name = archive_sources(d,stage_name) if stage_name == "prepatch": - if d.getVar('PATCHES_ARCHIVE_WITH_SERIES',True).upper() == 'TRUE': + if oe.data.typed_value('PATCHES_ARCHIVE_WITH_SERIES', d): patch_tar_name = select_archive_patches(d,"all") - elif d.getVar('PATCHES_ARCHIVE_WITH_SERIES',True).upper() == 'FALSE': - patch_tar_name = select_archive_patches(d,"applying") else: - bb.fatal("Please define 'PATCHES_ARCHIVE_WITH_SERIES' is strings 'True' or 'False' ") + patch_tar_name = select_archive_patches(d,"applying") else: patch_tar_name = '' - if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() not in 'SRPM': + if oe.data.typed_value('SOURCE_ARCHIVE_PACKAGE_TYPE', d) == 'tar': move_tarball_deploy(d,[source_tar_name,patch_tar_name]) - else: + else: # srpm tarpackage = os.path.join(d.getVar('WORKDIR', True),'tar-package') if os.path.exists(tarpackage): os.remove(tarpackage)@@ -317,7 +315,7 @@ def archive_scripts_logs(d): work_dir = d.getVar('WORKDIR', True) temp_dir = os.path.join(work_dir,'temp') - source_archive_log_with_scripts = d.getVar('SOURCE_ARCHIVE_LOG_WITH_SCRIPTS', True) + source_archive_log_with_scripts = oe.data.typed_value('SOURCE_ARCHIVE_LOG_WITH_SCRIPTS', d) if source_archive_log_with_scripts == 'logs_with_scripts': logdir = get_bb_inc(d) tarlog = archive_logs(d,logdir,True)@@ -326,10 +324,9 @@ def archive_scripts_logs(d): tarlog = archive_logs(d,temp_dir,False) else: return - - if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() not in 'SRPM': - move_tarball_deploy(d,[tarlog]) + if oe.data.typed_value('SOURCE_ARCHIVE_PACKAGE_TYPE', d) == 'tar': + move_tarball_deploy(d,[tarlog]) else: store_package(d,tarlog)@@ -427,14 +424,14 @@ python do_archive_linux_yocto(){ s = d.getVar('S', True) if 'linux-yocto' in s: source_tar_name = archive_sources(d,'') - if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() not in 'SRPM': + if oe.data.typed_value('SOURCE_ARCHIVE_PACKAGE_TYPE', d) == 'tar': move_tarball_deploy(d,[source_tar_name,'']) } do_kernel_checkout[postfuncs] += "do_archive_linux_yocto " # remove tarball for sources, patches and logs after creating srpm. python do_remove_tarball(){ - if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() == 'SRPM': + if oe.data.typed_value('SOURCE_ARCHIVE_PACKAGE_TYPE', d) == 'srpm': work_dir = d.getVar('WORKDIR', True) try: for file in os.listdir(os.getcwd()):meta/classes/package_rpm.bbclass +6
-6@@ -505,19 +505,19 @@ python write_specfile () { # append information for logs and patches to %prep def add_prep(d,spec_files_bottom): - if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) and d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() == 'SRPM': + if oe.data.typed_value('SOURCE_ARCHIVE_PACKAGE_TYPE', d) == 'srpm': spec_files_bottom.append('%%prep -n %s' % d.getVar('PN', True) ) spec_files_bottom.append('%s' % "echo \"include logs and patches, Please check them in SOURCES\"") spec_files_bottom.append('') # get the name of tarball for sources, patches and logs def get_tarballs(d): - if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) and d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() == 'SRPM': + if oe.data.typed_value('SOURCE_ARCHIVE_PACKAGE_TYPE', d) == 'srpm': return get_package(d) # append the name of tarball to key word 'SOURCE' in xxx.spec. def tail_source(d,source_list=[],patch_list=None): - if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) and d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() == 'SRPM': + if oe.data.typed_value('SOURCE_ARCHIVE_PACKAGE_TYPE', d) == 'srpm': source_number = 0 patch_number = 0 for source in source_list:@@ -956,7 +956,7 @@ python do_package_rpm () { import os def creat_srpm_dir(d): - if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) and d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() == 'SRPM': + if oe.data.typed_value('SOURCE_ARCHIVE_PACKAGE_TYPE', d) == 'srpm': clean_licenses = get_licenses(d) pkgwritesrpmdir = bb.data.expand('${PKGWRITEDIRSRPM}/${PACKAGE_ARCH_EXTEND}', d) pkgwritesrpmdir = pkgwritesrpmdir + '/' + clean_licenses@@ -1083,13 +1083,13 @@ python do_package_rpm () { cmd = cmd + " --define 'debug_package %{nil}'" cmd = cmd + " --define '_rpmfc_magic_path " + magicfile + "'" cmd = cmd + " --define '_tmppath " + workdir + "'" - if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) and d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() == 'SRPM': + if oe.data.typed_value('SOURCE_ARCHIVE_PACKAGE_TYPE', d) == 'srpm': cmdsrpm = cmd + " --define '_sourcedir " + workdir + "' --define '_srcrpmdir " + creat_srpm_dir(d) + "'" cmdsrpm = 'fakeroot ' + cmdsrpm + " -bs " + outspecfile cmd = cmd + " -bb " + outspecfile # Build the source rpm package ! - if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) and d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() == 'SRPM': + if oe.data.typed_value('SOURCE_ARCHIVE_PACKAGE_TYPE', d) == 'srpm': d.setVar('SBUILDSPEC', cmdsrpm + "\n") d.setVarFlag('SBUILDSPEC', 'func', '1') bb.build.exec_func('SBUILDSPEC', d)
Re: [PATCH 2/2] archiver.bbclass: leverage variable typing support
Quoted 53 lines · Saul Wold
Quoted 38 lines · Christopher Larson
From: Christopher Larson<[email protected]>
This makes use of variable typing to avoid reinventing the wheel in that way
and adds default values for a couple of said variables. It also changesPATCHES_ARCHIVE_WITH_SERIESto use ?= rather than =.Further, doing this fixes a single bug that occurs in many places:
if
d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() not in 'SRPM':This is performing a substring search. It should have done "== 'SRPM'"", or if
there *were* multiple options for that case (there aren't), it would do "not
in ['SRPM']" or similar.Signed-off-by Christopher Larson<[email protected]>---
meta/classes/archiver.bbclass | 45
+++++++++++++++++--------------------
meta/classes/package_rpm.bbclass | 12 +++++-----2 files changed, 27 insertions(+), 30 deletions(-)meta/classes/archiver.bbclass +0
-0@@ -2,10 +2,19 @@ # It also output building environment to xxx.dump.data and createxxx.diff.gz to record
# all content in ${S} to a diff file.meta/classes/archiver.bbclass +0
-2-ARCHIVE_EXCLUDE_FROM ?= ".pc autom4te.cache" -ARCHIVE_TYPE ?= "TAR SRPM"DISTRO ?= "poky"
meta/classes/archiver.bbclass line 14
Quoted 10 lines
meta/classes/archiver.bbclass +9
-1-PATCHES_ARCHIVE_WITH_SERIES = 'TRUE' +ARCHIVE_EXCLUDE_FROM ?= ".pc autom4te.cache" + +PATCHES_ARCHIVE_WITH_SERIES ?= "true" +PATCHES_ARCHIVE_WITH_SERIES[type] = "boolean" + +SOURCE_ARCHIVE_PACKAGE_TYPE ?= "tar" +SOURCE_ARCHIVE_PACKAGE_TYPE[type] = "choice" +SOURCE_ARCHIVE_PACKAGE_TYPE[choices] = "tar srpm" +Great patch! But:
Quoted 5 lines
Moving this here results in the following error if archiver.bbclass is not inherit'ed by default!
ERROR:
SOURCE_ARCHIVE_PACKAGE_TYPE: No type specified. Valid types: regex, float, list, choice, boolean, integer
Ah! Doh, I didn't think about that -- we really need to fix the package_rpm code there to not depend on archiver.bbclass specifics. I'll rework the patch. Thanks.
Signature · 1 line
Christopher Larson
Quoted 12 lines · Christopher Larson
From: Christopher Larson<[email protected]>
Signed-off-by Christopher Larson<[email protected]>--- meta/classes/typecheck.bbclass | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)meta/classes/typecheck.bbclass +0
-0
meta/classes/typecheck.bbclass python check_types() { · line 12
Quoted 7 lines
meta/classes/typecheck.bbclass +1
-1@@ -7,6 +7,6 @@ python check_types() { if isinstance(e, bb.event.ConfigParsed): for key in e.data.keys(): if e.data.getVarFlag(key, "type"): - oe.types.value(key, e.data) + oe.data.typed_value(key, e.data) } addhandler check_types
Merged this into OE-Core
Thanks
Sau!