@@ -59,6 +59,7 @@ import (
5959 "github.com/cespare/cp"
6060 "github.com/ethereum/go-ethereum/crypto/signify"
6161 "github.com/ethereum/go-ethereum/internal/build"
62+ "github.com/ethereum/go-ethereum/internal/download"
6263 "github.com/ethereum/go-ethereum/internal/version"
6364)
6465
@@ -190,7 +191,7 @@ func doInstall(cmdline []string) {
190191 // Configure the toolchain.
191192 tc := build.GoToolchain {GOARCH : * arch , CC : * cc }
192193 if * dlgo {
193- csdb := build .MustLoadChecksums ("build/checksums.txt" )
194+ csdb := download .MustLoadChecksums ("build/checksums.txt" )
194195 tc .Root = build .DownloadGo (csdb )
195196 }
196197 // Disable CLI markdown doc generation in release builds.
@@ -285,7 +286,7 @@ func doTest(cmdline []string) {
285286 flag .CommandLine .Parse (cmdline )
286287
287288 // Get test fixtures.
288- csdb := build .MustLoadChecksums ("build/checksums.txt" )
289+ csdb := download .MustLoadChecksums ("build/checksums.txt" )
289290 downloadSpecTestFixtures (csdb , * cachedir )
290291
291292 // Configure the toolchain.
@@ -329,16 +330,11 @@ func doTest(cmdline []string) {
329330}
330331
331332// 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 {
337334 ext := ".tar.gz"
338335 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 )
340336 archivePath := filepath .Join (cachedir , base + ext )
341- if err := csdb .DownloadFile ( url , archivePath ); err != nil {
337+ if err := csdb .DownloadFileFromKnownURL ( archivePath ); err != nil {
342338 log .Fatal (err )
343339 }
344340 if err := build .ExtractArchive (archivePath , executionSpecTestsDir ); err != nil {
@@ -444,24 +440,22 @@ func doLint(cmdline []string) {
444440
445441// downloadLinter downloads and unpacks golangci-lint.
446442func 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" )
449445 if err != nil {
450446 log .Fatal (err )
451447 }
452448 arch := runtime .GOARCH
453449 ext := ".tar.gz"
454-
455450 if runtime .GOOS == "windows" {
456451 ext = ".zip"
457452 }
458453 if arch == "arm" {
459454 arch += "v" + os .Getenv ("GOARM" )
460455 }
461456 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 )
463457 archivePath := filepath .Join (cachedir , base + ext )
464- if err := csdb .DownloadFile ( url , archivePath ); err != nil {
458+ if err := csdb .DownloadFileFromKnownURL ( archivePath ); err != nil {
465459 log .Fatal (err )
466460 }
467461 if err := build .ExtractArchive (archivePath , cachedir ); err != nil {
@@ -497,8 +491,8 @@ func protocArchiveBaseName() (string, error) {
497491// in the generate command. It returns the full path of the directory
498492// containing the 'protoc-gen-go' executable.
499493func 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" )
502496 if err != nil {
503497 log .Fatal (err )
504498 }
@@ -510,10 +504,8 @@ func downloadProtocGenGo(cachedir string) string {
510504 archiveName += ".tar.gz"
511505 }
512506
513- url := fmt .Sprintf ("https://github.com/protocolbuffers/protobuf-go/releases/download/v%s/%s" , version , archiveName )
514-
515507 archivePath := path .Join (cachedir , archiveName )
516- if err := csdb .DownloadFile ( url , archivePath ); err != nil {
508+ if err := csdb .DownloadFileFromKnownURL ( archivePath ); err != nil {
517509 log .Fatal (err )
518510 }
519511 extractDest := filepath .Join (cachedir , baseName )
@@ -531,8 +523,8 @@ func downloadProtocGenGo(cachedir string) string {
531523// files as a CI step. It returns the full path to the directory containing
532524// the protoc executable.
533525func 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" )
536528 if err != nil {
537529 log .Fatal (err )
538530 }
@@ -543,10 +535,8 @@ func downloadProtoc(cachedir string) string {
543535
544536 fileName := fmt .Sprintf ("protoc-%s-%s" , version , baseName )
545537 archiveFileName := fileName + ".zip"
546- url := fmt .Sprintf ("https://github.com/protocolbuffers/protobuf/releases/download/v%s/%s" , version , archiveFileName )
547538 archivePath := filepath .Join (cachedir , archiveFileName )
548-
549- if err := csdb .DownloadFile (url , archivePath ); err != nil {
539+ if err := csdb .DownloadFileFromKnownURL (archivePath ); err != nil {
550540 log .Fatal (err )
551541 }
552542 extractDest := filepath .Join (cachedir , fileName )
@@ -826,18 +816,17 @@ func doDebianSource(cmdline []string) {
826816// downloadGoBootstrapSources downloads the Go source tarball(s) that will be used
827817// to bootstrap the builder Go.
828818func downloadGoBootstrapSources (cachedir string ) []string {
829- csdb := build .MustLoadChecksums ("build/checksums.txt" )
819+ csdb := download .MustLoadChecksums ("build/checksums.txt" )
830820
831821 var bundles []string
832822 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 )
834824 if err != nil {
835825 log .Fatal (err )
836826 }
837827 file := fmt .Sprintf ("go%s.src.tar.gz" , gobootVersion )
838- url := "https://dl.google.com/go/" + file
839828 dst := filepath .Join (cachedir , file )
840- if err := csdb .DownloadFile ( url , dst ); err != nil {
829+ if err := csdb .DownloadFileFromKnownURL ( dst ); err != nil {
841830 log .Fatal (err )
842831 }
843832 bundles = append (bundles , dst )
@@ -847,15 +836,14 @@ func downloadGoBootstrapSources(cachedir string) []string {
847836
848837// downloadGoSources downloads the Go source tarball.
849838func 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" )
852841 if err != nil {
853842 log .Fatal (err )
854843 }
855844 file := fmt .Sprintf ("go%s.src.tar.gz" , dlgoVersion )
856- url := "https://dl.google.com/go/" + file
857845 dst := filepath .Join (cachedir , file )
858- if err := csdb .DownloadFile ( url , dst ); err != nil {
846+ if err := csdb .DownloadFileFromKnownURL ( dst ); err != nil {
859847 log .Fatal (err )
860848 }
861849 return dst
@@ -1181,5 +1169,6 @@ func doPurge(cmdline []string) {
11811169}
11821170
11831171func doSanityCheck () {
1184- build .DownloadAndVerifyChecksums (build .MustLoadChecksums ("build/checksums.txt" ))
1172+ csdb := download .MustLoadChecksums ("build/checksums.txt" )
1173+ csdb .DownloadAndVerifyAll ()
11851174}
0 commit comments