From c5b9f00467000d11cbb6fa5514ff0bddb5b731d8 Mon Sep 17 00:00:00 2001 From: Alex Kohler Date: Tue, 20 Feb 2018 13:04:25 -0500 Subject: [PATCH] Adding update-geth target (#673) --- Makefile | 3 +++ _assets/ci/update-geth.sh | 27 +++++++++++++++++++++++++++ _assets/docs/DEPENDENCIES.md | 7 +------ 3 files changed, 31 insertions(+), 6 deletions(-) create mode 100755 _assets/ci/update-geth.sh diff --git a/Makefile b/Makefile index ab28bde2b..38f78d776 100644 --- a/Makefile +++ b/Makefile @@ -174,6 +174,9 @@ dep-ensure: ##@dependencies Dep ensure and apply all patches dep-install: ##@dependencies Install vendoring tool go get -u github.com/golang/dep/cmd/dep +update-geth: ##@dependencies Update geth (use GETH_BRANCH to optionally set the geth branch name) + ./_assets/ci/update-geth.sh $(GETH_BRANCH) + patch: ##@patching Revert and apply all patches ./_assets/patches/patcher diff --git a/_assets/ci/update-geth.sh b/_assets/ci/update-geth.sh new file mode 100755 index 000000000..088ca6de7 --- /dev/null +++ b/_assets/ci/update-geth.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +# This script updates the go-ethereum dependency, optionally updating the branch if GETH_BRANCH is provided. +# If any changes were made, they will be committed. + +# Exit early if any errors are encountered +set -e +if [ ! -z "$GETH_BRANCH" ]; then + # escape slashes + GETH_BRANCH=$(echo $GETH_BRANCH | sed 's@\/@\\\/@g') + # Update go-ethereum contraint branch + sed -i 'N;N;s@\(\[\[constraint]]\n name = "github.com\/ethereum\/go-ethereum"\n branch =\)\(.*\)@\1 '"\"${GETH_BRANCH}\""'@g' Gopkg.toml +fi +dep ensure -v -update github.com/ethereum/go-ethereum +if ! make dep-ensure; then + echo "Please fix patches and rerun. (dep-ensure failed)" + exit 1 +fi + + +git add Gopkg.lock Gopkg.toml vendor/ _assets/patches/ +if $(git diff --cached --quiet); then + echo "No changes to commit. Geth up to date." + exit 0 +fi +git commit --quiet -m "Updating Geth" +echo "Geth updated." diff --git a/_assets/docs/DEPENDENCIES.md b/_assets/docs/DEPENDENCIES.md index de38fc0ab..c1c9629fc 100644 --- a/_assets/docs/DEPENDENCIES.md +++ b/_assets/docs/DEPENDENCIES.md @@ -49,12 +49,7 @@ file is changed, `dep ensure` will re-generate `Gopkg.lock` as well. ## Updating `Geth` -1. (for major releases) Update the branch name in `Gopkg.toml`. -2. Update the `go-ethereum` dependency: `dep ensure -v -update github.com/ethereum/go-ethereum`. -3. Update vendor files in `status-go`, and apply patches by running `make dep-ensure`. -4. Commit patches. -5. Commit `Gopkg.lock`, `Gopkg.toml` and `vendor` directories. - +Use the `update-geth` make target. For major releases, provide the GETH_BRANCH parameter. (e.g. `make update-geth GETH_BRANCH=release/1.9`). If there were any changes made, they will be committed while running this target. ## Commiting changes