Skip to content

add support for 'eb --inject-checksums'#2286

Merged
wpoely86 merged 18 commits intoeasybuilders:developfrom
boegel:inject_checksums
Aug 26, 2017
Merged

add support for 'eb --inject-checksums'#2286
wpoely86 merged 18 commits intoeasybuilders:developfrom
boegel:inject_checksums

Conversation

@boegel
Copy link
Copy Markdown
Member

@boegel boegel commented Aug 16, 2017

  • collect checksums for all files/patches, incl. for extensions
  • construct lines for checksums and exts_list easyconfig parameter to be injected into easyconfig file
  • replace existing value for checksums under --force
  • replace existing value for exts_list with value that includes checksums
  • inject checksums in easyconfig file where no checksums are provided yet
  • make checksum type required parameter
    • (not needed, proper error message is printed when --inject-checksums accidentally tries to consume an easyconfig filename thanks to choice option type)
  • add test for --inject-checksums
  • update docs: document --inject-checksums easybuild#369

@boegel boegel added this to the 3.4.0 milestone Aug 16, 2017
@boegel boegel changed the title add support for 'eb --inject-checksums' [WIP] add support for 'eb --inject-checksums' Aug 16, 2017
@boegel boegel requested a review from a team August 16, 2017 20:29
Comment thread easybuild/framework/easyblock.py Outdated

# back up easyconfig file before injecting checksums
ectxt = read_file(ec['spec'])
ec_backup = os.path.join(ec['spec'] + '.bck')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't bak the generally accepted suffix?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure there's a generally accepted standard... See https://fileinfo.com/filetypes/backup

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I would take bak 😉

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to .bak after checking with @damianam, since he chose .bck initially via #2134

Comment thread easybuild/framework/easyblock.py Outdated
checksums_txt = '\n'.join(checksum_lines)

if app.cfg['checksums']:
regex = re.compile(r'^checksums(?:.|\n)*?\]\s*$', re.M)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unless you're going to use it in many places, there is no point in compiling first?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and shouldn't it be +? instead of *??

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good points, fixed

Copy link
Copy Markdown
Member Author

@boegel boegel Aug 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just else?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, it's possible there are no sources, and hence no patches/checksums

for example: bundles, like intel-2017a.eb easyconfig

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: it is

Comment thread easybuild/framework/easyblock.py Outdated
else:
checksum_lines = ['checksums = [']
for fn, checksum in checksums:
checksum_lines.append(" '%s', # %s" % (checksum, fn))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

below you do: ' ' * 4, be consistent.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why change the prefix?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread easybuild/framework/easyblock.py Outdated

if ext.keys() == ['name']:
exts_list_lines.append("%s'%s'," % (' ' * 4, ext['name']))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

less empty lines?

@boegel
Copy link
Copy Markdown
Member Author

boegel commented Aug 21, 2017

@wpoely86 remarks fixed, please rereview?

wpoely86
wpoely86 previously approved these changes Aug 22, 2017
Comment thread easybuild/framework/easyblock.py Outdated

# back up easyconfig file before injecting checksums
ectxt = read_file(ec['spec'])
ec_backup = os.path.join(ec['spec'] + '.bck')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I would take bak 😉

if app.cfg['checksums']:
regex = re.compile(r'^checksums(?:.|\n)*?\]\s*$', re.M)
ectxt = regex.sub(checksums_txt, ectxt)
elif app.src:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: it is

@wpoely86 wpoely86 merged commit 12e9671 into easybuilders:develop Aug 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants