Skip to content

Commit

Permalink
Only self-check version in release builds
Browse files Browse the repository at this point in the history
This commit disables the comparison of dcrinstall's own embedded
version against the version discovered in the 'latest' file unless the
version is embedded using a linker flag by the release builder.
Normal development builds of dcrinstall will no longer self-check, and
the release builder should never produce a dcrinstall executable which
is incompatible with the manifests it creates.

While here, also update the fallback manifest URLs for the decred and
dexc distributions for the v1.6.0-rc3 release.
  • Loading branch information
jrick committed Nov 13, 2020
1 parent c592e15 commit d689904
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions cmd/dcrinstall/dcrinstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,15 @@ var (
defaultLatestManifestURI = "https://raw.githubusercontent.com/decred/decred-release/master/latest"

defaultTuple = runtime.GOOS + "-" + runtime.GOARCH
defaultDecredManifestVersion = "v1.6.0-rc2"
defaultDecredManifestVersion = "v1.6.0-rc3"
defaultDecredManifestFilename = "decred-" + defaultDecredManifestVersion +
"-manifest.txt"
defaultDecredManifestURI = "https://github.com/decred/decred-binaries" +
"/releases/download/" + defaultDecredManifestVersion + "/" +
defaultDecredManifestFilename

// dcrdex
defaultDcrdexManifestVersion = "v0.1.0"
defaultDcrdexManifestVersion = "v0.1.2"
defaultDcrdexManifestFilename = "dexc-" + defaultDcrdexManifestVersion +
"-manifest.txt"
defaultDcrdexManifestURI = "https://github.com/decred/decred-binaries" +
Expand All @@ -151,14 +151,15 @@ var (
"bitcoin-core-" + defaultBitcoinManifestVersion + "/" +
defaultBitcoinManifestFilename

// dcrinstall itself
defaultDcrinstallManifestVersion = "v1.6.0-rc1"
defaultDcrinstallManifestFilename = "dcrinstall-" +
defaultDcrinstallManifestVersion + "-manifest.txt"
defaultDcrinstallManifestURI = "https://github.com/decred/decred-release/releases/download/" +
defaultDcrinstallManifestVersion + "/" +
defaultDcrinstallManifestFilename
// https://github.com/decred/decred-release/releases/download/v1.6.0-rc1/dcrinstall-v1.6.0-manifest.txt
// dcrinstall itself.
// dcrinstallManifestVersion is set by linker flags by the release builder
// (e.g. -ldflags='-X main.dcrinstallManifestVersion=v1.6.0-rc3'). When
// this is not the empty string, dcrinstall will perform a self-check comparing
// this embedded version against the version found in the 'latest' file.
// Otherwise, no such check is performed.
dcrinstallManifestVersion string
dcrinstallManifestFilename string
dcrinstallManifestURI string

// Settings
tmpDir string // Directory where files are downloaded to
Expand All @@ -184,6 +185,16 @@ var (
dcrinstallRE = regexp.MustCompile(`dcrinstall-v[[:digit:]]\.[[:digit:]]\.[[:digit:]][[:print:]]*-manifest\.txt`)
)

func init() {
if dcrinstallManifestVersion != "" {
dcrinstallManifestFilename = "dcrinstall-" +
dcrinstallManifestVersion + "-manifest.txt"
dcrinstallManifestURI = "https://github.com/decred/decred-release/releases/download/" +
dcrinstallManifestVersion + "/" +
dcrinstallManifestFilename
}
}

// downloadManifest downloads the latest manifest and verifies them.
func downloadManifest() error {
f, err := ioutil.TempFile("", "dcrinstall")
Expand Down Expand Up @@ -255,7 +266,7 @@ func downloadManifest() error {
return fmt.Errorf("Invalid dcrinstall, contact maintainers")
}
// Deal with dcrinstall versions
if defaultDcrinstallManifestURI != dcrinstallURI {
if dcrinstallManifestVersion != "" && dcrinstallManifestURI != dcrinstallURI {
log.Printf("=== dcrinstall must be updated ===")
log.Println()
log.Printf("A new version of dcrinstall was detected. " +
Expand Down

0 comments on commit d689904

Please sign in to comment.