Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default Make target installs binaries from the Internet #222

Closed
mattbostock opened this issue Mar 1, 2018 · 4 comments
Closed

Default Make target installs binaries from the Internet #222

mattbostock opened this issue Mar 1, 2018 · 4 comments

Comments

@mattbostock
Copy link
Contributor

Running the default Make target invokes the install-tools target, which has the unexpected side-effect of performing a 'git pull' on repositories under the GOPATH:
https://github.com/improbable-eng/thanos/blob/b77877f42f9edf67a4413a9602054850a1a26afa/Makefile#L25-L31

We might want to consider using vg instead, which supports using dep metadata to specify which binaries are required. This would also allow for versions to be pinned, to make the builds repeatable.

The default Make target should not install binaries on a user's system.

@bwplotka
Copy link
Member

bwplotka commented Mar 1, 2018

I like your idea 👍

@lx223
Copy link
Contributor

lx223 commented Jun 21, 2019

I presume this issue is no longer relevant?

@bwplotka
Copy link
Member

There is still place for improvement - to move all installed binaries script into simple go get certain version and go mod tidy afterwards (:

AC:
Replace below function with installation via go modules. (:

# fetch_go_bin_version downloads (go gets) the binary from specific version and installs it in $(GOBIN)/<bin>-<version>
# arguments:
# $(1): Install path. (e.g github.com/campoy/embedmd)
# $(2): Tag or revision for checkout.
# TODO(bwplotka): Move to just using modules, however make sure to not use or edit Thanos go.mod file!
define fetch_go_bin_version
	@mkdir -p $(GOBIN)
	@mkdir -p $(TMP_GOPATH)

	@echo ">> fetching $(1)@$(2) revision/version"
	@if [ ! -d '$(TMP_GOPATH)/src/$(1)' ]; then \
    GOPATH='$(TMP_GOPATH)' GO111MODULE='off' go get -d -u '$(1)/...'; \
  else \
    CDPATH='' cd -- '$(TMP_GOPATH)/src/$(1)' && git fetch; \
  fi
	@CDPATH='' cd -- '$(TMP_GOPATH)/src/$(1)' && git checkout -f -q '$(2)'
	@echo ">> installing $(1)@$(2)"
	@GOBIN='$(TMP_GOPATH)/bin' GOPATH='$(TMP_GOPATH)' GO111MODULE='off' go install '$(1)'
	@mv -- '$(TMP_GOPATH)/bin/$(shell basename $(1))' '$(GOBIN)/$(shell basename $(1))-$(2)'
	@echo ">> produced $(GOBIN)/$(shell basename $(1))-$(2)"

endef

@stale
Copy link

stale bot commented Jan 11, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jan 11, 2020
@stale stale bot closed this as completed Jan 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants