@@ -59,6 +59,7 @@ import (
59
59
"github.com/cespare/cp"
60
60
"github.com/ethereum/go-ethereum/crypto/signify"
61
61
"github.com/ethereum/go-ethereum/internal/build"
62
+ "github.com/ethereum/go-ethereum/internal/download"
62
63
"github.com/ethereum/go-ethereum/internal/version"
63
64
)
64
65
@@ -190,7 +191,7 @@ func doInstall(cmdline []string) {
190
191
// Configure the toolchain.
191
192
tc := build.GoToolchain {GOARCH : * arch , CC : * cc }
192
193
if * dlgo {
193
- csdb := build .MustLoadChecksums ("build/checksums.txt" )
194
+ csdb := download .MustLoadChecksums ("build/checksums.txt" )
194
195
tc .Root = build .DownloadGo (csdb )
195
196
}
196
197
// Disable CLI markdown doc generation in release builds.
@@ -285,7 +286,7 @@ func doTest(cmdline []string) {
285
286
flag .CommandLine .Parse (cmdline )
286
287
287
288
// Get test fixtures.
288
- csdb := build .MustLoadChecksums ("build/checksums.txt" )
289
+ csdb := download .MustLoadChecksums ("build/checksums.txt" )
289
290
downloadSpecTestFixtures (csdb , * cachedir )
290
291
291
292
// Configure the toolchain.
@@ -329,16 +330,11 @@ func doTest(cmdline []string) {
329
330
}
330
331
331
332
// downloadSpecTestFixtures downloads and extracts the execution-spec-tests fixtures.
332
- func downloadSpecTestFixtures (csdb * build.ChecksumDB , cachedir string ) string {
333
- executionSpecTestsVersion , err := build .Version (csdb , "spec-tests" )
334
- if err != nil {
335
- log .Fatal (err )
336
- }
333
+ func downloadSpecTestFixtures (csdb * download.ChecksumDB , cachedir string ) string {
337
334
ext := ".tar.gz"
338
335
base := "fixtures_pectra-devnet-6" // TODO(s1na) rename once the version becomes part of the filename
339
- url := fmt .Sprintf ("https://github.com/ethereum/execution-spec-tests/releases/download/%s/%s%s" , executionSpecTestsVersion , base , ext )
340
336
archivePath := filepath .Join (cachedir , base + ext )
341
- if err := csdb .DownloadFile ( url , archivePath ); err != nil {
337
+ if err := csdb .DownloadFileFromKnownURL ( archivePath ); err != nil {
342
338
log .Fatal (err )
343
339
}
344
340
if err := build .ExtractArchive (archivePath , executionSpecTestsDir ); err != nil {
@@ -444,24 +440,22 @@ func doLint(cmdline []string) {
444
440
445
441
// downloadLinter downloads and unpacks golangci-lint.
446
442
func downloadLinter (cachedir string ) string {
447
- csdb := build .MustLoadChecksums ("build/checksums.txt" )
448
- version , err := build . Version ( csdb , "golangci" )
443
+ csdb := download .MustLoadChecksums ("build/checksums.txt" )
444
+ version , err := csdb . FindVersion ( "golangci" )
449
445
if err != nil {
450
446
log .Fatal (err )
451
447
}
452
448
arch := runtime .GOARCH
453
449
ext := ".tar.gz"
454
-
455
450
if runtime .GOOS == "windows" {
456
451
ext = ".zip"
457
452
}
458
453
if arch == "arm" {
459
454
arch += "v" + os .Getenv ("GOARM" )
460
455
}
461
456
base := fmt .Sprintf ("golangci-lint-%s-%s-%s" , version , runtime .GOOS , arch )
462
- url := fmt .Sprintf ("https://github.com/golangci/golangci-lint/releases/download/v%s/%s%s" , version , base , ext )
463
457
archivePath := filepath .Join (cachedir , base + ext )
464
- if err := csdb .DownloadFile ( url , archivePath ); err != nil {
458
+ if err := csdb .DownloadFileFromKnownURL ( archivePath ); err != nil {
465
459
log .Fatal (err )
466
460
}
467
461
if err := build .ExtractArchive (archivePath , cachedir ); err != nil {
@@ -497,8 +491,8 @@ func protocArchiveBaseName() (string, error) {
497
491
// in the generate command. It returns the full path of the directory
498
492
// containing the 'protoc-gen-go' executable.
499
493
func downloadProtocGenGo (cachedir string ) string {
500
- csdb := build .MustLoadChecksums ("build/checksums.txt" )
501
- version , err := build . Version ( csdb , "protoc-gen-go" )
494
+ csdb := download .MustLoadChecksums ("build/checksums.txt" )
495
+ version , err := csdb . FindVersion ( "protoc-gen-go" )
502
496
if err != nil {
503
497
log .Fatal (err )
504
498
}
@@ -510,10 +504,8 @@ func downloadProtocGenGo(cachedir string) string {
510
504
archiveName += ".tar.gz"
511
505
}
512
506
513
- url := fmt .Sprintf ("https://github.com/protocolbuffers/protobuf-go/releases/download/v%s/%s" , version , archiveName )
514
-
515
507
archivePath := path .Join (cachedir , archiveName )
516
- if err := csdb .DownloadFile ( url , archivePath ); err != nil {
508
+ if err := csdb .DownloadFileFromKnownURL ( archivePath ); err != nil {
517
509
log .Fatal (err )
518
510
}
519
511
extractDest := filepath .Join (cachedir , baseName )
@@ -531,8 +523,8 @@ func downloadProtocGenGo(cachedir string) string {
531
523
// files as a CI step. It returns the full path to the directory containing
532
524
// the protoc executable.
533
525
func downloadProtoc (cachedir string ) string {
534
- csdb := build .MustLoadChecksums ("build/checksums.txt" )
535
- version , err := build . Version ( csdb , "protoc" )
526
+ csdb := download .MustLoadChecksums ("build/checksums.txt" )
527
+ version , err := csdb . FindVersion ( "protoc" )
536
528
if err != nil {
537
529
log .Fatal (err )
538
530
}
@@ -543,10 +535,8 @@ func downloadProtoc(cachedir string) string {
543
535
544
536
fileName := fmt .Sprintf ("protoc-%s-%s" , version , baseName )
545
537
archiveFileName := fileName + ".zip"
546
- url := fmt .Sprintf ("https://github.com/protocolbuffers/protobuf/releases/download/v%s/%s" , version , archiveFileName )
547
538
archivePath := filepath .Join (cachedir , archiveFileName )
548
-
549
- if err := csdb .DownloadFile (url , archivePath ); err != nil {
539
+ if err := csdb .DownloadFileFromKnownURL (archivePath ); err != nil {
550
540
log .Fatal (err )
551
541
}
552
542
extractDest := filepath .Join (cachedir , fileName )
@@ -826,18 +816,17 @@ func doDebianSource(cmdline []string) {
826
816
// downloadGoBootstrapSources downloads the Go source tarball(s) that will be used
827
817
// to bootstrap the builder Go.
828
818
func downloadGoBootstrapSources (cachedir string ) []string {
829
- csdb := build .MustLoadChecksums ("build/checksums.txt" )
819
+ csdb := download .MustLoadChecksums ("build/checksums.txt" )
830
820
831
821
var bundles []string
832
822
for _ , booter := range []string {"ppa-builder-1.19" , "ppa-builder-1.21" , "ppa-builder-1.23" } {
833
- gobootVersion , err := build . Version ( csdb , booter )
823
+ gobootVersion , err := csdb . FindVersion ( booter )
834
824
if err != nil {
835
825
log .Fatal (err )
836
826
}
837
827
file := fmt .Sprintf ("go%s.src.tar.gz" , gobootVersion )
838
- url := "https://dl.google.com/go/" + file
839
828
dst := filepath .Join (cachedir , file )
840
- if err := csdb .DownloadFile ( url , dst ); err != nil {
829
+ if err := csdb .DownloadFileFromKnownURL ( dst ); err != nil {
841
830
log .Fatal (err )
842
831
}
843
832
bundles = append (bundles , dst )
@@ -847,15 +836,14 @@ func downloadGoBootstrapSources(cachedir string) []string {
847
836
848
837
// downloadGoSources downloads the Go source tarball.
849
838
func downloadGoSources (cachedir string ) string {
850
- csdb := build .MustLoadChecksums ("build/checksums.txt" )
851
- dlgoVersion , err := build . Version ( csdb , "golang" )
839
+ csdb := download .MustLoadChecksums ("build/checksums.txt" )
840
+ dlgoVersion , err := csdb . FindVersion ( "golang" )
852
841
if err != nil {
853
842
log .Fatal (err )
854
843
}
855
844
file := fmt .Sprintf ("go%s.src.tar.gz" , dlgoVersion )
856
- url := "https://dl.google.com/go/" + file
857
845
dst := filepath .Join (cachedir , file )
858
- if err := csdb .DownloadFile ( url , dst ); err != nil {
846
+ if err := csdb .DownloadFileFromKnownURL ( dst ); err != nil {
859
847
log .Fatal (err )
860
848
}
861
849
return dst
@@ -1181,5 +1169,6 @@ func doPurge(cmdline []string) {
1181
1169
}
1182
1170
1183
1171
func doSanityCheck () {
1184
- build .DownloadAndVerifyChecksums (build .MustLoadChecksums ("build/checksums.txt" ))
1172
+ csdb := download .MustLoadChecksums ("build/checksums.txt" )
1173
+ csdb .DownloadAndVerifyAll ()
1185
1174
}
0 commit comments