Page MenuHomeFreeBSD

Extend go.mk to download go.mod from other location
ClosedPublic

Authored by mfechner on Jun 19 2024, 6:43 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Dec 24, 2:21 AM
Unknown Object (File)
Nov 27 2024, 11:23 AM
Unknown Object (File)
Nov 22 2024, 7:34 PM
Unknown Object (File)
Nov 22 2024, 1:09 AM
Unknown Object (File)
Nov 17 2024, 11:30 PM
Unknown Object (File)
Nov 10 2024, 3:04 AM
Unknown Object (File)
Oct 19 2024, 12:51 AM
Unknown Object (File)
Oct 1 2024, 10:09 PM

Details

Summary

More and more projects do not make there go.mod file available on GO_PROXY and therefor the go module build is not usable in ports.

You need to create work arounds like this:
https://cgit.freebsd.org/ports/tree/devel/gitaly/Makefile#n39

The patch added a new variable GO_MOD_DIST which can be defined to:

  • gitlab
  • github
  • A direct custom URI without go.mod

Or it can be ommited, then default GO_PROXY is used.

What do you think about this?

Test Plan

I current list of all commits related to this change (included test builds) can always be found here:
https://gitlab.fechner.net/mfechner/Gitlab/-/compare/main...go-mod-download-other-locations?from_project_id=120&straight=false

I added to this review only the modification of the go.mk, so we can focus on the important part.

Diff Detail

Repository
R11 FreeBSD ports repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

mfechner created this revision.

While doing some tests, I see that one use case is currently not covered.
Usage of WRKSRC_SUBDIR does not work, as it does not download the go.mod from the WRKSRC_SUBDIR on the remote.

I also changed the PORTNAME to GH/GL_PROJECT to be able to overwrite the PORTNAME.

I will show here the next version, after these use-cases are fixed.

I updated now the case for WRKSRC_SUBDIR.

Mk/Uses/go.mk
157

Why not

defined(GO_MOD_DIST) && "${GO_MOD_DIST}" = "gitlab"

so it's possible to give a different gitlab URL than the default one (e.g. in case go.mod is a release artefact). Same for the github case.

159

This line is the same for all cases. Check if you can refactor the conditionals so it only appears once.

Mk/Uses/go.mk
157

Have you tested your comment?
I get:
make: "/usr/local/poudriere/ports/gitlab/Mk/Uses/go.mk" line 157: Malformed conditional (defined(GO_MOD_DIST) && "${GO_MOD_DIST}" = "gitlab")
make: Fatal errors encountered -- cannot continue
make: stopped in /usr/local/poudriere/ports/gitlab/www/gitlab-workhorse

158

I will replace here the

v${DISTVERSION}

by

${GO_MODVERSION}

This should make it more usable.

159

No it is not the same for all causes, the default is different, only for gitlab, github and custom it is go.mod

Mk/Uses/go.mk
157

No I did not. I think you may need == instead, check the make manual.

159

Yes, every time GO_MOD_DIST is set, go.mod is added to DISTFILES. Show that should be the criterion and there should be a single case that sets the variable.

mfechner added inline comments.
Mk/Uses/go.mk
157

Thanks a lot for this!
If you write Makefile only once a year it can be tricky.
Now I learned the :M is a contains condition and yes I want here and equal condition, very good catch!

159

I'm sorry, but I do not understand it.
I think that go.mk is evaluated only once. If I set now the GO_MOD_DIST like this:

GO_MOD_DIST= gitlab github

which I understand as 'every time' the condition will now fall back to the current standard and GO_MOD_DIST is ignored, as it is not a valid.

Whatever I tested, I was not able to trigger an additional unwanted addition to MASTER_SITES or DISTFILES.

I think that version can now be seen as stable.
If I do not get any feedback, I will commit that change soon.

This revision was not accepted when it landed; it landed in state Needs Review.Jul 11 2024, 1:37 PM
This revision was automatically updated to reflect the committed changes.