svn commit: r53306 - in head/en_US.ISO8859-1/books/porters-handbook: special uses

Tobias Kortkamp <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.doc
Message-ID <[email protected]>
Author: tobik (ports committer)
Date: Tue Aug 13 17:49:49 2019
New Revision: 53306
URL: https://svnweb.freebsd.org/changeset/doc/53306

Log:
  Porter's Handbook: Add an example on how to create a USES=go port
  
  Submitted by:	tobik
  Reviewed by:	Dmitri Goutnik <[email protected]>, mat
  Approved by:	mat
  Differential Revision:	https://reviews.freebsd.org/D21243

Modified:
  head/en_US.ISO8859-1/books/porters-handbook/special/chapter.xml
  head/en_US.ISO8859-1/books/porters-handbook/uses/chapter.xml

Modified: head/en_US.ISO8859-1/books/porters-handbook/special/chapter.xml
==============================================================================
--- head/en_US.ISO8859-1/books/porters-handbook/special/chapter.xml	Tue Aug 13 16:49:10 2019	(r53305)
+++ head/en_US.ISO8859-1/books/porters-handbook/special/chapter.xml	Tue Aug 13 17:49:49 2019	(r53306)
@@ -1211,6 +1211,114 @@ byteorder-1.2.2     Unlicense/MIT
 MESON_ARGS=	-Dfoo=enabled</programlisting>
       </example>
     </sect2>
+
+    <sect2 xml:id="using-go">
+      <title>Building <application>Go</application> applications</title>
+
+      <para>For ports that use <application>Go</application>,
+	define <literal>USES=go</literal>.  Refer to <xref
+	linkend="uses-go" /> for a list of variables that can be
+	set to control the build process.</para>
+
+      <example xml:id="go-ex1">
+	<title>Creating a Port for a Go Modules Based
+	  Application</title>
+
+	<para>Creating a Go based port is a five stage process.
+	  First we need to provide a ports template that fetches the
+	  application distribution file:</para>
+
+	<programlisting>PORTNAME=	ghq
+DISTVERSIONPREFIX=	v
+DISTVERSION=	0.12.5
+CATEGORIES=	devel
+
+MAINTAINER=	[email protected]
+COMMENT=	Remote repository management made easy
+
+USES=		go:modules
+USE_GITHUB=	yes
+GH_ACCOUNT=	motemen
+
+.include &lt;bsd.port.mk&gt;</programlisting>
+
+	<para>Generate an initial
+	  <filename>distinfo</filename>:</para>
+
+	<screen>&prompt.user; <userinput>make makesum</userinput>
+===>  License MIT accepted by the user
+=> motemen-ghq-v0.12.5_GH0.tar.gz doesn't seem to exist in /usr/ports/distfiles/.
+=> Attempting to fetch https://codeload.github.com/motemen/ghq/tar.gz/v0.12.5?dummy=/motemen-ghq-v0.12.5_GH0.tar.gz
+fetch: https://codeload.github.com/motemen/ghq/tar.gz/v0.12.5?dummy=/motemen-ghq-v0.12.5_GH0.tar.gz: size of remote file is not known
+motemen-ghq-v0.12.5_GH0.tar.gz                          32 kB  177 kBps    00s</screen>
+
+	<para>Now the distribution file is ready to use and we can
+	  extract the required Go module dependencies.  This step
+	  requires having
+	  <package role="port">ports-mgmt/modules2tuple</package>
+	  installed:</para>
+
+	<screen>&prompt.user; <userinput>make gomod-vendor</userinput>
+[...]
+GH_TUPLE=	\
+		Songmu:gitconfig:v0.0.2:songmu_gitconfig/vendor/github.com/Songmu/gitconfig \
+		daviddengcn:go-colortext:186a3d44e920:daviddengcn_go_colortext/vendor/github.com/daviddengcn/go-colortext \
+		go-yaml:yaml:v2.2.2:go_yaml_yaml/vendor/gopkg.in/yaml.v2 \
+		golang:net:3ec191127204:golang_net/vendor/golang.org/x/net \
+		golang:sync:112230192c58:golang_sync/vendor/golang.org/x/sync \
+		golang:xerrors:3ee3066db522:golang_xerrors/vendor/golang.org/x/xerrors \
+		motemen:go-colorine:45d19169413a:motemen_go_colorine/vendor/github.com/motemen/go-colorine \
+		urfave:cli:v1.20.0:urfave_cli/vendor/github.com/urfave/cli</screen>
+
+	<para>The output of this command needs to be pasted directly
+	  into the Makefile:</para>
+
+	<programlisting>PORTNAME=	ghq
+DISTVERSIONPREFIX=	v
+DISTVERSION=	0.12.5
+CATEGORIES=	devel
+
+MAINTAINER=	[email protected]
+COMMENT=	Remote repository management made easy
+
+USES=		go:modules
+USE_GITHUB=	yes
+GH_ACCOUNT=	motemen
+GH_TUPLE=	Songmu:gitconfig:v0.0.2:songmu_gitconfig/vendor/github.com/Songmu/gitconfig \
+		daviddengcn:go-colortext:186a3d44e920:daviddengcn_go_colortext/vendor/github.com/daviddengcn/go-colortext \
+		go-yaml:yaml:v2.2.2:go_yaml_yaml/vendor/gopkg.in/yaml.v2 \
+		golang:net:3ec191127204:golang_net/vendor/golang.org/x/net \
+		golang:sync:112230192c58:golang_sync/vendor/golang.org/x/sync \
+		golang:xerrors:3ee3066db522:golang_xerrors/vendor/golang.org/x/xerrors \
+		motemen:go-colorine:45d19169413a:motemen_go_colorine/vendor/github.com/motemen/go-colorine \
+		urfave:cli:v1.20.0:urfave_cli/vendor/github.com/urfave/cli
+
+.include &lt;bsd.port.mk&gt;</programlisting>
+
+	<para><filename>distinfo</filename> needs to be regenerated to
+	  contain all the distribution files:</para>
+
+	<screen>&prompt.user; <userinput>make makesum</userinput>
+=> Songmu-gitconfig-v0.0.2_GH0.tar.gz doesn't seem to exist in /usr/ports/distfiles/.
+=> Attempting to fetch https://codeload.github.com/Songmu/gitconfig/tar.gz/v0.0.2?dummy=/Songmu-gitconfig-v0.0.2_GH0.tar.gz
+fetch: https://codeload.github.com/Songmu/gitconfig/tar.gz/v0.0.2?dummy=/Songmu-gitconfig-v0.0.2_GH0.tar.gz: size of remote file is not known
+Songmu-gitconfig-v0.0.2_GH0.tar.gz                    5662  B  936 kBps    00s
+=> daviddengcn-go-colortext-186a3d44e920_GH0.tar.gz doesn't seem to exist in /usr/ports/distfiles/.
+=> Attempting to fetch https://codeload.github.com/daviddengcn/go-colortext/tar.gz/186a3d44e920?dummy=/daviddengcn-go-colortext-186a3d44e920_GH0.tar.gz
+fetch: https://codeload.github.com/daviddengcn/go-colortext/tar.gz/186a3d44e920?dummy=/daviddengcn-go-colortext-186a3d44e920_GH0.tar.gz: size of remote file is not known
+daviddengcn-go-colortext-186a3d44e920_GH0.tar.        4534  B 1098 kBps    00s
+[...]</screen>
+
+	<para>The port is now ready for a test build and further
+	  adjustments like creating a plist, writing a description,
+	  adding license information, options, etc. as normal.</para>
+
+	<para>If you are not testing your port in a clean environment
+	  like with <application>Poudriere</application>, remember to
+	  run <command>make clean</command> before any testing.
+	</para>
+      </example>
+    </sect2>
   </sect1>
 
   <sect1 xml:id="using-autotools">

Modified: head/en_US.ISO8859-1/books/porters-handbook/uses/chapter.xml
==============================================================================
--- head/en_US.ISO8859-1/books/porters-handbook/uses/chapter.xml	Tue Aug 13 16:49:10 2019	(r53305)
+++ head/en_US.ISO8859-1/books/porters-handbook/uses/chapter.xml	Tue Aug 13 17:49:49 2019	(r53306)
@@ -1237,6 +1237,8 @@ USE_GNOME=	gnomemenus3:build intlhack</programlisting>
 	</listitem>
       </varlistentry>
     </variablelist>
+
+    <para>See <xref linkend="using-go" /> for usage examples.</para>
   </sect1>
 
   <sect1 xml:id="uses-gperf">
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-doc-all
To unsubscribe, send any mail to "[email protected]"
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.