diff --git a/build/bot/macos-build.sh b/build/bot/macos-build.sh deleted file mode 100644 index f1620bca86..0000000000 --- a/build/bot/macos-build.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -set -e -x - -# -- Check XCode version -xcodebuild -version -# xcrun simctl list - -# -- Build for macOS and upload to Azure -go run build/ci.go install -dlgo -go run build/ci.go archive -type tar # -signer OSX_SIGNING_KEY -upload gethstore/builds - -# # -- CocoaPods -# gem uninstall cocoapods -a -x -# gem install cocoapods -# mv ~/.cocoapods/repos/master ~/.cocoapods/repos/master.bak -# sed -i '.bak' 's/repo.join/!repo.join/g' $(dirname `gem which cocoapods`)/cocoapods/sources_manager.rb -# git clone --depth=1 https://github.com/CocoaPods/Specs.git ~/.cocoapods/repos/master -# pod setup --verbose - -# # -- Build for iOS and upload to Azure -# go run build/ci.go xcode -signer IOS_SIGNING_KEY -upload gethstore/builds diff --git a/build/bot/ppa-build.sh b/build/bot/ppa-build.sh deleted file mode 100644 index ca04262a20..0000000000 --- a/build/bot/ppa-build.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -set -e -x - -# Note: this script is meant to be run in a Debian/Ubuntu docker container, -# as user 'root'. - -# Install the required tools for creating source packages. -apt-get -yq --no-install-suggests --no-install-recommends install\ - devscripts debhelper dput fakeroot - -# Add the SSH key of ppa.launchpad.net to known_hosts. -mkdir -p ~/.ssh -echo '|1|7SiYPr9xl3uctzovOTj4gMwAC1M=|t6ReES75Bo/PxlOPJ6/GsGbTrM0= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA0aKz5UTUndYgIGG7dQBV+HaeuEZJ2xPHo2DS2iSKvUL4xNMSAY4UguNW+pX56nAQmZKIZZ8MaEvSj6zMEDiq6HFfn5JcTlM80UwlnyKe8B8p7Nk06PPQLrnmQt5fh0HmEcZx+JU9TZsfCHPnX7MNz4ELfZE6cFsclClrKim3BHUIGq//t93DllB+h4O9LHjEUsQ1Sr63irDLSutkLJD6RXchjROXkNirlcNVHH/jwLWR5RcYilNX7S5bIkK8NlWPjsn/8Ua5O7I9/YoE97PpO6i73DTGLh5H9JN/SITwCKBkgSDWUt61uPK3Y11Gty7o2lWsBjhBUm2Y38CBsoGmBw==' >> ~/.ssh/known_hosts - -# Build the source package and upload. -go run build/ci.go debsrc -upload ethereum/ethereum -sftp-user geth-ci -signer "Go Ethereum Linux Builder " diff --git a/build/checksums.txt b/build/checksums.txt deleted file mode 100644 index 6e43e9cbe0..0000000000 --- a/build/checksums.txt +++ /dev/null @@ -1,58 +0,0 @@ -# This file contains sha256 checksums of optional build dependencies. - -38f423db4cc834883f2b52344282fa7a39fbb93650dc62a11fdf0be6409bdad6 go1.18.src.tar.gz -70bb4a066997535e346c8bfa3e0dfe250d61100b17ccc5676274642447834969 go1.18.darwin-amd64.tar.gz -9cab6123af9ffade905525d79fc9ee76651e716c85f1f215872b5f2976782480 go1.18.darwin-arm64.tar.gz -e63492d4f38487331518eb4b50e670d853bb8d67e88596269af84bb9aca0b381 go1.18.freebsd-386.tar.gz -01cd67bbc12e659ff236ecebde1806f76452f7ca145c172d5ecdbf4f4803daae go1.18.freebsd-amd64.tar.gz -1c04cf4440b323a66328e0df95d409f955b9b475e58eae235fdd3d1f1cf02f4f go1.18.linux-386.tar.gz -e85278e98f57cdb150fe8409e6e5df5343ecb13cebf03a5d5ff12bd55a80264f go1.18.linux-amd64.tar.gz -7ac7b396a691e588c5fb57687759e6c4db84a2a3bbebb0765f4b38e5b1c5b00e go1.18.linux-arm64.tar.gz -a80fa43d1f4575fb030adbfbaa94acd860c6847820764eecb06c63b7c103612b go1.18.linux-armv6l.tar.gz -070351edac192483c074b38d08ec19251a83f8210765a532a84c3dcf8aec04d8 go1.18.linux-ppc64le.tar.gz -ea265f5e62fcaf941d53f0cdb81222d9668e1672a0d39d992f16ff0e87c0ee6b go1.18.linux-s390x.tar.gz -e23fd2a0509690fe7e63b2b1bcd4c39ed57b46ccde76f35dc0d16ca7fdbc5aaa go1.18.windows-386.zip -65c5c0c709a7ca1b357091b10b795b439d8b50e579d3893edab4c7e9b384f435 go1.18.windows-amd64.zip -1c454eb60c64d481965a165c623ff1ed6cf32d68c6b31f36069c8768d908f093 go1.18.windows-arm64.zip - -03c181fc1bb29ea3e73cbb23399c43b081063833a7cf7554b94e5a98308df53e golangci-lint-1.45.2-linux-riscv64.deb -08a50bbbf451ede6d5354179eb3e14a5634e156dfa92cb9a2606f855a637e35b golangci-lint-1.45.2-linux-ppc64le.rpm -0d12f6ec1296b5a70e392aa88cd2295cceef266165eb7028e675f455515dd1c9 golangci-lint-1.45.2-linux-armv7.deb -10f2846e2e50e4ea8ae426ee62dcd2227b23adddd8e991aa3c065927ac948735 golangci-lint-1.45.2-linux-ppc64le.deb -1463049b744871168095e3e8f687247d6040eeb895955b869889ea151e0603ab golangci-lint-1.45.2-linux-arm64.tar.gz -15720f9c4c6f9324af695f081dc189adc7751b255759e78d7b2df1d7e9192533 golangci-lint-1.45.2-linux-amd64.deb -166d922e4d3cfe3d47786c590154a9c8ea689dff0aa92b73d2f5fc74fc570c29 golangci-lint-1.45.2-linux-arm64.rpm -1a3754c69f7cc19ab89cbdcc2550da4cf9abb3120383c6b3bd440c1ec22da2e6 golangci-lint-1.45.2-freebsd-386.tar.gz -1dec0aa46d4f0d241863b573f70129bdf1de9c595cf51172a840a588a4cd9fc5 golangci-lint-1.45.2-windows-amd64.zip -3198453806517c1ad988229f5e758ef850e671203f46d6905509df5bdf4dc24b golangci-lint-1.45.2-freebsd-armv7.tar.gz -46a3cd1749d7b98adc2dc01510ddbe21abe42689c8a53fb0e81662713629f215 golangci-lint-1.45.2-linux-386.deb -4e28bfb593d464b9e160f2acd5b71993836a183270bf8299b78ad31f7a168c0d golangci-lint-1.45.2-linux-arm64.deb -5157a58c8f9ab85c33af2e46f0d7c57a3b1e8953b81d61130e292e09f545cfab golangci-lint-1.45.2-linux-mips64le.tar.gz -518cd027644129fbf8ec4f02bd6f9ad7278aae826f92b63c80d4d0819ddde49a golangci-lint-1.45.2-linux-armv6.rpm -595ad6c6dade4c064351bc309f411703e457f8ffbb7a1806b3d8ee713333427f golangci-lint-1.45.2-linux-amd64.tar.gz -6994d6c80f0730751090986184a3481b4be2e6b6e84416238a2b857910045a4f golangci-lint-1.45.2-windows-arm64.zip -6c81652fc340118811b487f713c441fc6f527800bf5fd11b8929d08124efa015 golangci-lint-1.45.2-linux-armv7.tar.gz -726cb045559b7518bafdd3459de70a0647c087eb1b4634627a4b2e95b1258580 golangci-lint-1.45.2-freebsd-amd64.tar.gz -77df3774cdfda49b956d4a0e676da9a9b883f496ee37293c530770fef6b1d24e golangci-lint-1.45.2-linux-mips64.deb -7a9840f279a7d5d405bb434e101c2290964b3729630ac2add29280b962b7b9a5 golangci-lint-1.45.2-windows-armv6.zip -7d4bf9a5d80ec467aaaf66e78dbdcab567bbc6ba8151334c714eee58766aae32 golangci-lint-1.45.2-windows-armv7.zip -7e5f8821d39bb11d273b0841b34355f56bd5a45a2d5179f0d09e614e0efc0482 golangci-lint-1.45.2-linux-s390x.rpm -828de1bde796b23d8656b17a8885fbd879ef612795d62d1e4618126b419728b5 golangci-lint-1.45.2-linux-mips64.rpm -879a52107a797678a03c175cc7cf441411a14a01f66dc87f70bdfa304a4129a6 golangci-lint-1.45.2-windows-386.zip -87b6c7e3a3769f7d9abeb3bb82119b3c91e3c975300f6834fdeef8b2e37c98ff golangci-lint-1.45.2-linux-amd64.rpm -8b605c6d686c8af53ecc4ef39544541eeb1644d34cc10f9ffc5087808210c4ff golangci-lint-1.45.2-linux-s390x.deb -9427dbf51d0ac6f73a0f992838bd40c817470cc5bf6c8e2e2bea6fac46d7af6e golangci-lint-1.45.2-linux-ppc64le.tar.gz -995e509e895ca6a64ffc7395ac884d5961bdec98423cb896b17f345a9b4a19cf golangci-lint-1.45.2-darwin-amd64.tar.gz -a3f36278f2ea5516341e9071a2df6e65df272be80230b5406a12b72c6d425bee golangci-lint-1.45.2-linux-armv7.rpm -a5e12c50c23e87ac1deffc872f92ae85427b1198604969399805ae47cfe43f08 golangci-lint-1.45.2-linux-riscv64.tar.gz -aa8fa1be0729dbc2fbc4e01e82027097613eee74bd686ebef20f860b01fff8b3 golangci-lint-1.45.2-freebsd-armv6.tar.gz -c2b9669decc1b638cf2ee9060571af4e255f6dfcbb225c293e3a7ee4bb2c7217 golangci-lint-1.45.2-darwin-arm64.tar.gz -dfa8bdaf0387aec1cd5c1aa8857f67b2bbdfc2e42efce540c8fb9bbe3e8af302 golangci-lint-1.45.2-linux-armv6.tar.gz -eb8b8539dd017eee5c131ea9b875893ab2cebeeca41e8c6624907fb02224d643 golangci-lint-1.45.2-linux-386.rpm -ed6c7e17a857f30d715c5302fa250d95936936b277024bffea201187a257d7a7 golangci-lint-1.45.2-linux-armv6.deb -ef4d0154ace4001f01b288baeb118176242efb4fd163e178763e3213b77ef30b golangci-lint-1.45.2-linux-mips64le.deb -ef7002a2229f5ff5ba201a715fcf877664ea88decbe58e69d163293913024955 golangci-lint-1.45.2-linux-s390x.tar.gz -f13ecbd09228632e6bbe91a8324bd675c406eed22eb6d2c1e8192eed9ec4f914 golangci-lint-1.45.2-linux-386.tar.gz -f4cd9cfb09252f51699407277512263cae8409b665dd764f55a34738d0e89edc golangci-lint-1.45.2-linux-riscv64.rpm -fb1945dc59d37c9d14bf0a4aea11ea8651fa0e1d582ea80c4c44d0a536c08893 golangci-lint-1.45.2-linux-mips64.tar.gz -fe542c22738010f453c735a3c410decfd3784d1bd394b395c298ee298fc4c606 golangci-lint-1.45.2-linux-mips64le.rpm diff --git a/build/ci-notes.md b/build/ci-notes.md deleted file mode 100644 index edd9adc1c2..0000000000 --- a/build/ci-notes.md +++ /dev/null @@ -1,50 +0,0 @@ -# Debian Packaging - -Tagged releases and develop branch commits are available as installable Debian packages -for Ubuntu. Packages are built for the all Ubuntu versions which are supported by -Canonical. - -Packages of develop branch commits have suffix -unstable and cannot be installed alongside -the stable version. Switching between release streams requires user intervention. - -## Launchpad - -The packages are built and served by launchpad.net. We generate a Debian source package -for each distribution and upload it. Their builder picks up the source package, builds it -and installs the new version into the PPA repository. Launchpad requires a valid signature -by a team member for source package uploads. - -The signing key is stored in an environment variable which Travis CI makes available to -certain builds. Since Travis CI doesn't support FTP, SFTP is used to transfer the -packages. To set this up yourself, you need to create a Launchpad user and add a GPG key -and SSH key to it. Then encode both keys as base64 and configure 'secret' environment -variables `PPA_SIGNING_KEY` and `PPA_SSH_KEY` on Travis. - -We want to build go-ethereum with the most recent version of Go, irrespective of the Go -version that is available in the main Ubuntu repository. In order to make this possible, -we bundle the entire Go sources into our own source archive and start the built job by -compiling Go and then using that to build go-ethereum. On Trusty we have a special case -requiring the `~gophers/ubuntu/archive` PPA since Trusty can't even build Go itself. PPA -deps are set at https://launchpad.net/%7Eethereum/+archive/ubuntu/ethereum/+edit-dependencies - -## Building Packages Locally (for testing) - -You need to run Ubuntu to do test packaging. - -Install any version of Go and Debian packaging tools: - - $ sudo apt-get install build-essential golang-go devscripts debhelper python-bzrlib python-paramiko - -Create the source packages: - - $ go run build/ci.go debsrc -workdir dist - -Then go into the source package directory for your running distribution and build the package: - - $ cd dist/ethereum-unstable-1.9.6+bionic - $ dpkg-buildpackage - -Built packages are placed in the dist/ directory. - - $ cd .. - $ dpkg-deb -c geth-unstable_1.9.6+bionic_amd64.deb diff --git a/build/ci.go b/build/ci.go deleted file mode 100644 index a9bc2b4a7b..0000000000 --- a/build/ci.go +++ /dev/null @@ -1,1042 +0,0 @@ -// Copyright 2016 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -//go:build none -// +build none - -/* -The ci command is called from Continuous Integration scripts. - -Usage: go run build/ci.go - -Available commands are: - - install [ -arch architecture ] [ -cc compiler ] [ packages... ] -- builds packages and executables - test [ -coverage ] [ packages... ] -- runs the tests - lint -- runs certain pre-selected linters - archive [ -arch architecture ] [ -type zip|tar ] [ -signer key-envvar ] [ -signify key-envvar ] [ -upload dest ] -- archives build artifacts - importkeys -- imports signing keys from env - debsrc [ -signer key-id ] [ -upload dest ] -- creates a debian source package - nsis -- creates a Windows NSIS installer - purge [ -store blobstore ] [ -days threshold ] -- purges old archives from the blobstore - -For all commands, -n prevents execution of external programs (dry run mode). -*/ -package main - -import ( - "bytes" - "encoding/base64" - "flag" - "fmt" - "log" - "os" - "os/exec" - "path" - "path/filepath" - "runtime" - "strconv" - "strings" - "time" - - "github.com/cespare/cp" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/crypto/signify" - "github.com/ethereum/go-ethereum/internal/build" - "github.com/ethereum/go-ethereum/params" -) - -var ( - // Files that end up in the geth*.zip archive. - gethArchiveFiles = []string{ - "COPYING", - executablePath("geth"), - } - - // Files that end up in the geth-alltools*.zip archive. - allToolsArchiveFiles = []string{ - "COPYING", - executablePath("abigen"), - executablePath("bootnode"), - executablePath("evm"), - executablePath("geth"), - executablePath("rlpdump"), - executablePath("clef"), - } - - // A debian package is created for all executables listed here. - debExecutables = []debExecutable{ - { - BinaryName: "abigen", - Description: "Source code generator to convert Ethereum contract definitions into easy to use, compile-time type-safe Go packages.", - }, - { - BinaryName: "bootnode", - Description: "Ethereum bootnode.", - }, - { - BinaryName: "evm", - Description: "Developer utility version of the EVM (Ethereum Virtual Machine) that is capable of running bytecode snippets within a configurable environment and execution mode.", - }, - { - BinaryName: "geth", - Description: "Ethereum CLI client.", - }, - { - BinaryName: "rlpdump", - Description: "Developer utility tool that prints RLP structures.", - }, - { - BinaryName: "clef", - Description: "Ethereum account management tool.", - }, - } - - // A debian package is created for all executables listed here. - debEthereum = debPackage{ - Name: "ethereum", - Version: params.Version, - Executables: debExecutables, - } - - // Debian meta packages to build and push to Ubuntu PPA - debPackages = []debPackage{ - debEthereum, - } - - // Distros for which packages are created. - // Note: vivid is unsupported because there is no golang-1.6 package for it. - // Note: the following Ubuntu releases have been officially deprecated on Launchpad: - // wily, yakkety, zesty, artful, cosmic, disco, eoan, groovy, hirsuite, impish - debDistroGoBoots = map[string]string{ - "trusty": "golang-1.11", // EOL: 04/2024 - "xenial": "golang-go", // EOL: 04/2026 - "bionic": "golang-go", // EOL: 04/2028 - "focal": "golang-go", // EOL: 04/2030 - "jammy": "golang-go", // EOL: 04/2032 - "kinetic": "golang-go", // EOL: 07/2023 - "lunar": "golang-go", // EOL: 01/2024 - } - - debGoBootPaths = map[string]string{ - "golang-1.11": "/usr/lib/go-1.11", - "golang-go": "/usr/lib/go", - } - - // This is the version of Go that will be downloaded by - // - // go run ci.go install -dlgo - dlgoVersion = "1.20" -) - -var GOBIN, _ = filepath.Abs(filepath.Join("build", "bin")) - -func executablePath(name string) string { - if runtime.GOOS == "windows" { - name += ".exe" - } - return filepath.Join(GOBIN, name) -} - -func main() { - log.SetFlags(log.Lshortfile) - - if !common.FileExist(filepath.Join("build", "ci.go")) { - log.Fatal("this script must be run from the root of the repository") - } - if len(os.Args) < 2 { - log.Fatal("need subcommand as first argument") - } - switch os.Args[1] { - case "install": - doInstall(os.Args[2:]) - case "test": - doTest(os.Args[2:]) - case "lint": - doLint(os.Args[2:]) - case "archive": - doArchive(os.Args[2:]) - case "docker": - doDocker(os.Args[2:]) - case "debsrc": - doDebianSource(os.Args[2:]) - case "nsis": - doWindowsInstaller(os.Args[2:]) - case "purge": - doPurge(os.Args[2:]) - default: - log.Fatal("unknown command ", os.Args[1]) - } -} - -// Compiling - -func doInstall(cmdline []string) { - var ( - dlgo = flag.Bool("dlgo", false, "Download Go and build with it") - arch = flag.String("arch", "", "Architecture to cross build for") - cc = flag.String("cc", "", "C compiler to cross build with") - staticlink = flag.Bool("static", false, "Create statically-linked executable") - ) - flag.CommandLine.Parse(cmdline) - - // Configure the toolchain. - tc := build.GoToolchain{GOARCH: *arch, CC: *cc} - if *dlgo { - csdb := build.MustLoadChecksums("build/checksums.txt") - tc.Root = build.DownloadGo(csdb, dlgoVersion) - } - - // Disable CLI markdown doc generation in release builds. - buildTags := []string{"urfave_cli_no_docs"} - - // Configure the build. - env := build.Env() - gobuild := tc.Go("build", buildFlags(env, *staticlink, buildTags)...) - - // arm64 CI builders are memory-constrained and can't handle concurrent builds, - // better disable it. This check isn't the best, it should probably - // check for something in env instead. - if env.CI && runtime.GOARCH == "arm64" { - gobuild.Args = append(gobuild.Args, "-p", "1") - } - - // We use -trimpath to avoid leaking local paths into the built executables. - gobuild.Args = append(gobuild.Args, "-trimpath") - - // Show packages during build. - gobuild.Args = append(gobuild.Args, "-v") - - // Now we choose what we're even building. - // Default: collect all 'main' packages in cmd/ and build those. - packages := flag.Args() - if len(packages) == 0 { - packages = build.FindMainPackages("./cmd") - } - - // Do the build! - for _, pkg := range packages { - args := make([]string, len(gobuild.Args)) - copy(args, gobuild.Args) - args = append(args, "-o", executablePath(path.Base(pkg))) - args = append(args, pkg) - build.MustRun(&exec.Cmd{Path: gobuild.Path, Args: args, Env: gobuild.Env}) - } -} - -// buildFlags returns the go tool flags for building. -func buildFlags(env build.Environment, staticLinking bool, buildTags []string) (flags []string) { - var ld []string - if env.Commit != "" { - ld = append(ld, "-X", "github.com/maticnetwork/bor/internal/version.gitCommit="+env.Commit) - ld = append(ld, "-X", "github.com/maticnetwork/bor/internal/version.gitDate="+env.Date) - } - // Strip DWARF on darwin. This used to be required for certain things, - // and there is no downside to this, so we just keep doing it. - if runtime.GOOS == "darwin" { - ld = append(ld, "-s") - } - if runtime.GOOS == "linux" { - // Enforce the stacksize to 8M, which is the case on most platforms apart from - // alpine Linux. - extld := []string{"-Wl,-z,stack-size=0x800000"} - if staticLinking { - extld = append(extld, "-static") - // Under static linking, use of certain glibc features must be - // disabled to avoid shared library dependencies. - buildTags = append(buildTags, "osusergo", "netgo") - } - ld = append(ld, "-extldflags", "'"+strings.Join(extld, " ")+"'") - } - if len(ld) > 0 { - flags = append(flags, "-ldflags", strings.Join(ld, " ")) - } - if len(buildTags) > 0 { - flags = append(flags, "-tags", strings.Join(buildTags, ",")) - } - return flags -} - -// Running The Tests -// -// "tests" also includes static analysis tools such as vet. - -func doTest(cmdline []string) { - var ( - dlgo = flag.Bool("dlgo", false, "Download Go and build with it") - arch = flag.String("arch", "", "Run tests for given architecture") - cc = flag.String("cc", "", "Sets C compiler binary") - coverage = flag.Bool("coverage", false, "Whether to record code coverage") - verbose = flag.Bool("v", false, "Whether to log verbosely") - race = flag.Bool("race", false, "Execute the race detector") - ) - flag.CommandLine.Parse(cmdline) - - // Configure the toolchain. - tc := build.GoToolchain{GOARCH: *arch, CC: *cc} - if *dlgo { - csdb := build.MustLoadChecksums("build/checksums.txt") - tc.Root = build.DownloadGo(csdb, dlgoVersion) - } - gotest := tc.Go("test") - - // Test a single package at a time. CI builders are slow - // and some tests run into timeouts under load. - gotest.Args = append(gotest.Args, "-p", "1") - if *coverage { - gotest.Args = append(gotest.Args, "-covermode=atomic", "-cover") - } - if *verbose { - gotest.Args = append(gotest.Args, "-v") - } - if *race { - gotest.Args = append(gotest.Args, "-race") - } - - packages := []string{"./..."} - if len(flag.CommandLine.Args()) > 0 { - packages = flag.CommandLine.Args() - } - gotest.Args = append(gotest.Args, packages...) - build.MustRun(gotest) -} - -// doLint runs golangci-lint on requested packages. -func doLint(cmdline []string) { - var ( - cachedir = flag.String("cachedir", "./build/cache", "directory for caching golangci-lint binary.") - ) - flag.CommandLine.Parse(cmdline) - packages := []string{"./..."} - if len(flag.CommandLine.Args()) > 0 { - packages = flag.CommandLine.Args() - } - - linter := downloadLinter(*cachedir) - lflags := []string{"run", "--config", ".golangci.yml"} - build.MustRunCommand(linter, append(lflags, packages...)...) - fmt.Println("You have achieved perfection.") -} - -// downloadLinter downloads and unpacks golangci-lint. -func downloadLinter(cachedir string) string { - const version = "1.45.2" - - csdb := build.MustLoadChecksums("build/checksums.txt") - arch := runtime.GOARCH - ext := ".tar.gz" - - if runtime.GOOS == "windows" { - ext = ".zip" - } - if arch == "arm" { - arch += "v" + os.Getenv("GOARM") - } - base := fmt.Sprintf("golangci-lint-%s-%s-%s", version, runtime.GOOS, arch) - url := fmt.Sprintf("https://github.com/golangci/golangci-lint/releases/download/v%s/%s%s", version, base, ext) - archivePath := filepath.Join(cachedir, base+ext) - if err := csdb.DownloadFile(url, archivePath); err != nil { - log.Fatal(err) - } - if err := build.ExtractArchive(archivePath, cachedir); err != nil { - log.Fatal(err) - } - return filepath.Join(cachedir, base, "golangci-lint") -} - -// Release Packaging -func doArchive(cmdline []string) { - var ( - arch = flag.String("arch", runtime.GOARCH, "Architecture cross packaging") - atype = flag.String("type", "zip", "Type of archive to write (zip|tar)") - signer = flag.String("signer", "", `Environment variable holding the signing key (e.g. LINUX_SIGNING_KEY)`) - signify = flag.String("signify", "", `Environment variable holding the signify key (e.g. LINUX_SIGNIFY_KEY)`) - upload = flag.String("upload", "", `Destination to upload the archives (usually "gethstore/builds")`) - ext string - ) - flag.CommandLine.Parse(cmdline) - switch *atype { - case "zip": - ext = ".zip" - case "tar": - ext = ".tar.gz" - default: - log.Fatal("unknown archive type: ", atype) - } - - var ( - env = build.Env() - basegeth = archiveBasename(*arch, params.ArchiveVersion(env.Commit)) - geth = "geth-" + basegeth + ext - alltools = "geth-alltools-" + basegeth + ext - ) - maybeSkipArchive(env) - if err := build.WriteArchive(geth, gethArchiveFiles); err != nil { - log.Fatal(err) - } - if err := build.WriteArchive(alltools, allToolsArchiveFiles); err != nil { - log.Fatal(err) - } - for _, archive := range []string{geth, alltools} { - if err := archiveUpload(archive, *upload, *signer, *signify); err != nil { - log.Fatal(err) - } - } -} - -func archiveBasename(arch string, archiveVersion string) string { - platform := runtime.GOOS + "-" + arch - if arch == "arm" { - platform += os.Getenv("GOARM") - } - if arch == "android" { - platform = "android-all" - } - if arch == "ios" { - platform = "ios-all" - } - return platform + "-" + archiveVersion -} - -func archiveUpload(archive string, blobstore string, signer string, signifyVar string) error { - // If signing was requested, generate the signature files - if signer != "" { - key := getenvBase64(signer) - if err := build.PGPSignFile(archive, archive+".asc", string(key)); err != nil { - return err - } - } - if signifyVar != "" { - key := os.Getenv(signifyVar) - untrustedComment := "verify with geth-release.pub" - trustedComment := fmt.Sprintf("%s (%s)", archive, time.Now().UTC().Format(time.RFC1123)) - if err := signify.SignFile(archive, archive+".sig", key, untrustedComment, trustedComment); err != nil { - return err - } - } - // If uploading to Azure was requested, push the archive possibly with its signature - if blobstore != "" { - auth := build.AzureBlobstoreConfig{ - Account: strings.Split(blobstore, "/")[0], - Token: os.Getenv("AZURE_BLOBSTORE_TOKEN"), - Container: strings.SplitN(blobstore, "/", 2)[1], - } - if err := build.AzureBlobstoreUpload(archive, filepath.Base(archive), auth); err != nil { - return err - } - if signer != "" { - if err := build.AzureBlobstoreUpload(archive+".asc", filepath.Base(archive+".asc"), auth); err != nil { - return err - } - } - if signifyVar != "" { - if err := build.AzureBlobstoreUpload(archive+".sig", filepath.Base(archive+".sig"), auth); err != nil { - return err - } - } - } - return nil -} - -// skips archiving for some build configurations. -func maybeSkipArchive(env build.Environment) { - if env.IsPullRequest { - log.Printf("skipping archive creation because this is a PR build") - os.Exit(0) - } - if env.Branch != "master" && !strings.HasPrefix(env.Tag, "v1.") { - log.Printf("skipping archive creation because branch %q, tag %q is not on the inclusion list", env.Branch, env.Tag) - os.Exit(0) - } -} - -// Builds the docker images and optionally uploads them to Docker Hub. -func doDocker(cmdline []string) { - var ( - image = flag.Bool("image", false, `Whether to build and push an arch specific docker image`) - manifest = flag.String("manifest", "", `Push a multi-arch docker image for the specified architectures (usually "amd64,arm64")`) - upload = flag.String("upload", "", `Where to upload the docker image (usually "ethereum/client-go")`) - ) - flag.CommandLine.Parse(cmdline) - - // Skip building and pushing docker images for PR builds - env := build.Env() - maybeSkipArchive(env) - - // Retrieve the upload credentials and authenticate - user := getenvBase64("DOCKER_HUB_USERNAME") - pass := getenvBase64("DOCKER_HUB_PASSWORD") - - if len(user) > 0 && len(pass) > 0 { - auther := exec.Command("docker", "login", "-u", string(user), "--password-stdin") - auther.Stdin = bytes.NewReader(pass) - build.MustRun(auther) - } - // Retrieve the version infos to build and push to the following paths: - // - ethereum/client-go:latest - Pushes to the master branch, Geth only - // - ethereum/client-go:stable - Version tag publish on GitHub, Geth only - // - ethereum/client-go:alltools-latest - Pushes to the master branch, Geth & tools - // - ethereum/client-go:alltools-stable - Version tag publish on GitHub, Geth & tools - // - ethereum/client-go:release-. - Version tag publish on GitHub, Geth only - // - ethereum/client-go:alltools-release-. - Version tag publish on GitHub, Geth & tools - // - ethereum/client-go:v.. - Version tag publish on GitHub, Geth only - // - ethereum/client-go:alltools-v.. - Version tag publish on GitHub, Geth & tools - var tags []string - - switch { - case env.Branch == "master": - tags = []string{"latest"} - case strings.HasPrefix(env.Tag, "v1."): - tags = []string{"stable", fmt.Sprintf("release-1.%d", params.VersionMinor), "v" + params.Version} - } - // If architecture specific image builds are requested, build and push them - if *image { - build.MustRunCommand("docker", "build", "--build-arg", "COMMIT="+env.Commit, "--build-arg", "VERSION="+params.VersionWithMeta, "--build-arg", "BUILDNUM="+env.Buildnum, "--tag", fmt.Sprintf("%s:TAG", *upload), ".") - build.MustRunCommand("docker", "build", "--build-arg", "COMMIT="+env.Commit, "--build-arg", "VERSION="+params.VersionWithMeta, "--build-arg", "BUILDNUM="+env.Buildnum, "--tag", fmt.Sprintf("%s:alltools-TAG", *upload), "-f", "Dockerfile.alltools", ".") - - // Tag and upload the images to Docker Hub - for _, tag := range tags { - gethImage := fmt.Sprintf("%s:%s-%s", *upload, tag, runtime.GOARCH) - toolImage := fmt.Sprintf("%s:alltools-%s-%s", *upload, tag, runtime.GOARCH) - - // If the image already exists (non version tag), check the build - // number to prevent overwriting a newer commit if concurrent builds - // are running. This is still a tiny bit racey if two published are - // done at the same time, but that's extremely unlikely even on the - // master branch. - for _, img := range []string{gethImage, toolImage} { - if exec.Command("docker", "pull", img).Run() != nil { - continue // Generally the only failure is a missing image, which is good - } - buildnum, err := exec.Command("docker", "inspect", "--format", "{{index .Config.Labels \"buildnum\"}}", img).CombinedOutput() - if err != nil { - log.Fatalf("Failed to inspect container: %v\nOutput: %s", err, string(buildnum)) - } - buildnum = bytes.TrimSpace(buildnum) - - if len(buildnum) > 0 && len(env.Buildnum) > 0 { - oldnum, err := strconv.Atoi(string(buildnum)) - if err != nil { - log.Fatalf("Failed to parse old image build number: %v", err) - } - newnum, err := strconv.Atoi(env.Buildnum) - if err != nil { - log.Fatalf("Failed to parse current build number: %v", err) - } - if oldnum > newnum { - log.Fatalf("Current build number %d not newer than existing %d", newnum, oldnum) - } else { - log.Printf("Updating %s from build %d to %d", img, oldnum, newnum) - } - } - } - build.MustRunCommand("docker", "image", "tag", fmt.Sprintf("%s:TAG", *upload), gethImage) - build.MustRunCommand("docker", "image", "tag", fmt.Sprintf("%s:alltools-TAG", *upload), toolImage) - build.MustRunCommand("docker", "push", gethImage) - build.MustRunCommand("docker", "push", toolImage) - } - } - // If multi-arch image manifest push is requested, assemble it - if len(*manifest) != 0 { - // Since different architectures are pushed by different builders, wait - // until all required images are updated. - var mismatch bool - for i := 0; i < 2; i++ { // 2 attempts, second is race check - mismatch = false // hope there's no mismatch now - - for _, tag := range tags { - for _, arch := range strings.Split(*manifest, ",") { - gethImage := fmt.Sprintf("%s:%s-%s", *upload, tag, arch) - toolImage := fmt.Sprintf("%s:alltools-%s-%s", *upload, tag, arch) - - for _, img := range []string{gethImage, toolImage} { - if out, err := exec.Command("docker", "pull", img).CombinedOutput(); err != nil { - log.Printf("Required image %s unavailable: %v\nOutput: %s", img, err, out) - mismatch = true - break - } - buildnum, err := exec.Command("docker", "inspect", "--format", "{{index .Config.Labels \"buildnum\"}}", img).CombinedOutput() - if err != nil { - log.Fatalf("Failed to inspect container: %v\nOutput: %s", err, string(buildnum)) - } - buildnum = bytes.TrimSpace(buildnum) - - if string(buildnum) != env.Buildnum { - log.Printf("Build number mismatch on %s: want %s, have %s", img, env.Buildnum, buildnum) - mismatch = true - break - } - } - if mismatch { - break - } - } - if mismatch { - break - } - } - if mismatch { - // Build numbers mismatching, retry in a short time to - // avoid concurrent fails in both publisher images. If - // however the retry failed too, it means the concurrent - // builder is still crunching, let that do the publish. - if i == 0 { - time.Sleep(30 * time.Second) - } - continue - } - break - } - if mismatch { - log.Println("Relinquishing publish to other builder") - return - } - // Assemble and push the Geth manifest image - for _, tag := range tags { - gethImage := fmt.Sprintf("%s:%s", *upload, tag) - - var gethSubImages []string - for _, arch := range strings.Split(*manifest, ",") { - gethSubImages = append(gethSubImages, gethImage+"-"+arch) - } - build.MustRunCommand("docker", append([]string{"manifest", "create", gethImage}, gethSubImages...)...) - build.MustRunCommand("docker", "manifest", "push", gethImage) - } - // Assemble and push the alltools manifest image - for _, tag := range tags { - toolImage := fmt.Sprintf("%s:alltools-%s", *upload, tag) - - var toolSubImages []string - for _, arch := range strings.Split(*manifest, ",") { - toolSubImages = append(toolSubImages, toolImage+"-"+arch) - } - build.MustRunCommand("docker", append([]string{"manifest", "create", toolImage}, toolSubImages...)...) - build.MustRunCommand("docker", "manifest", "push", toolImage) - } - } -} - -// Debian Packaging -func doDebianSource(cmdline []string) { - var ( - cachedir = flag.String("cachedir", "./build/cache", `Filesystem path to cache the downloaded Go bundles at`) - signer = flag.String("signer", "", `Signing key name, also used as package author`) - upload = flag.String("upload", "", `Where to upload the source package (usually "ethereum/ethereum")`) - sshUser = flag.String("sftp-user", "", `Username for SFTP upload (usually "geth-ci")`) - workdir = flag.String("workdir", "", `Output directory for packages (uses temp dir if unset)`) - now = time.Now() - ) - flag.CommandLine.Parse(cmdline) - *workdir = makeWorkdir(*workdir) - env := build.Env() - tc := new(build.GoToolchain) - maybeSkipArchive(env) - - // Import the signing key. - if key := getenvBase64("PPA_SIGNING_KEY"); len(key) > 0 { - gpg := exec.Command("gpg", "--import") - gpg.Stdin = bytes.NewReader(key) - build.MustRun(gpg) - } - // Download and verify the Go source packages. - var ( - gobundle = downloadGoSources(*cachedir) - ) - // Download all the dependencies needed to build the sources and run the ci script - srcdepfetch := tc.Go("mod", "download") - srcdepfetch.Env = append(srcdepfetch.Env, "GOPATH="+filepath.Join(*workdir, "modgopath")) - build.MustRun(srcdepfetch) - - cidepfetch := tc.Go("run", "./build/ci.go") - cidepfetch.Env = append(cidepfetch.Env, "GOPATH="+filepath.Join(*workdir, "modgopath")) - cidepfetch.Run() // Command fails, don't care, we only need the deps to start it - - // Create Debian packages and upload them. - for _, pkg := range debPackages { - for distro, goboot := range debDistroGoBoots { - // Prepare the debian package with the go-ethereum sources. - meta := newDebMetadata(distro, goboot, *signer, env, now, pkg.Name, pkg.Version, pkg.Executables) - pkgdir := stageDebianSource(*workdir, meta) - - canonicalPath, err := common.VerifyPath(pkgdir) - if err != nil { - fmt.Println("path not verified: " + err.Error()) - return - } - - // Add builder Go source code - if err := build.ExtractArchive(gobundle, canonicalPath); err != nil { - log.Fatalf("Failed to extract builder Go sources: %v", err) - } - if err := os.Rename(filepath.Join(canonicalPath, "go"), filepath.Join(canonicalPath, ".go")); err != nil { - log.Fatalf("Failed to rename builder Go source folder: %v", err) - } - // Add all dependency modules in compressed form - os.MkdirAll(filepath.Join(canonicalPath, ".mod", "cache"), 0755) - if err := cp.CopyAll(filepath.Join(canonicalPath, ".mod", "cache", "download"), filepath.Join(*workdir, "modgopath", "pkg", "mod", "cache", "download")); err != nil { - log.Fatalf("Failed to copy Go module dependencies: %v", err) - } - // Run the packaging and upload to the PPA - debuild := exec.Command("debuild", "-S", "-sa", "-us", "-uc", "-d", "-Zxz", "-nc") - debuild.Dir = canonicalPath - build.MustRun(debuild) - - var ( - basename = fmt.Sprintf("%s_%s", meta.Name(), meta.VersionString()) - source = filepath.Join(*workdir, basename+".tar.xz") - dsc = filepath.Join(*workdir, basename+".dsc") - changes = filepath.Join(*workdir, basename+"_source.changes") - buildinfo = filepath.Join(*workdir, basename+"_source.buildinfo") - ) - if *signer != "" { - build.MustRunCommand("debsign", changes) - } - if *upload != "" { - ppaUpload(*workdir, *upload, *sshUser, []string{source, dsc, changes, buildinfo}) - } - } - } -} - -// downloadGoSources downloads the Go source tarball. -func downloadGoSources(cachedir string) string { - csdb := build.MustLoadChecksums("build/checksums.txt") - file := fmt.Sprintf("go%s.src.tar.gz", dlgoVersion) - url := "https://dl.google.com/go/" + file - dst := filepath.Join(cachedir, file) - if err := csdb.DownloadFile(url, dst); err != nil { - log.Fatal(err) - } - return dst -} - -func ppaUpload(workdir, ppa, sshUser string, files []string) { - p := strings.Split(ppa, "/") - if len(p) != 2 { - log.Fatal("-upload PPA name must contain single /") - } - if sshUser == "" { - sshUser = p[0] - } - incomingDir := fmt.Sprintf("~%s/ubuntu/%s", p[0], p[1]) - // Create the SSH identity file if it doesn't exist. - var idfile string - if sshkey := getenvBase64("PPA_SSH_KEY"); len(sshkey) > 0 { - idfile = filepath.Join(workdir, "sshkey") - if !common.FileExist(idfile) { - os.WriteFile(idfile, sshkey, 0600) - } - } - // Upload - dest := sshUser + "@ppa.launchpad.net" - if err := build.UploadSFTP(idfile, dest, incomingDir, files); err != nil { - log.Fatal(err) - } -} - -func getenvBase64(variable string) []byte { - dec, err := base64.StdEncoding.DecodeString(os.Getenv(variable)) - if err != nil { - log.Fatal("invalid base64 " + variable) - } - return []byte(dec) -} - -func makeWorkdir(wdflag string) string { - var err error - if wdflag != "" { - err = os.MkdirAll(wdflag, 0744) - } else { - wdflag, err = os.MkdirTemp("", "geth-build-") - } - if err != nil { - log.Fatal(err) - } - return wdflag -} - -func isUnstableBuild(env build.Environment) bool { - if env.Tag != "" { - return false - } - return true -} - -type debPackage struct { - Name string // the name of the Debian package to produce, e.g. "ethereum" - Version string // the clean version of the debPackage, e.g. 1.8.12, without any metadata - Executables []debExecutable // executables to be included in the package -} - -type debMetadata struct { - Env build.Environment - GoBootPackage string - GoBootPath string - - PackageName string - - // go-ethereum version being built. Note that this - // is not the debian package version. The package version - // is constructed by VersionString. - Version string - - Author string // "name ", also selects signing key - Distro, Time string - Executables []debExecutable -} - -type debExecutable struct { - PackageName string - BinaryName string - Description string -} - -// Package returns the name of the package if present, or -// fallbacks to BinaryName -func (d debExecutable) Package() string { - if d.PackageName != "" { - return d.PackageName - } - return d.BinaryName -} - -func newDebMetadata(distro, goboot, author string, env build.Environment, t time.Time, name string, version string, exes []debExecutable) debMetadata { - if author == "" { - // No signing key, use default author. - author = "Ethereum Builds " - } - return debMetadata{ - GoBootPackage: goboot, - GoBootPath: debGoBootPaths[goboot], - PackageName: name, - Env: env, - Author: author, - Distro: distro, - Version: version, - Time: t.Format(time.RFC1123Z), - Executables: exes, - } -} - -// Name returns the name of the metapackage that depends -// on all executable packages. -func (meta debMetadata) Name() string { - if isUnstableBuild(meta.Env) { - return meta.PackageName + "-unstable" - } - return meta.PackageName -} - -// VersionString returns the debian version of the packages. -func (meta debMetadata) VersionString() string { - vsn := meta.Version - if meta.Env.Buildnum != "" { - vsn += "+build" + meta.Env.Buildnum - } - if meta.Distro != "" { - vsn += "+" + meta.Distro - } - return vsn -} - -// ExeList returns the list of all executable packages. -func (meta debMetadata) ExeList() string { - names := make([]string, len(meta.Executables)) - for i, e := range meta.Executables { - names[i] = meta.ExeName(e) - } - return strings.Join(names, ", ") -} - -// ExeName returns the package name of an executable package. -func (meta debMetadata) ExeName(exe debExecutable) string { - if isUnstableBuild(meta.Env) { - return exe.Package() + "-unstable" - } - return exe.Package() -} - -// ExeConflicts returns the content of the Conflicts field -// for executable packages. -func (meta debMetadata) ExeConflicts(exe debExecutable) string { - if isUnstableBuild(meta.Env) { - // Set up the conflicts list so that the *-unstable packages - // cannot be installed alongside the regular version. - // - // https://www.debian.org/doc/debian-policy/ch-relationships.html - // is very explicit about Conflicts: and says that Breaks: should - // be preferred and the conflicting files should be handled via - // alternates. We might do this eventually but using a conflict is - // easier now. - return "ethereum, " + exe.Package() - } - return "" -} - -func stageDebianSource(tmpdir string, meta debMetadata) (pkgdir string) { - pkg := meta.Name() + "-" + meta.VersionString() - pkgdir = filepath.Join(tmpdir, pkg) - if err := os.Mkdir(pkgdir, 0755); err != nil { - log.Fatal(err) - } - // Copy the source code. - build.MustRunCommand("git", "checkout-index", "-a", "--prefix", pkgdir+string(filepath.Separator)) - - // Put the debian build files in place. - debian := filepath.Join(pkgdir, "debian") - build.Render("build/deb/"+meta.PackageName+"/deb.rules", filepath.Join(debian, "rules"), 0755, meta) - build.Render("build/deb/"+meta.PackageName+"/deb.changelog", filepath.Join(debian, "changelog"), 0644, meta) - build.Render("build/deb/"+meta.PackageName+"/deb.control", filepath.Join(debian, "control"), 0644, meta) - build.Render("build/deb/"+meta.PackageName+"/deb.copyright", filepath.Join(debian, "copyright"), 0644, meta) - build.RenderString("8\n", filepath.Join(debian, "compat"), 0644, meta) - build.RenderString("3.0 (native)\n", filepath.Join(debian, "source/format"), 0644, meta) - for _, exe := range meta.Executables { - install := filepath.Join(debian, meta.ExeName(exe)+".install") - docs := filepath.Join(debian, meta.ExeName(exe)+".docs") - build.Render("build/deb/"+meta.PackageName+"/deb.install", install, 0644, exe) - build.Render("build/deb/"+meta.PackageName+"/deb.docs", docs, 0644, exe) - } - return pkgdir -} - -// Windows installer -func doWindowsInstaller(cmdline []string) { - // Parse the flags and make skip installer generation on PRs - var ( - arch = flag.String("arch", runtime.GOARCH, "Architecture for cross build packaging") - signer = flag.String("signer", "", `Environment variable holding the signing key (e.g. WINDOWS_SIGNING_KEY)`) - signify = flag.String("signify key", "", `Environment variable holding the signify signing key (e.g. WINDOWS_SIGNIFY_KEY)`) - upload = flag.String("upload", "", `Destination to upload the archives (usually "gethstore/builds")`) - workdir = flag.String("workdir", "", `Output directory for packages (uses temp dir if unset)`) - ) - flag.CommandLine.Parse(cmdline) - *workdir = makeWorkdir(*workdir) - env := build.Env() - maybeSkipArchive(env) - - // Aggregate binaries that are included in the installer - var ( - devTools []string - allTools []string - gethTool string - ) - for _, file := range allToolsArchiveFiles { - if file == "COPYING" { // license, copied later - continue - } - allTools = append(allTools, filepath.Base(file)) - if filepath.Base(file) == "geth.exe" { - gethTool = file - } else { - devTools = append(devTools, file) - } - } - - // Render NSIS scripts: Installer NSIS contains two installer sections, - // first section contains the geth binary, second section holds the dev tools. - templateData := map[string]interface{}{ - "License": "COPYING", - "Geth": gethTool, - "DevTools": devTools, - } - build.Render("build/nsis.geth.nsi", filepath.Join(*workdir, "geth.nsi"), 0644, nil) - build.Render("build/nsis.install.nsh", filepath.Join(*workdir, "install.nsh"), 0644, templateData) - build.Render("build/nsis.uninstall.nsh", filepath.Join(*workdir, "uninstall.nsh"), 0644, allTools) - build.Render("build/nsis.pathupdate.nsh", filepath.Join(*workdir, "PathUpdate.nsh"), 0644, nil) - build.Render("build/nsis.envvarupdate.nsh", filepath.Join(*workdir, "EnvVarUpdate.nsh"), 0644, nil) - if err := cp.CopyFile(filepath.Join(*workdir, "SimpleFC.dll"), "build/nsis.simplefc.dll"); err != nil { - log.Fatalf("Failed to copy SimpleFC.dll: %v", err) - } - if err := cp.CopyFile(filepath.Join(*workdir, "COPYING"), "COPYING"); err != nil { - log.Fatalf("Failed to copy copyright note: %v", err) - } - // Build the installer. This assumes that all the needed files have been previously - // built (don't mix building and packaging to keep cross compilation complexity to a - // minimum). - version := strings.Split(params.Version, ".") - if env.Commit != "" { - version[2] += "-" + env.Commit[:8] - } - installer, err := filepath.Abs("geth-" + archiveBasename(*arch, params.ArchiveVersion(env.Commit)) + ".exe") - if err != nil { - log.Fatalf("Failed to convert installer file path: %v", err) - } - build.MustRunCommand("makensis.exe", - "/DOUTPUTFILE="+installer, - "/DMAJORVERSION="+version[0], - "/DMINORVERSION="+version[1], - "/DBUILDVERSION="+version[2], - "/DARCH="+*arch, - filepath.Join(*workdir, "geth.nsi"), - ) - // Sign and publish installer. - if err := archiveUpload(installer, *upload, *signer, *signify); err != nil { - log.Fatal(err) - } -} - -// Binary distribution cleanups - -func doPurge(cmdline []string) { - var ( - store = flag.String("store", "", `Destination from where to purge archives (usually "gethstore/builds")`) - limit = flag.Int("days", 30, `Age threshold above which to delete unstable archives`) - ) - flag.CommandLine.Parse(cmdline) - - if env := build.Env(); !env.IsCronJob { - log.Printf("skipping because not a cron job") - os.Exit(0) - } - // Create the azure authentication and list the current archives - auth := build.AzureBlobstoreConfig{ - Account: strings.Split(*store, "/")[0], - Token: os.Getenv("AZURE_BLOBSTORE_TOKEN"), - Container: strings.SplitN(*store, "/", 2)[1], - } - blobs, err := build.AzureBlobstoreList(auth) - if err != nil { - log.Fatal(err) - } - fmt.Printf("Found %d blobs\n", len(blobs)) - - // Iterate over the blobs, collect and sort all unstable builds - for i := 0; i < len(blobs); i++ { - if !strings.Contains(*blobs[i].Name, "unstable") { - blobs = append(blobs[:i], blobs[i+1:]...) - i-- - } - } - for i := 0; i < len(blobs); i++ { - for j := i + 1; j < len(blobs); j++ { - if blobs[i].Properties.LastModified.After(*blobs[j].Properties.LastModified) { - blobs[i], blobs[j] = blobs[j], blobs[i] - } - } - } - // Filter out all archives more recent that the given threshold - for i, blob := range blobs { - if time.Since(*blob.Properties.LastModified) < time.Duration(*limit)*24*time.Hour { - blobs = blobs[:i] - break - } - } - fmt.Printf("Deleting %d blobs\n", len(blobs)) - // Delete all marked as such and return - if err := build.AzureBlobstoreDelete(auth, blobs); err != nil { - log.Fatal(err) - } -} diff --git a/build/deb/ethereum/completions/bash/geth b/build/deb/ethereum/completions/bash/geth deleted file mode 100755 index a78952793e..0000000000 --- a/build/deb/ethereum/completions/bash/geth +++ /dev/null @@ -1,16 +0,0 @@ -_geth_bash_autocomplete() { - if [[ "${COMP_WORDS[0]}" != "source" ]]; then - local cur opts base - COMPREPLY=() - cur="${COMP_WORDS[COMP_CWORD]}" - if [[ "$cur" == "-"* ]]; then - opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} ${cur} --generate-bash-completion ) - else - opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion ) - fi - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) - return 0 - fi -} - -complete -o bashdefault -o default -o nospace -F _geth_bash_autocomplete geth diff --git a/build/deb/ethereum/completions/zsh/_geth b/build/deb/ethereum/completions/zsh/_geth deleted file mode 100644 index 119794c532..0000000000 --- a/build/deb/ethereum/completions/zsh/_geth +++ /dev/null @@ -1,18 +0,0 @@ -_geth_zsh_autocomplete() { - local -a opts - local cur - cur=${words[-1]} - if [[ "$cur" == "-"* ]]; then - opts=("${(@f)$(${words[@]:0:#words[@]-1} ${cur} --generate-bash-completion)}") - else - opts=("${(@f)$(${words[@]:0:#words[@]-1} --generate-bash-completion)}") - fi - - if [[ "${opts[1]}" != "" ]]; then - _describe 'values' opts - else - _files - fi -} - -compdef _geth_zsh_autocomplete geth diff --git a/build/deb/ethereum/deb.changelog b/build/deb/ethereum/deb.changelog deleted file mode 100644 index 83f804a833..0000000000 --- a/build/deb/ethereum/deb.changelog +++ /dev/null @@ -1,5 +0,0 @@ -{{.Name}} ({{.VersionString}}) {{.Distro}}; urgency=low - - * git build of {{.Env.Commit}} - - -- {{.Author}} {{.Time}} diff --git a/build/deb/ethereum/deb.control b/build/deb/ethereum/deb.control deleted file mode 100644 index 3b759f2d04..0000000000 --- a/build/deb/ethereum/deb.control +++ /dev/null @@ -1,25 +0,0 @@ -Source: {{.Name}} -Section: science -Priority: extra -Maintainer: {{.Author}} -Build-Depends: debhelper (>= 8.0.0), {{.GoBootPackage}} -Standards-Version: 3.9.5 -Homepage: https://ethereum.org -Vcs-Git: https://github.com/ethereum/go-ethereum.git -Vcs-Browser: https://github.com/ethereum/go-ethereum - -Package: {{.Name}} -Architecture: any -Depends: ${misc:Depends}, {{.ExeList}} -Description: Meta-package to install geth and other tools - Meta-package to install geth and other tools - -{{range .Executables}} -Package: {{$.ExeName .}} -Conflicts: {{$.ExeConflicts .}} -Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends} -Built-Using: ${misc:Built-Using} -Description: {{.Description}} - {{.Description}} -{{end}} diff --git a/build/deb/ethereum/deb.copyright b/build/deb/ethereum/deb.copyright deleted file mode 100644 index fe6e36ad9d..0000000000 --- a/build/deb/ethereum/deb.copyright +++ /dev/null @@ -1,14 +0,0 @@ -Copyright 2018 The go-ethereum Authors - -go-ethereum is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -go-ethereum is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with go-ethereum. If not, see . diff --git a/build/deb/ethereum/deb.docs b/build/deb/ethereum/deb.docs deleted file mode 100644 index 62deb04972..0000000000 --- a/build/deb/ethereum/deb.docs +++ /dev/null @@ -1 +0,0 @@ -AUTHORS diff --git a/build/deb/ethereum/deb.install b/build/deb/ethereum/deb.install deleted file mode 100644 index 5a624594b0..0000000000 --- a/build/deb/ethereum/deb.install +++ /dev/null @@ -1,5 +0,0 @@ -build/bin/{{.BinaryName}} usr/bin -{{- if eq .BinaryName "geth" }} -build/deb/ethereum/completions/bash/geth etc/bash_completion.d -build/deb/ethereum/completions/zsh/_geth usr/share/zsh/vendor-completions -{{end -}} diff --git a/build/deb/ethereum/deb.rules b/build/deb/ethereum/deb.rules deleted file mode 100644 index 475e628b2f..0000000000 --- a/build/deb/ethereum/deb.rules +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/make -f -# -*- makefile -*- - -# Uncomment this to turn on verbose mode. -#export DH_VERBOSE=1 - -# Launchpad rejects Go's access to $HOME, use custom folders -export GOCACHE=/tmp/go-build -export GOPATH=/tmp/gopath -export GOROOT_BOOTSTRAP={{.GoBootPath}} - -override_dh_auto_clean: - # Don't try to be smart Launchpad, we know our build rules better than you - -override_dh_auto_build: - # We can't download a fresh Go within Launchpad, so we're shipping and building - # one on the fly. However, we can't build it inside the go-ethereum folder as - # bootstrapping clashes with go modules, so build in a sibling folder. - # - # We're also shipping the bootstrapper as of Go 1.20 as it had minimum version - # requirements opposed to older versions of Go. - (mv .goboot ../ && cd ../.goboot/src && ./make.bash) - (mv .go ../ && cd ../.go/src && GOROOT_BOOTSTRAP=`pwd`/../../.goboot ./make.bash) - - # We can't download external go modules within Launchpad, so we're shipping the - # entire dependency source cache with go-ethereum. - mkdir -p $(GOPATH)/pkg - mv .mod $(GOPATH)/pkg/mod - - # A fresh Go was built, all dependency downloads faked, hope build works now - ../.go/bin/go run build/ci.go install -git-commit={{.Env.Commit}} -git-branch={{.Env.Branch}} -git-tag={{.Env.Tag}} -buildnum={{.Env.Buildnum}} -pull-request={{.Env.IsPullRequest}} - -override_dh_auto_test: - -%: - dh $@ diff --git a/build/goimports.sh b/build/goimports.sh deleted file mode 100755 index 1fcace6a4b..0000000000 --- a/build/goimports.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -find_files() { - find . ! \( \ - \( \ - -path '.github' \ - -o -path './build/_workspace' \ - -o -path './build/bin' \ - -o -path './crypto/bn256' \ - -o -path '*/vendor/*' \ - \) -prune \ - \) -name '*.go' -} - -GOFMT="gofmt -s -w" -GOIMPORTS="goimports -w" -find_files | xargs $GOFMT -find_files | xargs $GOIMPORTS diff --git a/build/nsis.envvarupdate.nsh b/build/nsis.envvarupdate.nsh deleted file mode 100644 index 95c2f1f639..0000000000 --- a/build/nsis.envvarupdate.nsh +++ /dev/null @@ -1,327 +0,0 @@ -/** - * EnvVarUpdate.nsh - * : Environmental Variables: append, prepend, and remove entries - * - * WARNING: If you use StrFunc.nsh header then include it before this file - * with all required definitions. This is to avoid conflicts - * - * Usage: - * ${EnvVarUpdate} "ResultVar" "EnvVarName" "Action" "RegLoc" "PathString" - * - * Credits: - * Version 1.0 - * * Cal Turney (turnec2) - * * Amir Szekely (KiCHiK) and e-circ for developing the forerunners of this - * function: AddToPath, un.RemoveFromPath, AddToEnvVar, un.RemoveFromEnvVar, - * WriteEnvStr, and un.DeleteEnvStr - * * Diego Pedroso (deguix) for StrTok - * * Kevin English (kenglish_hi) for StrContains - * * Hendri Adriaens (Smile2Me), Diego Pedroso (deguix), and Dan Fuhry - * (dandaman32) for StrReplace - * - * Version 1.1 (compatibility with StrFunc.nsh) - * * techtonik - * - * http://nsis.sourceforge.net/Environmental_Variables:_append%2C_prepend%2C_and_remove_entries - * - */ - - -!ifndef ENVVARUPDATE_FUNCTION -!define ENVVARUPDATE_FUNCTION -!verbose push -!verbose 3 -!include "LogicLib.nsh" -!include "WinMessages.NSH" -!include "StrFunc.nsh" - -; ---- Fix for conflict if StrFunc.nsh is already includes in main file ----------------------- -!macro _IncludeStrFunction StrFuncName - !ifndef ${StrFuncName}_INCLUDED - ${${StrFuncName}} - !endif - !ifndef Un${StrFuncName}_INCLUDED - ${Un${StrFuncName}} - !endif - !define un.${StrFuncName} '${Un${StrFuncName}}' -!macroend - -!insertmacro _IncludeStrFunction StrTok -!insertmacro _IncludeStrFunction StrStr -!insertmacro _IncludeStrFunction StrRep - -; ---------------------------------- Macro Definitions ---------------------------------------- -!macro _EnvVarUpdateConstructor ResultVar EnvVarName Action Regloc PathString - Push "${EnvVarName}" - Push "${Action}" - Push "${RegLoc}" - Push "${PathString}" - Call EnvVarUpdate - Pop "${ResultVar}" -!macroend -!define EnvVarUpdate '!insertmacro "_EnvVarUpdateConstructor"' - -!macro _unEnvVarUpdateConstructor ResultVar EnvVarName Action Regloc PathString - Push "${EnvVarName}" - Push "${Action}" - Push "${RegLoc}" - Push "${PathString}" - Call un.EnvVarUpdate - Pop "${ResultVar}" -!macroend -!define un.EnvVarUpdate '!insertmacro "_unEnvVarUpdateConstructor"' -; ---------------------------------- Macro Definitions end------------------------------------- - -;----------------------------------- EnvVarUpdate start---------------------------------------- -!define hklm_all_users 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"' -!define hkcu_current_user 'HKCU "Environment"' - -!macro EnvVarUpdate UN - -Function ${UN}EnvVarUpdate - - Push $0 - Exch 4 - Exch $1 - Exch 3 - Exch $2 - Exch 2 - Exch $3 - Exch - Exch $4 - Push $5 - Push $6 - Push $7 - Push $8 - Push $9 - Push $R0 - - /* After this point: - ------------------------- - $0 = ResultVar (returned) - $1 = EnvVarName (input) - $2 = Action (input) - $3 = RegLoc (input) - $4 = PathString (input) - $5 = Orig EnvVar (read from registry) - $6 = Len of $0 (temp) - $7 = tempstr1 (temp) - $8 = Entry counter (temp) - $9 = tempstr2 (temp) - $R0 = tempChar (temp) */ - - ; Step 1: Read contents of EnvVarName from RegLoc - ; - ; Check for empty EnvVarName - ${If} $1 == "" - SetErrors - DetailPrint "ERROR: EnvVarName is blank" - Goto EnvVarUpdate_Restore_Vars - ${EndIf} - - ; Check for valid Action - ${If} $2 != "A" - ${AndIf} $2 != "P" - ${AndIf} $2 != "R" - SetErrors - DetailPrint "ERROR: Invalid Action - must be A, P, or R" - Goto EnvVarUpdate_Restore_Vars - ${EndIf} - - ${If} $3 == HKLM - ReadRegStr $5 ${hklm_all_users} $1 ; Get EnvVarName from all users into $5 - ${ElseIf} $3 == HKCU - ReadRegStr $5 ${hkcu_current_user} $1 ; Read EnvVarName from current user into $5 - ${Else} - SetErrors - DetailPrint 'ERROR: Action is [$3] but must be "HKLM" or HKCU"' - Goto EnvVarUpdate_Restore_Vars - ${EndIf} - - ; Check for empty PathString - ${If} $4 == "" - SetErrors - DetailPrint "ERROR: PathString is blank" - Goto EnvVarUpdate_Restore_Vars - ${EndIf} - - ; Make sure we've got some work to do - ${If} $5 == "" - ${AndIf} $2 == "R" - SetErrors - DetailPrint "$1 is empty - Nothing to remove" - Goto EnvVarUpdate_Restore_Vars - ${EndIf} - - ; Step 2: Scrub EnvVar - ; - StrCpy $0 $5 ; Copy the contents to $0 - ; Remove spaces around semicolons (NOTE: spaces before the 1st entry or - ; after the last one are not removed here but instead in Step 3) - ${If} $0 != "" ; If EnvVar is not empty ... - ${Do} - ${${UN}StrStr} $7 $0 " ;" - ${If} $7 == "" - ${ExitDo} - ${EndIf} - ${${UN}StrRep} $0 $0 " ;" ";" ; Remove ';' - ${Loop} - ${Do} - ${${UN}StrStr} $7 $0 "; " - ${If} $7 == "" - ${ExitDo} - ${EndIf} - ${${UN}StrRep} $0 $0 "; " ";" ; Remove ';' - ${Loop} - ${Do} - ${${UN}StrStr} $7 $0 ";;" - ${If} $7 == "" - ${ExitDo} - ${EndIf} - ${${UN}StrRep} $0 $0 ";;" ";" - ${Loop} - - ; Remove a leading or trailing semicolon from EnvVar - StrCpy $7 $0 1 0 - ${If} $7 == ";" - StrCpy $0 $0 "" 1 ; Change ';' to '' - ${EndIf} - StrLen $6 $0 - IntOp $6 $6 - 1 - StrCpy $7 $0 1 $6 - ${If} $7 == ";" - StrCpy $0 $0 $6 ; Change ';' to '' - ${EndIf} - ; DetailPrint "Scrubbed $1: [$0]" ; Uncomment to debug - ${EndIf} - - /* Step 3. Remove all instances of the target path/string (even if "A" or "P") - $6 = bool flag (1 = found and removed PathString) - $7 = a string (e.g. path) delimited by semicolon(s) - $8 = entry counter starting at 0 - $9 = copy of $0 - $R0 = tempChar */ - - ${If} $5 != "" ; If EnvVar is not empty ... - StrCpy $9 $0 - StrCpy $0 "" - StrCpy $8 0 - StrCpy $6 0 - - ${Do} - ${${UN}StrTok} $7 $9 ";" $8 "0" ; $7 = next entry, $8 = entry counter - - ${If} $7 == "" ; If we've run out of entries, - ${ExitDo} ; were done - ${EndIf} ; - - ; Remove leading and trailing spaces from this entry (critical step for Action=Remove) - ${Do} - StrCpy $R0 $7 1 - ${If} $R0 != " " - ${ExitDo} - ${EndIf} - StrCpy $7 $7 "" 1 ; Remove leading space - ${Loop} - ${Do} - StrCpy $R0 $7 1 -1 - ${If} $R0 != " " - ${ExitDo} - ${EndIf} - StrCpy $7 $7 -1 ; Remove trailing space - ${Loop} - ${If} $7 == $4 ; If string matches, remove it by not appending it - StrCpy $6 1 ; Set 'found' flag - ${ElseIf} $7 != $4 ; If string does NOT match - ${AndIf} $0 == "" ; and the 1st string being added to $0, - StrCpy $0 $7 ; copy it to $0 without a prepended semicolon - ${ElseIf} $7 != $4 ; If string does NOT match - ${AndIf} $0 != "" ; and this is NOT the 1st string to be added to $0, - StrCpy $0 $0;$7 ; append path to $0 with a prepended semicolon - ${EndIf} ; - - IntOp $8 $8 + 1 ; Bump counter - ${Loop} ; Check for duplicates until we run out of paths - ${EndIf} - - ; Step 4: Perform the requested Action - ; - ${If} $2 != "R" ; If Append or Prepend - ${If} $6 == 1 ; And if we found the target - DetailPrint "Target is already present in $1. It will be removed and" - ${EndIf} - ${If} $0 == "" ; If EnvVar is (now) empty - StrCpy $0 $4 ; just copy PathString to EnvVar - ${If} $6 == 0 ; If found flag is either 0 - ${OrIf} $6 == "" ; or blank (if EnvVarName is empty) - DetailPrint "$1 was empty and has been updated with the target" - ${EndIf} - ${ElseIf} $2 == "A" ; If Append (and EnvVar is not empty), - StrCpy $0 $0;$4 ; append PathString - ${If} $6 == 1 - DetailPrint "appended to $1" - ${Else} - DetailPrint "Target was appended to $1" - ${EndIf} - ${Else} ; If Prepend (and EnvVar is not empty), - StrCpy $0 $4;$0 ; prepend PathString - ${If} $6 == 1 - DetailPrint "prepended to $1" - ${Else} - DetailPrint "Target was prepended to $1" - ${EndIf} - ${EndIf} - ${Else} ; If Action = Remove - ${If} $6 == 1 ; and we found the target - DetailPrint "Target was found and removed from $1" - ${Else} - DetailPrint "Target was NOT found in $1 (nothing to remove)" - ${EndIf} - ${If} $0 == "" - DetailPrint "$1 is now empty" - ${EndIf} - ${EndIf} - - ; Step 5: Update the registry at RegLoc with the updated EnvVar and announce the change - ; - ClearErrors - ${If} $3 == HKLM - WriteRegExpandStr ${hklm_all_users} $1 $0 ; Write it in all users section - ${ElseIf} $3 == HKCU - WriteRegExpandStr ${hkcu_current_user} $1 $0 ; Write it to current user section - ${EndIf} - - IfErrors 0 +4 - MessageBox MB_OK|MB_ICONEXCLAMATION "Could not write updated $1 to $3" - DetailPrint "Could not write updated $1 to $3" - Goto EnvVarUpdate_Restore_Vars - - ; "Export" our change - SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 - - EnvVarUpdate_Restore_Vars: - ; - ; Restore the user's variables and return ResultVar - Pop $R0 - Pop $9 - Pop $8 - Pop $7 - Pop $6 - Pop $5 - Pop $4 - Pop $3 - Pop $2 - Pop $1 - Push $0 ; Push my $0 (ResultVar) - Exch - Pop $0 ; Restore his $0 - -FunctionEnd - -!macroend ; EnvVarUpdate UN -!insertmacro EnvVarUpdate "" -!insertmacro EnvVarUpdate "un." -;----------------------------------- EnvVarUpdate end---------------------------------------- - -!verbose pop -!endif \ No newline at end of file diff --git a/build/nsis.geth.nsi b/build/nsis.geth.nsi deleted file mode 100644 index 03710dd95d..0000000000 --- a/build/nsis.geth.nsi +++ /dev/null @@ -1,70 +0,0 @@ -# Builds a Windows installer with NSIS. -# It expects the following command line arguments: -# - OUTPUTFILE, filename of the installer (without extension) -# - MAJORVERSION, major build version -# - MINORVERSION, minor build version -# - BUILDVERSION, build id version -# -# The created installer executes the following steps: -# 1. install geth for all users -# 2. install optional development tools such as abigen -# 3. create an uninstaller -# 4. configures the Windows firewall for geth -# 5. create geth, attach and uninstall start menu entries -# 6. configures the registry that allows Windows to manage the package through its platform tools -# 7. adds the environment system wide variable ETHEREUM_SOCKET -# 8. adds the install directory to %PATH% -# -# Requirements: -# - NSIS, http://nsis.sourceforge.net/Main_Page -# - NSIS Large Strings build, http://nsis.sourceforge.net/Special_Builds -# - SFP, http://nsis.sourceforge.net/NSIS_Simple_Firewall_Plugin (put dll in NSIS\Plugins\x86-ansi) -# -# After installing NSIS extra the NSIS Large Strings build zip and replace the makensis.exe and the -# files found in Stub. -# -# based on: http://nsis.sourceforge.net/A_simple_installer_with_start_menu_shortcut_and_uninstaller -# -# TODO: -# - sign installer -CRCCheck on - -!define GROUPNAME "Ethereum" -!define APPNAME "Geth" -!define DESCRIPTION "Official Go implementation of the Ethereum protocol" -!addplugindir .\ - -# Require admin rights on NT6+ (When UAC is turned on) -RequestExecutionLevel admin - -# Use LZMA compression -SetCompressor /SOLID lzma - -!include LogicLib.nsh -!include PathUpdate.nsh -!include EnvVarUpdate.nsh - -!macro VerifyUserIsAdmin -UserInfo::GetAccountType -pop $0 -${If} $0 != "admin" # Require admin rights on NT4+ - messageBox mb_iconstop "Administrator rights required!" - setErrorLevel 740 # ERROR_ELEVATION_REQUIRED - quit -${EndIf} -!macroend - -function .onInit - # make vars are global for all users since geth is installed global - setShellVarContext all - !insertmacro VerifyUserIsAdmin - - ${If} ${ARCH} == "amd64" - StrCpy $InstDir "$PROGRAMFILES64\${APPNAME}" - ${Else} - StrCpy $InstDir "$PROGRAMFILES32\${APPNAME}" - ${Endif} -functionEnd - -!include install.nsh -!include uninstall.nsh diff --git a/build/nsis.install.nsh b/build/nsis.install.nsh deleted file mode 100644 index 9b73148a44..0000000000 --- a/build/nsis.install.nsh +++ /dev/null @@ -1,103 +0,0 @@ -Name "geth ${MAJORVERSION}.${MINORVERSION}.${BUILDVERSION}" # VERSION variables set through command line arguments -InstallDir "$InstDir" -OutFile "${OUTPUTFILE}" # set through command line arguments - -# Links for "Add/Remove Programs" -!define HELPURL "https://github.com/ethereum/go-ethereum/issues" -!define UPDATEURL "https://github.com/ethereum/go-ethereum/releases" -!define ABOUTURL "https://github.com/ethereum/go-ethereum#ethereum-go" -!define /date NOW "%Y%m%d" - -PageEx license - LicenseData {{.License}} -PageExEnd - -# Install geth binary -Section "Geth" GETH_IDX - SetOutPath $INSTDIR - file {{.Geth}} - - # Create start menu launcher - createDirectory "$SMPROGRAMS\${APPNAME}" - createShortCut "$SMPROGRAMS\${APPNAME}\${APPNAME}.lnk" "$INSTDIR\geth.exe" - createShortCut "$SMPROGRAMS\${APPNAME}\Attach.lnk" "$INSTDIR\geth.exe" "attach" - createShortCut "$SMPROGRAMS\${APPNAME}\Uninstall.lnk" "$INSTDIR\uninstall.exe" - - # Firewall - remove rules (if exists) - SimpleFC::AdvRemoveRule "Geth incoming peers (TCP:30303)" - SimpleFC::AdvRemoveRule "Geth outgoing peers (TCP:30303)" - SimpleFC::AdvRemoveRule "Geth UDP discovery (UDP:30303)" - - # Firewall - add rules - SimpleFC::AdvAddRule "Geth incoming peers (TCP:30303)" "" 6 1 1 2147483647 1 "$INSTDIR\geth.exe" "" "" "Ethereum" 30303 "" "" "" - SimpleFC::AdvAddRule "Geth outgoing peers (TCP:30303)" "" 6 2 1 2147483647 1 "$INSTDIR\geth.exe" "" "" "Ethereum" "" 30303 "" "" - SimpleFC::AdvAddRule "Geth UDP discovery (UDP:30303)" "" 17 2 1 2147483647 1 "$INSTDIR\geth.exe" "" "" "Ethereum" "" 30303 "" "" - - # Set default IPC endpoint (https://github.com/ethereum/EIPs/issues/147) - ${EnvVarUpdate} $0 "ETHEREUM_SOCKET" "R" "HKLM" "\\.\pipe\geth.ipc" - ${EnvVarUpdate} $0 "ETHEREUM_SOCKET" "A" "HKLM" "\\.\pipe\geth.ipc" - - # Add instdir to PATH - Push "$INSTDIR" - Call AddToPath -SectionEnd - -# Install optional develop tools. -Section /o "Development tools" DEV_TOOLS_IDX - SetOutPath $INSTDIR - {{range .DevTools}}file {{.}} - {{end}} -SectionEnd - -# Return on top of stack the total size (as DWORD) of the selected/installed sections. -Var GetInstalledSize.total -Function GetInstalledSize - StrCpy $GetInstalledSize.total 0 - - ${if} ${SectionIsSelected} ${GETH_IDX} - SectionGetSize ${GETH_IDX} $0 - IntOp $GetInstalledSize.total $GetInstalledSize.total + $0 - ${endif} - - ${if} ${SectionIsSelected} ${DEV_TOOLS_IDX} - SectionGetSize ${DEV_TOOLS_IDX} $0 - IntOp $GetInstalledSize.total $GetInstalledSize.total + $0 - ${endif} - - IntFmt $GetInstalledSize.total "0x%08X" $GetInstalledSize.total - Push $GetInstalledSize.total -FunctionEnd - -# Write registry, Windows uses these values in various tools such as add/remove program. -# PowerShell: Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, InstallLocation, InstallDate | Format-Table –AutoSize -function .onInstSuccess - # Save information in registry in HKEY_LOCAL_MACHINE branch, Windows add/remove functionality depends on this - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "DisplayName" "${GROUPNAME} - ${APPNAME} - ${DESCRIPTION}" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "UninstallString" "$\"$INSTDIR\uninstall.exe$\"" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "QuietUninstallString" "$\"$INSTDIR\uninstall.exe$\" /S" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "InstallLocation" "$INSTDIR" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "InstallDate" "${NOW}" - # Wait for Alex - #WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "DisplayIcon" "$\"$INSTDIR\logo.ico$\"" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "Publisher" "${GROUPNAME}" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "HelpLink" "${HELPURL}" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "URLUpdateInfo" "${UPDATEURL}" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "URLInfoAbout" "${ABOUTURL}" - WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "DisplayVersion" "${MAJORVERSION}.${MINORVERSION}.${BUILDVERSION}" - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "VersionMajor" ${MAJORVERSION} - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "VersionMinor" ${MINORVERSION} - # There is no option for modifying or repairing the install - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "NoModify" 1 - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "NoRepair" 1 - - Call GetInstalledSize - Pop $0 - WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" "EstimatedSize" "$0" - - # Create uninstaller - writeUninstaller "$INSTDIR\uninstall.exe" -functionEnd - -Page components -Page directory -Page instfiles diff --git a/build/nsis.pathupdate.nsh b/build/nsis.pathupdate.nsh deleted file mode 100644 index f54b7e3e13..0000000000 --- a/build/nsis.pathupdate.nsh +++ /dev/null @@ -1,153 +0,0 @@ -!include "WinMessages.nsh" - -; see https://support.microsoft.com/en-us/kb/104011 -!define Environ 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"' -; HKEY_LOCAL_MACHINE = 0x80000002 - -; AddToPath - Appends dir to PATH -; (does not work on Win9x/ME) -; -; Usage: -; Push "dir" -; Call AddToPath -Function AddToPath - Exch $0 - Push $1 - Push $2 - Push $3 - Push $4 - - ; NSIS ReadRegStr returns empty string on string overflow - ; Native calls are used here to check actual length of PATH - ; $4 = RegOpenKey(HKEY_LOCAL_MACHINE, "SYSTEM\CurrentControlSet\Control\Session Manager\Environment", &$3) - System::Call "advapi32::RegOpenKey(i 0x80000002, t'SYSTEM\CurrentControlSet\Control\Session Manager\Environment', *i.r3) i.r4" - IntCmp $4 0 0 done done - - ; $4 = RegQueryValueEx($3, "PATH", (DWORD*)0, (DWORD*)0, &$1, ($2=NSIS_MAX_STRLEN, &$2)) - ; RegCloseKey($3) - System::Call "advapi32::RegQueryValueEx(i $3, t'PATH', i 0, i 0, t.r1, *i ${NSIS_MAX_STRLEN} r2) i.r4" - System::Call "advapi32::RegCloseKey(i $3)" - - IntCmp $4 234 0 +4 +4 ; $4 == ERROR_MORE_DATA - DetailPrint "AddToPath: original length $2 > ${NSIS_MAX_STRLEN}" - MessageBox MB_OK "PATH not updated, original length $2 > ${NSIS_MAX_STRLEN}" - Goto done - - IntCmp $4 0 +5 ; $4 != NO_ERROR - IntCmp $4 2 +3 ; $4 != ERROR_FILE_NOT_FOUND - DetailPrint "AddToPath: unexpected error code $4" - Goto done - StrCpy $1 "" - - ; Check if already in PATH - Push "$1;" - Push "$0;" - Call StrStr - Pop $2 - StrCmp $2 "" 0 done - Push "$1;" - Push "$0\;" - Call StrStr - Pop $2 - StrCmp $2 "" 0 done - - ; Prevent NSIS string overflow - StrLen $2 $0 - StrLen $3 $1 - IntOp $2 $2 + $3 - IntOp $2 $2 + 2 ; $2 = strlen(dir) + strlen(PATH) + sizeof(";") - IntCmp $2 ${NSIS_MAX_STRLEN} +4 +4 0 - DetailPrint "AddToPath: new length $2 > ${NSIS_MAX_STRLEN}" - MessageBox MB_OK "PATH not updated, new length $2 > ${NSIS_MAX_STRLEN}." - Goto done - - ; Append dir to PATH - DetailPrint "Add to PATH: $0" - StrCpy $2 $1 1 -1 - StrCmp $2 ";" 0 +2 - StrCpy $1 $1 -1 ; remove trailing ';' - StrCmp $1 "" +2 ; no leading ';' - StrCpy $0 "$1;$0" - - WriteRegExpandStr ${Environ} "PATH" $0 - SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 - -done: - Pop $4 - Pop $3 - Pop $2 - Pop $1 - Pop $0 -FunctionEnd - - -; RemoveFromPath - Removes dir from PATH -; -; Usage: -; Push "dir" -; Call RemoveFromPath -Function un.RemoveFromPath - Exch $0 - Push $1 - Push $2 - Push $3 - Push $4 - Push $5 - Push $6 - - ; NSIS ReadRegStr returns empty string on string overflow - ; Native calls are used here to check actual length of PATH - ; $4 = RegOpenKey(HKEY_LOCAL_MACHINE, "SYSTEM\CurrentControlSet\Control\Session Manager\Environment", &$3) - System::Call "advapi32::RegOpenKey(i 0x80000002, t'SYSTEM\CurrentControlSet\Control\Session Manager\Environment', *i.r3) i.r4" - IntCmp $4 0 0 done done - - ; $4 = RegQueryValueEx($3, "PATH", (DWORD*)0, (DWORD*)0, &$1, ($2=NSIS_MAX_STRLEN, &$2)) - ; RegCloseKey($3) - System::Call "advapi32::RegQueryValueEx(i $3, t'PATH', i 0, i 0, t.r1, *i ${NSIS_MAX_STRLEN} r2) i.r4" - System::Call "advapi32::RegCloseKey(i $3)" - - IntCmp $4 234 0 +4 +4 ; $4 == ERROR_MORE_DATA - DetailPrint "RemoveFromPath: original length $2 > ${NSIS_MAX_STRLEN}" - MessageBox MB_OK "PATH not updated, original length $2 > ${NSIS_MAX_STRLEN}" - Goto done - - IntCmp $4 0 +5 ; $4 != NO_ERROR - IntCmp $4 2 +3 ; $4 != ERROR_FILE_NOT_FOUND - DetailPrint "RemoveFromPath: unexpected error code $4" - Goto done - StrCpy $1 "" - - ; length < ${NSIS_MAX_STRLEN} -> ReadRegStr can be used - ReadRegStr $1 ${Environ} "PATH" - StrCpy $5 $1 1 -1 - StrCmp $5 ";" +2 - StrCpy $1 "$1;" ; ensure trailing ';' - Push $1 - Push "$0;" - Call un.StrStr - Pop $2 ; pos of our dir - StrCmp $2 "" done - - DetailPrint "Remove from PATH: $0" - StrLen $3 "$0;" - StrLen $4 $2 - StrCpy $5 $1 -$4 ; $5 is now the part before the path to remove - StrCpy $6 $2 "" $3 ; $6 is now the part after the path to remove - StrCpy $3 "$5$6" - StrCpy $5 $3 1 -1 - StrCmp $5 ";" 0 +2 - StrCpy $3 $3 -1 ; remove trailing ';' - WriteRegExpandStr ${Environ} "PATH" $3 - SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 - -done: - Pop $6 - Pop $5 - Pop $4 - Pop $3 - Pop $2 - Pop $1 - Pop $0 -FunctionEnd - - diff --git a/build/nsis.simplefc.dll b/build/nsis.simplefc.dll deleted file mode 100644 index 73b7d9634d..0000000000 Binary files a/build/nsis.simplefc.dll and /dev/null differ diff --git a/build/nsis.simplefc.source.zip b/build/nsis.simplefc.source.zip deleted file mode 100644 index d7476022ad..0000000000 Binary files a/build/nsis.simplefc.source.zip and /dev/null differ diff --git a/build/nsis.uninstall.nsh b/build/nsis.uninstall.nsh deleted file mode 100644 index 6358faa74e..0000000000 --- a/build/nsis.uninstall.nsh +++ /dev/null @@ -1,33 +0,0 @@ -Section "Uninstall" - # uninstall for all users - setShellVarContext all - - # Delete (optionally) installed files - {{range $}}Delete $INSTDIR\{{.}} - {{end}} - Delete $INSTDIR\uninstall.exe - - # Delete install directory - rmDir $INSTDIR - - # Delete start menu launcher - Delete "$SMPROGRAMS\${APPNAME}\${APPNAME}.lnk" - Delete "$SMPROGRAMS\${APPNAME}\Attach.lnk" - Delete "$SMPROGRAMS\${APPNAME}\Uninstall.lnk" - rmDir "$SMPROGRAMS\${APPNAME}" - - # Firewall - remove rules if exists - SimpleFC::AdvRemoveRule "Geth incoming peers (TCP:30303)" - SimpleFC::AdvRemoveRule "Geth outgoing peers (TCP:30303)" - SimpleFC::AdvRemoveRule "Geth UDP discovery (UDP:30303)" - - # Remove IPC endpoint (https://github.com/ethereum/EIPs/issues/147) - ${un.EnvVarUpdate} $0 "ETHEREUM_SOCKET" "R" "HKLM" "\\.\pipe\geth.ipc" - - # Remove install directory from PATH - Push "$INSTDIR" - Call un.RemoveFromPath - - # Cleanup registry (deletes all sub keys) - DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${GROUPNAME} ${APPNAME}" -SectionEnd diff --git a/build/tools/tools.go b/build/tools/tools.go deleted file mode 100644 index 506e26eeff..0000000000 --- a/build/tools/tools.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2019 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -//go:build tools -// +build tools - -package tools - -import ( - // Tool imports for go:generate. - _ "github.com/fjl/gencodec" - _ "github.com/golang/protobuf/protoc-gen-go" - _ "golang.org/x/tools/cmd/stringer" -) diff --git a/build/travis_keepalive.sh b/build/travis_keepalive.sh deleted file mode 100755 index 77cc623eaf..0000000000 --- a/build/travis_keepalive.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env bash - -# travis_keepalive runs the given command and preserves its return value, -# while it forks a child process what periodically produces a log line, -# so that Travis won't abort the build after 10 minutes. - -# Why? -# `t.Log()` in Go holds the buffer until the test does not pass or fail, -# and `-race` can increase the execution time by 2-20x. - -set -euo pipefail - -readonly KEEPALIVE_INTERVAL=300 # seconds => 5m - -main() { - keepalive - $@ -} - -# Keepalive produces a log line in each KEEPALIVE_INTERVAL. -keepalive() { - local child_pid - # Note: We fork here! - repeat "keepalive" & - child_pid=$! - ensureChildOnEXIT "${child_pid}" -} - -repeat() { - local this="$1" - while true; do - echo "${this}" - sleep "${KEEPALIVE_INTERVAL}" - done -} - -# Ensures that the child gets killed on normal program exit. -ensureChildOnEXIT() { - # Note: SIGINT and SIGTERM are forwarded to the child process by Bash - # automatically, so we don't have to deal with signals. - - local child_pid="$1" - trap "kill ${child_pid}" EXIT -} - -main "$@" diff --git a/build/update-license.go b/build/update-license.go deleted file mode 100644 index f61536470a..0000000000 --- a/build/update-license.go +++ /dev/null @@ -1,432 +0,0 @@ -// Copyright 2018 The go-ethereum Authors -// This file is part of the go-ethereum library. -// -// The go-ethereum library is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// The go-ethereum library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with the go-ethereum library. If not, see . - -//go:build none -// +build none - -/* -This command generates GPL license headers on top of all source files. -You can run it once per month, before cutting a release or just -whenever you feel like it. - - go run update-license.go - -All authors (people who have contributed code) are listed in the -AUTHORS file. The author names are mapped and deduplicated using the -.mailmap file. You can use .mailmap to set the canonical name and -address for each author. See git-shortlog(1) for an explanation of the -.mailmap format. - -Please review the resulting diff to check whether the correct -copyright assignments are performed. -*/ - -package main - -import ( - "bufio" - "bytes" - "fmt" - "log" - "os" - "os/exec" - "path/filepath" - "regexp" - "runtime" - "sort" - "strconv" - "strings" - "sync" - "text/template" - "time" -) - -var ( - // only files with these extensions will be considered - extensions = []string{".go", ".js", ".qml"} - - // paths with any of these prefixes will be skipped - skipPrefixes = []string{ - // boring stuff - "vendor/", "tests/testdata/", "build/", - - // don't relicense vendored sources - "cmd/internal/browser", - "common/bitutil/bitutil", - "common/prque/", - "consensus/ethash/xor.go", - "crypto/blake2b/", - "crypto/bn256/", - "crypto/bls12381/", - "crypto/ecies/", - "graphql/graphiql.go", - "internal/jsre/deps", - "log/", - "metrics/", - "signer/rules/deps", - - // skip special licenses - "crypto/secp256k1", // Relicensed to BSD-3 via https://github.com/ethereum/go-ethereum/pull/17225 - } - - // paths with this prefix are licensed as GPL. all other files are LGPL. - gplPrefixes = []string{"cmd/"} - - // this regexp must match the entire license comment at the - // beginning of each file. - licenseCommentRE = regexp.MustCompile(`^//\s*(Copyright|This file is part of).*?\n(?://.*?\n)*\n*`) - - // this text appears at the start of AUTHORS - authorsFileHeader = "# This is the official list of go-ethereum authors for copyright purposes.\n\n" -) - -// this template generates the license comment. -// its input is an info structure. -var licenseT = template.Must(template.New("").Parse(` -// Copyright {{.Year}} The go-ethereum Authors -// This file is part of {{.Whole false}}. -// -// {{.Whole true}} is free software: you can redistribute it and/or modify -// it under the terms of the GNU {{.License}} as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// {{.Whole true}} is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU {{.License}} for more details. -// -// You should have received a copy of the GNU {{.License}} -// along with {{.Whole false}}. If not, see . - -`[1:])) - -type info struct { - file string - Year int64 -} - -func (i info) License() string { - if i.gpl() { - return "General Public License" - } - return "Lesser General Public License" -} - -func (i info) ShortLicense() string { - if i.gpl() { - return "GPL" - } - return "LGPL" -} - -func (i info) Whole(startOfSentence bool) string { - if i.gpl() { - return "go-ethereum" - } - if startOfSentence { - return "The go-ethereum library" - } - return "the go-ethereum library" -} - -func (i info) gpl() bool { - for _, p := range gplPrefixes { - if strings.HasPrefix(i.file, p) { - return true - } - } - return false -} - -// authors implements the sort.Interface for strings in case-insensitive mode. -type authors []string - -func (as authors) Len() int { return len(as) } -func (as authors) Less(i, j int) bool { return strings.ToLower(as[i]) < strings.ToLower(as[j]) } -func (as authors) Swap(i, j int) { as[i], as[j] = as[j], as[i] } - -func main() { - var ( - files = getFiles() - filec = make(chan string) - infoc = make(chan *info, 20) - wg sync.WaitGroup - ) - - writeAuthors(files) - - go func() { - for _, f := range files { - filec <- f - } - close(filec) - }() - for i := runtime.NumCPU(); i >= 0; i-- { - // getting file info is slow and needs to be parallel. - // it traverses git history for each file. - wg.Add(1) - go getInfo(filec, infoc, &wg) - } - go func() { - wg.Wait() - close(infoc) - }() - writeLicenses(infoc) -} - -func skipFile(path string) bool { - if strings.Contains(path, "/testdata/") { - return true - } - for _, p := range skipPrefixes { - if strings.HasPrefix(path, p) { - return true - } - } - return false -} - -func getFiles() []string { - cmd := exec.Command("git", "ls-tree", "-r", "--name-only", "HEAD") - var files []string - err := doLines(cmd, func(line string) { - if skipFile(line) { - return - } - ext := filepath.Ext(line) - for _, wantExt := range extensions { - if ext == wantExt { - goto keep - } - } - return - keep: - files = append(files, line) - }) - if err != nil { - log.Fatal("error getting files:", err) - } - return files -} - -var authorRegexp = regexp.MustCompile(`\s*[0-9]+\s*(.*)`) - -func gitAuthors(files []string) []string { - cmds := []string{"shortlog", "-s", "-n", "-e", "HEAD", "--"} - cmds = append(cmds, files...) - cmd := exec.Command("git", cmds...) - var authors []string - err := doLines(cmd, func(line string) { - m := authorRegexp.FindStringSubmatch(line) - if len(m) > 1 { - authors = append(authors, m[1]) - } - }) - if err != nil { - log.Fatalln("error getting authors:", err) - } - return authors -} - -func readAuthors() []string { - content, err := os.ReadFile("AUTHORS") - if err != nil && !os.IsNotExist(err) { - log.Fatalln("error reading AUTHORS:", err) - } - var authors []string - for _, a := range bytes.Split(content, []byte("\n")) { - if len(a) > 0 && a[0] != '#' { - authors = append(authors, string(a)) - } - } - // Retranslate existing authors through .mailmap. - // This should catch email address changes. - authors = mailmapLookup(authors) - return authors -} - -func mailmapLookup(authors []string) []string { - if len(authors) == 0 { - return nil - } - cmds := []string{"check-mailmap", "--"} - cmds = append(cmds, authors...) - cmd := exec.Command("git", cmds...) - var translated []string - err := doLines(cmd, func(line string) { - translated = append(translated, line) - }) - if err != nil { - log.Fatalln("error translating authors:", err) - } - return translated -} - -func writeAuthors(files []string) { - var ( - dedup = make(map[string]bool) - list []string - ) - // Add authors that Git reports as contributors. - // This is the primary source of author information. - for _, a := range gitAuthors(files) { - if la := strings.ToLower(a); !dedup[la] { - list = append(list, a) - dedup[la] = true - } - } - // Add existing authors from the file. This should ensure that we - // never lose authors, even if Git stops listing them. We can also - // add authors manually this way. - for _, a := range readAuthors() { - if la := strings.ToLower(a); !dedup[la] { - list = append(list, a) - dedup[la] = true - } - } - // Write sorted list of authors back to the file. - sort.Sort(authors(list)) - content := new(bytes.Buffer) - content.WriteString(authorsFileHeader) - for _, a := range list { - content.WriteString(a) - content.WriteString("\n") - } - fmt.Println("writing AUTHORS") - if err := os.WriteFile("AUTHORS", content.Bytes(), 0644); err != nil { - log.Fatalln(err) - } -} - -func getInfo(files <-chan string, out chan<- *info, wg *sync.WaitGroup) { - for file := range files { - stat, err := os.Lstat(file) - if err != nil { - fmt.Printf("ERROR %s: %v\n", file, err) - continue - } - if !stat.Mode().IsRegular() { - continue - } - if isGenerated(file) { - continue - } - info, err := fileInfo(file) - if err != nil { - fmt.Printf("ERROR %s: %v\n", file, err) - continue - } - out <- info - } - wg.Done() -} - -func isGenerated(file string) bool { - fd, err := os.Open(file) - if err != nil { - return false - } - defer fd.Close() - buf := make([]byte, 2048) - n, err := fd.Read(buf) - if err != nil { - return false - } - buf = buf[:n] - for _, l := range bytes.Split(buf, []byte("\n")) { - if bytes.HasPrefix(l, []byte("// Code generated")) { - return true - } - } - return false -} - -// fileInfo finds the lowest year in which the given file was committed. -func fileInfo(file string) (*info, error) { - info := &info{file: file, Year: int64(time.Now().Year())} - cmd := exec.Command("git", "log", "--follow", "--find-renames=80", "--find-copies=80", "--pretty=format:%ai", "--", file) - err := doLines(cmd, func(line string) { - y, err := strconv.ParseInt(line[:4], 10, 64) - if err != nil { - fmt.Printf("cannot parse year: %q", line[:4]) - } - if y < info.Year { - info.Year = y - } - }) - return info, err -} - -func writeLicenses(infos <-chan *info) { - for i := range infos { - writeLicense(i) - } -} - -func writeLicense(info *info) { - fi, err := os.Stat(info.file) - if os.IsNotExist(err) { - fmt.Println("skipping (does not exist)", info.file) - return - } - if err != nil { - log.Fatalf("error stat'ing %s: %v\n", info.file, err) - } - content, err := os.ReadFile(info.file) - if err != nil { - log.Fatalf("error reading %s: %v\n", info.file, err) - } - // Construct new file content. - buf := new(bytes.Buffer) - licenseT.Execute(buf, info) - if m := licenseCommentRE.FindIndex(content); m != nil && m[0] == 0 { - buf.Write(content[:m[0]]) - buf.Write(content[m[1]:]) - } else { - buf.Write(content) - } - // Write it to the file. - if bytes.Equal(content, buf.Bytes()) { - fmt.Println("skipping (no changes)", info.file) - return - } - fmt.Println("writing", info.ShortLicense(), info.file) - if err := os.WriteFile(info.file, buf.Bytes(), fi.Mode()); err != nil { - log.Fatalf("error writing %s: %v", info.file, err) - } -} - -func doLines(cmd *exec.Cmd, f func(string)) error { - stdout, err := cmd.StdoutPipe() - if err != nil { - return err - } - if err := cmd.Start(); err != nil { - return err - } - s := bufio.NewScanner(stdout) - for s.Scan() { - f(s.Text()) - } - if s.Err() != nil { - return s.Err() - } - if err := cmd.Wait(); err != nil { - return fmt.Errorf("%v (for %s)", err, strings.Join(cmd.Args, " ")) - } - return nil -} diff --git a/core/rawdb/database.go b/core/rawdb/database.go index 1d704006a8..6c2c028d58 100644 --- a/core/rawdb/database.go +++ b/core/rawdb/database.go @@ -386,10 +386,8 @@ func openKeyValueDatabase(o OpenOptions) (ethdb.Database, error) { // return nil, fmt.Errorf("db.engine choice was %v but found pre-existing %v database in specified data directory", o.Type, existingDb) // } - if o.Type == dbClevelDB { - log.Info("Using cleveldb as the backing database") - return NewCLevelDBDatabase(o.Directory, o.Cache, o.Handles, o.Namespace, o.ReadOnly) - } + log.Info("Using cleveldb as the backing database") + return NewCLevelDBDatabase(o.Directory, o.Cache, o.Handles, o.Namespace, o.ReadOnly) if o.Type == dbPebble { if PebbleEnabled { diff --git a/ethdb/cleveldb/cleveldb.go b/ethdb/cleveldb/cleveldb.go index ed5512611d..b840701e23 100644 --- a/ethdb/cleveldb/cleveldb.go +++ b/ethdb/cleveldb/cleveldb.go @@ -563,6 +563,7 @@ func (b *batch) Write() error { // Close implements Batch. func (b *batch) Close() error { + b.b.Clear() if b.b != nil { b.b.Close() b.b = nil @@ -573,6 +574,9 @@ func (b *batch) Close() error { // Reset resets the batch for reuse. func (b *batch) Reset() { b.size = 0 + if b.b != nil { + b.b.Close() + } b.b = levigo.NewWriteBatch() }