Skip to content

Conversation

@wking
Copy link
Contributor

@wking wking commented May 15, 2018

And use go env GOBIN to detect the user's existing preference.

Using ?= allows us to skip the go env call if we already have GOBIN in the environment, or if we don't need GOBIN at all (e.g. for the help target). The recursive expansion could cause an issue if the result of the shell expansions included a $, but those seem unlikely in GOBIN, GOMD2MAN, or the manpage paths.

Using GOMD2MAN allows us to collapse old ||-based recipe into a less confusing invocation. And using a static pattern rule for $(MANPAGES) lets us write a single rule to handle both section 1 and section 5.

@rhatdan
Copy link
Member

rhatdan commented May 15, 2018

I am fine with this change, as soon as you get the tests to pass. :^(

@wking
Copy link
Contributor Author

wking commented May 15, 2018

Looks like $(GOBIN) is empty (at least in the Travis tests):

/bin/sh: 6: /gometalinter: not found

And this is because Travis is explicitly setting GOBIN to the empty string.

@wking wking force-pushed the gobin branch 2 times, most recently from efaed01 to 12ab406 Compare May 15, 2018 22:40
@mheon
Copy link
Member

mheon commented May 15, 2018

Tests look to be passing. LGTM.

@wking
Copy link
Contributor Author

wking commented May 15, 2018 via email

@rhatdan
Copy link
Member

rhatdan commented May 16, 2018

@rh-atomic-bot r+

@rh-atomic-bot
Copy link
Collaborator

📌 Commit 44111b7 has been approved by rhatdan

@rh-atomic-bot
Copy link
Collaborator

⌛ Testing commit 44111b7 with merge 5fbe959...

@rh-atomic-bot
Copy link
Collaborator

💔 Test failed - status-papr

@mheon
Copy link
Member

mheon commented May 16, 2018

Homu is a known flake
@rh-atomic-bot retry

@rh-atomic-bot
Copy link
Collaborator

🔒 Merge conflict

@rh-atomic-bot
Copy link
Collaborator

☔ The latest upstream changes (presumably 1aaf8df) made this pull request unmergeable. Please resolve the merge conflicts.

@rhatdan
Copy link
Member

rhatdan commented May 16, 2018

Sorry @wking Needs rebase, but it was probably caused by another one of your PRs. :^)

And use 'go env GOBIN' to detect the user's existing preference.  From
[1]:

> The bin directory holds compiled commands.  Each command is named
> for its source directory, but only the final element, not the entire
> path.  That is, the command with source in DIR/src/foo/quux is
> installed into DIR/bin/quux, not DIR/bin/foo/quux.  The "foo/"
> prefix is stripped so that you can add DIR/bin to your PATH to get
> at the installed commands.  If the GOBIN environment variable is
> set, commands are installed to the directory it names instead of
> DIR/bin.  GOBIN must be an absolute path.
> ...
> Go searches each directory listed in GOPATH to find source code, but
> new packages are always downloaded into the first directory in the
> list.

So if GOBIN is set, it will be non-empty, and we can use $(GOBIN)/...

If GOBIN is unset, 'go env GOBIN' will return an empty string (as it
does on Travis [2]).  In that case, I'm assuming that the package in
question is in the first directory in GOPATH and using the new
FIRST_GOPATH (firstword and subst are documented in [3]).  That's
probably fairly safe, since our previous GOPATH handling assumed it
only contained a single path, and nobody was complaining about that.

Using ?= allows us to skip the 'dirname' call if we end up not needing
GOPKGBASEDIR [4] (e.g. for the 'help' target).  The recursive
expansion could cause an issue if the result of the shell expansions
included a '$', but those seem unlikely in GOPKGBASEDIR, GOMD2MAN, or
the manpage paths.  I haven't used ?= for GOBIN, because we'll always
need the expanded value for the if check.

Using GOMD2MAN allows us to collapse old ||-based recipe into a less
confusing invocation.  And using a static pattern rule [5] for
$(MANPAGES) lets us write a single rule to handle both section 1 and
section 5.

While I was updating the GOPATH handling, I moved .gopathok from the
possibly-shared $(GOPATH)/.gopathok to the
definitely-specific-to-this-project .gopathok.  That may cause some
issues if you rebuild after changing your GOPATH without calling
'clean', but I don't expect folks to change their GOPATH frequently.
And the old approach would fail if different consumers were also using
the same flag path to mean something else (as CRI-O does [6]).

As part of cleaning up .gopathok, I've also collapsed clean's rm calls
into a single invocation.  That will give us the same results with
less process setup/teardown penalties.

[1]: https://golang.org/cmd/go/#hdr-GOPATH_environment_variable
[2]: https://travis-ci.org/projectatomic/libpod/jobs/379345071#L459
[3]: https://www.gnu.org/software/make/manual/html_node/Text-Functions.html
[4]: https://www.gnu.org/software/make/manual/html_node/Setting.html
[5]: https://www.gnu.org/software/make/manual/html_node/Static-Usage.html
[6]: https://github.com/kubernetes-incubator/cri-o/blob/v1.10.1/Makefile#L62

Signed-off-by: W. Trevor King <wking@tremily.us>
@wking
Copy link
Contributor Author

wking commented May 16, 2018

Rebased around #748 with 44111b7 -> e63f3f3.

@mheon
Copy link
Member

mheon commented May 16, 2018

@rh-atomic-bot r+

@rh-atomic-bot
Copy link
Collaborator

📌 Commit e63f3f3 has been approved by mheon

@rh-atomic-bot
Copy link
Collaborator

⌛ Testing commit e63f3f3 with merge db388b1...

@rh-atomic-bot
Copy link
Collaborator

☀️ Test successful - status-papr
Approved by: mheon
Pushing db388b1 to master...

@wking wking deleted the gobin branch May 17, 2018 00:45
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 27, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants