Page MenuHomeFreeBSD

Porter's Handbook: Add an example on how to create a USES=go port
ClosedPublic

Authored by tobik on Aug 13 2019, 7:19 AM.

Diff Detail

Repository
rD FreeBSD doc repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

tobik created this revision.Aug 13 2019, 7:19 AM
tobik added inline comments.Aug 13 2019, 7:24 AM
en_US.ISO8859-1/books/porters-handbook/special/chapter.xml
1261–1263 ↗(On Diff #60715)

While this is not too difficult to do, I think we could streamline this step by providing a make gomod-vendor (or whatever) target in USES=go like make cargo-crates in USES=cargo.

mat added inline comments.Aug 13 2019, 11:14 AM
en_US.ISO8859-1/books/porters-handbook/special/chapter.xml
1216 ↗(On Diff #60715)

Unless I read incorrectly, this is not about using the "go" command but how to build ports using the "Go" language in the ports tree.

1313–1326 ↗(On Diff #60715)

I think this should be either removed or really trimmed down to a simple note. It encourages people to test the build of their port outside of poudriere.

tobik updated this revision to Diff 60720.Aug 13 2019, 12:02 PM
tobik marked an inline comment as done.
  • Update section title
tobik added inline comments.Aug 13 2019, 12:03 PM
en_US.ISO8859-1/books/porters-handbook/special/chapter.xml
1313–1326 ↗(On Diff #60715)

This is copied from using-cargo where we have added a similar note and I think it has helped people.

If there is no note about this people will get confused and have to ask for help. Many people are building things outside of Poudriere (sometimes even as root) whether we like it or not because we still allow it by default for some reason.

mat added inline comments.Aug 13 2019, 12:24 PM
en_US.ISO8859-1/books/porters-handbook/special/chapter.xml
1313–1326 ↗(On Diff #60715)

Well, I would rather it be a small note saying something like "if you are not testing your port in a clean environment like with poudriere, remember to run make clean before any testing." or something similar :-)

dmgk added inline comments.Aug 13 2019, 12:43 PM
en_US.ISO8859-1/books/porters-handbook/special/chapter.xml
1261–1263 ↗(On Diff #60715)

I've added a review for this: https://reviews.freebsd.org/D21246

tobik updated this revision to Diff 60727.Aug 13 2019, 1:06 PM
  • Use make gomod-vendor
  • Mention Poudriere
tobik marked 3 inline comments as done.Aug 13 2019, 1:08 PM
tobik added inline comments.
en_US.ISO8859-1/books/porters-handbook/special/chapter.xml
1261–1263 ↗(On Diff #60715)

Thank you.

mat accepted this revision.Aug 13 2019, 1:48 PM
mat added inline comments.
en_US.ISO8859-1/books/porters-handbook/special/chapter.xml
1262 ↗(On Diff #60727)

Does it output anything else ?
Because it should probably be as silent as possible, to be able to run, say, make gomod-vendor >> Makefile and need as few tweaks as possible.

This revision is now accepted and ready to land.Aug 13 2019, 1:48 PM
dmgk added inline comments.Aug 13 2019, 2:11 PM
en_US.ISO8859-1/books/porters-handbook/special/chapter.xml
1262 ↗(On Diff #60727)

go mod vendor does output some diagnostics, but it all goes to stderr so redirecting stdout should work.

tobik marked an inline comment as done.Aug 13 2019, 2:31 PM
tobik added inline comments.
en_US.ISO8859-1/books/porters-handbook/special/chapter.xml
1262 ↗(On Diff #60727)

Yes, it implies make patch and framework messages always go to stdout, so the output might not be clean. make cargo-crates has the same problem.

If you want to append the output somewhere or pipe it to some command just run make gomod-vendor twice. On the second run the framework has nothing to do and will not output anything and the output will be clean.

This is just one more step in several steps you already have to go through. You probably already script it and adding one extra command should not make much of a difference. For USES=cargo ports (it's no different for USES=go:modules ports just s/cargo-crates/gomod-vendor/) this is basically what I do (implies ports-mgmt/portfmt is installed):

portedit set-version -i v1.2.3 Makefile
make clean makesum
make cargo-crates
make cargo-crates | portedit merge -i Makefile
make clean makesum

Anyway I think how to get the output into the Makefile should be left as an exercise to the reader as I do not foresee adding something like that to framework is wanted. ;-)

mat added inline comments.Aug 13 2019, 4:03 PM
en_US.ISO8859-1/books/porters-handbook/special/chapter.xml
1262 ↗(On Diff #60727)

all that portedit seems way too complicated, for the one port I have that uses rust (dns/doh-proxy), I have a crates.mk that I include in the Makefile and that I overwrite at each update, seemed much simpler :-)

tobik added a comment.Aug 13 2019, 5:36 PM

@dg_syrec.org Are you fine with this too?

en_US.ISO8859-1/books/porters-handbook/special/chapter.xml
1262 ↗(On Diff #60727)

I have used that approach too in the first USES=cargo review but you told me not to do it since it requires extra files. ;-)

For dns/doh-proxy this is probably fine but make cargo-crates can also output things like CARGO_USE_GIT{HUB,LAB}, G{H,L}_TUPLE where IMHO port readability starts to suffer if they are set in another file. This is where portedit starts to make all the difference to me.

Anyway I do not mean to turn this review into a portedit ad and this is fairly OT now.

dmgk accepted this revision.Aug 13 2019, 5:43 PM

LGTM, thanks.

This revision was automatically updated to reflect the committed changes.