add support for 'eb --inject-checksums'#2286
Conversation
…sources/patches specs
|
|
||
| # back up easyconfig file before injecting checksums | ||
| ectxt = read_file(ec['spec']) | ||
| ec_backup = os.path.join(ec['spec'] + '.bck') |
There was a problem hiding this comment.
isn't bak the generally accepted suffix?
There was a problem hiding this comment.
I'm not sure there's a generally accepted standard... See https://fileinfo.com/filetypes/backup
| checksums_txt = '\n'.join(checksum_lines) | ||
|
|
||
| if app.cfg['checksums']: | ||
| regex = re.compile(r'^checksums(?:.|\n)*?\]\s*$', re.M) |
There was a problem hiding this comment.
unless you're going to use it in many places, there is no point in compiling first?
There was a problem hiding this comment.
and shouldn't it be +? instead of *??
There was a problem hiding this comment.
Actually, there is a technical reason for splitting this up with re.compile: using re.M in re.sub requires Python 2.7... (see also 4f41328)
| if app.cfg['checksums']: | ||
| regex = re.compile(r'^checksums(?:.|\n)*?\]\s*$', re.M) | ||
| ectxt = regex.sub(checksums_txt, ectxt) | ||
| elif app.src: |
There was a problem hiding this comment.
no, it's possible there are no sources, and hence no patches/checksums
for example: bundles, like intel-2017a.eb easyconfig
| else: | ||
| checksum_lines = ['checksums = ['] | ||
| for fn, checksum in checksums: | ||
| checksum_lines.append(" '%s', # %s" % (checksum, fn)) |
There was a problem hiding this comment.
below you do: ' ' * 4, be consistent.
There was a problem hiding this comment.
I'll use INDENT_4SPACES consistently instead...
| 'choice', 'store_or_None', CHECKSUM_TYPE_SHA256, CHECKSUM_TYPES), | ||
| }) | ||
| self.log.debug("easyconfig_options: descr %s opts %s" % (descr, opts)) | ||
| self.add_group_parser(opts, descr, prefix='easyconfig') |
There was a problem hiding this comment.
Otherwise the option would be --easyconfig-inject-checksums, which is overkill imho.
There were no options in this category yet, so this change is fine.
|
|
||
| if ext.keys() == ['name']: | ||
| exts_list_lines.append("%s'%s'," % (' ' * 4, ext['name'])) | ||
|
|
…d needless re.compile
…M in re.sub requires Python 2.7
|
@wpoely86 remarks fixed, please rereview? |
|
|
||
| # back up easyconfig file before injecting checksums | ||
| ectxt = read_file(ec['spec']) | ||
| ec_backup = os.path.join(ec['spec'] + '.bck') |
| if app.cfg['checksums']: | ||
| regex = re.compile(r'^checksums(?:.|\n)*?\]\s*$', re.M) | ||
| ectxt = regex.sub(checksums_txt, ectxt) | ||
| elif app.src: |
checksumsandexts_listeasyconfig parameter to be injected into easyconfig filechecksumsunder--forceexts_listwith value that includes checksumschecksumsin easyconfig file where no checksums are provided yetmake checksum type required parameter--inject-checksumsaccidentally tries to consume an easyconfig filename thanks tochoiceoption type)--inject-checksums