@@ -502,6 +502,8 @@ def fetch_extension_sources(self, skip_checksums=False):
502502 if self .dry_run :
503503 self .dry_run_msg ("\n List of sources/patches for extensions:" )
504504
505+ force_download = build_option ('force_download' ) in [FORCE_DOWNLOAD_ALL , FORCE_DOWNLOAD_SOURCES ]
506+
505507 for ext in exts_list :
506508 if (isinstance (ext , list ) or isinstance (ext , tuple )) and ext :
507509
@@ -539,18 +541,17 @@ def fetch_extension_sources(self, skip_checksums=False):
539541 # resolve templates in extension options
540542 ext_options = resolve_template (ext_options , template_values )
541543
544+ source_urls = ext_options .get ('source_urls' , [])
542545 checksums = ext_options .get ('checksums' , [])
543546
544- # use default template for name of source file if none is specified
545- default_source_tmpl = resolve_template ('%(name)s-%(version)s.tar.gz' , template_values )
546- fn = ext_options .get ('source_tmpl' , default_source_tmpl )
547-
548547 if ext_options .get ('nosource' , None ):
549- exts_sources . append ( ext_src )
548+ self . log . debug ( "No sources for extension %s, as indicated by 'nosource'" , ext_name )
550549
551550 elif ext_options .get ('sources' , None ):
552551 sources = ext_options ['sources' ]
553552
553+ # only a single source file is supported for extensions currently,
554+ # see https://github.com/easybuilders/easybuild-framework/issues/3463
554555 if isinstance (sources , list ):
555556 if len (sources ) == 1 :
556557 source = sources [0 ]
@@ -560,67 +561,90 @@ def fetch_extension_sources(self, skip_checksums=False):
560561 else :
561562 source = sources
562563
564+ # always pass source spec as dict value to fetch_source method,
565+ # mostly so we can inject stuff like source URLs
566+ if isinstance (source , string_type ):
567+ source = {'filename' : source }
568+ elif not isinstance (source , dict ):
569+ raise EasyBuildError ("Incorrect value type for source of extension %s: %s" ,
570+ ext_name , source )
571+
572+ # if no custom source URLs are specified in sources spec,
573+ # inject the ones specified for this extension
574+ if 'source_urls' not in source :
575+ source ['source_urls' ] = source_urls
576+
563577 src = self .fetch_source (source , checksums , extension = True )
564- # Copy 'path' entry to 'src' for use with extensions
565- ext_src .update ({'src' : src ['path' ]})
566- exts_sources .append (ext_src )
567- else :
568- source_urls = ext_options .get ('source_urls' , [])
569- force_download = build_option ('force_download' ) in [FORCE_DOWNLOAD_ALL , FORCE_DOWNLOAD_SOURCES ]
570578
571- src_fn = self .obtain_file (fn , extension = True , urls = source_urls , force_download = force_download )
579+ # copy 'path' entry to 'src' for use with extensions
580+ ext_src .update ({'src' : src ['path' ]})
572581
573- if src_fn :
574- ext_src .update ({'src' : src_fn })
582+ else :
583+ # use default template for name of source file if none is specified
584+ default_source_tmpl = resolve_template ('%(name)s-%(version)s.tar.gz' , template_values )
585+
586+ # if no sources are specified via 'sources', fall back to 'source_tmpl'
587+ src_fn = ext_options .get ('source_tmpl' , default_source_tmpl )
588+ src_path = self .obtain_file (src_fn , extension = True , urls = source_urls ,
589+ force_download = force_download )
590+ if src_path :
591+ ext_src .update ({'src' : src_path })
592+ else :
593+ raise EasyBuildError ("Source for extension %s not found." , ext )
575594
576- if not skip_checksums :
577- # report both MD5 and SHA256 checksums, since both are valid default checksum types
595+ # verify checksum for extension sources
596+ if 'src' in ext_src and not skip_checksums :
597+ src_path = ext_src ['src' ]
598+ src_fn = os .path .basename (src_path )
599+
600+ # report both MD5 and SHA256 checksums, since both are valid default checksum types
601+ for checksum_type in (CHECKSUM_TYPE_MD5 , CHECKSUM_TYPE_SHA256 ):
602+ src_checksum = compute_checksum (src_path , checksum_type = checksum_type )
603+ self .log .info ("%s checksum for %s: %s" , checksum_type , src_path , src_checksum )
604+
605+ # verify checksum (if provided)
606+ self .log .debug ('Verifying checksums for extension source...' )
607+ fn_checksum = self .get_checksum_for (checksums , index = 0 )
608+ if verify_checksum (src_path , fn_checksum ):
609+ self .log .info ('Checksum for extension source %s verified' , src_fn )
610+ elif build_option ('ignore_checksums' ):
611+ print_warning ("Ignoring failing checksum verification for %s" % src_fn )
612+ else :
613+ raise EasyBuildError ('Checksum verification for extension source %s failed' , src_fn )
614+
615+ # locate extension patches (if any), and verify checksums
616+ ext_patches = self .fetch_patches (patch_specs = ext_options .get ('patches' , []), extension = True )
617+ if ext_patches :
618+ self .log .debug ('Found patches for extension %s: %s' , ext_name , ext_patches )
619+ ext_src .update ({'patches' : ext_patches })
620+
621+ if not skip_checksums :
622+ for patch in ext_patches :
623+ patch = patch ['path' ]
624+ # report both MD5 and SHA256 checksums,
625+ # since both are valid default checksum types
578626 for checksum_type in (CHECKSUM_TYPE_MD5 , CHECKSUM_TYPE_SHA256 ):
579- src_checksum = compute_checksum (src_fn , checksum_type = checksum_type )
580- self .log .info ("%s checksum for %s: %s" , checksum_type , src_fn , src_checksum )
581-
582- # verify checksum (if provided)
583- self .log .debug ('Verifying checksums for extension source...' )
584- fn_checksum = self .get_checksum_for (checksums , index = 0 )
585- if verify_checksum (src_fn , fn_checksum ):
586- self .log .info ('Checksum for extension source %s verified' , fn )
627+ checksum = compute_checksum (patch , checksum_type = checksum_type )
628+ self .log .info ("%s checksum for %s: %s" , checksum_type , patch , checksum )
629+
630+ # verify checksum (if provided)
631+ self .log .debug ('Verifying checksums for extension patches...' )
632+ for idx , patch in enumerate (ext_patches ):
633+ patch = patch ['path' ]
634+ patch_fn = os .path .basename (patch )
635+
636+ checksum = self .get_checksum_for (checksums [1 :], index = idx )
637+ if verify_checksum (patch , checksum ):
638+ self .log .info ('Checksum for extension patch %s verified' , patch_fn )
587639 elif build_option ('ignore_checksums' ):
588- print_warning ("Ignoring failing checksum verification for %s" % fn )
640+ print_warning ("Ignoring failing checksum verification for %s" % patch_fn )
589641 else :
590- raise EasyBuildError ('Checksum verification for extension source %s failed' , fn )
591-
592- ext_patches = self .fetch_patches (patch_specs = ext_options .get ('patches' , []), extension = True )
593- if ext_patches :
594- self .log .debug ('Found patches for extension %s: %s' % (ext_name , ext_patches ))
595- ext_src .update ({'patches' : ext_patches })
596-
597- if not skip_checksums :
598- for patch in ext_patches :
599- patch = patch ['path' ]
600- # report both MD5 and SHA256 checksums,
601- # since both are valid default checksum types
602- for checksum_type in (CHECKSUM_TYPE_MD5 , CHECKSUM_TYPE_SHA256 ):
603- checksum = compute_checksum (patch , checksum_type = checksum_type )
604- self .log .info ("%s checksum for %s: %s" , checksum_type , patch , checksum )
605-
606- # verify checksum (if provided)
607- self .log .debug ('Verifying checksums for extension patches...' )
608- for idx , patch in enumerate (ext_patches ):
609- patch = patch ['path' ]
610- checksum = self .get_checksum_for (checksums [1 :], index = idx )
611- if verify_checksum (patch , checksum ):
612- self .log .info ('Checksum for extension patch %s verified' , patch )
613- elif build_option ('ignore_checksums' ):
614- print_warning ("Ignoring failing checksum verification for %s" % patch )
615- else :
616- raise EasyBuildError ('Checksum for extension patch %s failed' , patch )
617- else :
618- self .log .debug ('No patches found for extension %s.' % ext_name )
619-
620- exts_sources .append (ext_src )
642+ raise EasyBuildError ("Checksum verification for extension patch %s failed" ,
643+ patch_fn )
644+ else :
645+ self .log .debug ('No patches found for extension %s.' % ext_name )
621646
622- else :
623- raise EasyBuildError ("Source for extension %s not found." , ext )
647+ exts_sources .append (ext_src )
624648
625649 elif isinstance (ext , string_type ):
626650 exts_sources .append ({'name' : ext })
0 commit comments