Sun Feb 13 11:16:54 2022 UTC ()
doc/pkgsrc.*: regen


(nia)
diff -r1.333 -r1.334 pkgsrc/doc/pkgsrc.html
diff -r1.331 -r1.332 pkgsrc/doc/pkgsrc.txt

cvs diff -r1.333 -r1.334 pkgsrc/doc/pkgsrc.html (expand / switch to unified diff)

--- pkgsrc/doc/pkgsrc.html 2022/02/11 08:06:21 1.333
+++ pkgsrc/doc/pkgsrc.html 2022/02/13 11:16:54 1.334
@@ -211,30 +211,29 @@ builds) @@ -211,30 +211,29 @@ builds)
211<dt><span class="sect1"><a href="#build.wrapper">13.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt> 211<dt><span class="sect1"><a href="#build.wrapper">13.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
212<dt><span class="sect1"><a href="#build.configure">13.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt> 212<dt><span class="sect1"><a href="#build.configure">13.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
213<dt><span class="sect1"><a href="#build.build">13.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt> 213<dt><span class="sect1"><a href="#build.build">13.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
214<dt><span class="sect1"><a href="#build.test">13.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt> 214<dt><span class="sect1"><a href="#build.test">13.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
215<dt><span class="sect1"><a href="#build.install">13.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt> 215<dt><span class="sect1"><a href="#build.install">13.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
216<dt><span class="sect1"><a href="#build.package">13.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt> 216<dt><span class="sect1"><a href="#build.package">13.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
217<dt><span class="sect1"><a href="#build.clean">13.16. Cleaning up</a></span></dt> 217<dt><span class="sect1"><a href="#build.clean">13.16. Cleaning up</a></span></dt>
218<dt><span class="sect1"><a href="#build.helpful-targets">13.17. Other helpful targets</a></span></dt> 218<dt><span class="sect1"><a href="#build.helpful-targets">13.17. Other helpful targets</a></span></dt>
219</dl></dd> 219</dl></dd>
220<dt><span class="chapter"><a href="#creating">14. Creating a new pkgsrc package from scratch</a></span></dt> 220<dt><span class="chapter"><a href="#creating">14. Creating a new pkgsrc package from scratch</a></span></dt>
221<dd><dl> 221<dd><dl>
222<dt><span class="sect1"><a href="#creating.common">14.1. Common types of packages</a></span></dt> 222<dt><span class="sect1"><a href="#creating.common">14.1. Common types of packages</a></span></dt>
223<dd><dl> 223<dd><dl>
224<dt><span class="sect2"><a href="#creating.perl-module">14.1.1. Perl modules</a></span></dt> 224<dt><span class="sect2"><a href="#creating.python-module">14.1.1. Python modules and programs</a></span></dt>
225<dt><span class="sect2"><a href="#creating.python-module">14.1.2. Python modules and programs</a></span></dt> 225<dt><span class="sect2"><a href="#creating.R-package">14.1.2. R packages</a></span></dt>
226<dt><span class="sect2"><a href="#creating.R-package">14.1.3. R packages</a></span></dt> 226<dt><span class="sect2"><a href="#creating.TeX-package">14.1.3. TeXlive packages</a></span></dt>
227<dt><span class="sect2"><a href="#creating.TeX-package">14.1.4. TeXlive packages</a></span></dt> 
228</dl></dd> 227</dl></dd>
229<dt><span class="sect1"><a href="#creating.examples">14.2. Examples</a></span></dt> 228<dt><span class="sect1"><a href="#creating.examples">14.2. Examples</a></span></dt>
230<dd><dl><dt><span class="sect2"><a href="#creating.nvu">14.2.1. How the www/nvu package came into pkgsrc</a></span></dt></dl></dd> 229<dd><dl><dt><span class="sect2"><a href="#creating.nvu">14.2.1. How the www/nvu package came into pkgsrc</a></span></dt></dl></dd>
231</dl></dd> 230</dl></dd>
232<dt><span class="chapter"><a href="#makefile">15. Programming in <code class="filename">Makefile</code>s</a></span></dt> 231<dt><span class="chapter"><a href="#makefile">15. Programming in <code class="filename">Makefile</code>s</a></span></dt>
233<dd><dl> 232<dd><dl>
234<dt><span class="sect1"><a href="#makefile.style">15.1. Caveats</a></span></dt> 233<dt><span class="sect1"><a href="#makefile.style">15.1. Caveats</a></span></dt>
235<dt><span class="sect1"><a href="#makefile.variables">15.2. <code class="filename">Makefile</code> variables</a></span></dt> 234<dt><span class="sect1"><a href="#makefile.variables">15.2. <code class="filename">Makefile</code> variables</a></span></dt>
236<dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">15.2.1. Naming conventions</a></span></dt></dl></dd> 235<dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">15.2.1. Naming conventions</a></span></dt></dl></dd>
237<dt><span class="sect1"><a href="#makefile.code">15.3. Code snippets</a></span></dt> 236<dt><span class="sect1"><a href="#makefile.code">15.3. Code snippets</a></span></dt>
238<dd><dl> 237<dd><dl>
239<dt><span class="sect2"><a href="#adding-to-list">15.3.1. Adding things to a list</a></span></dt> 238<dt><span class="sect2"><a href="#adding-to-list">15.3.1. Adding things to a list</a></span></dt>
240<dt><span class="sect2"><a href="#echo-literal">15.3.2. Echoing a string exactly as-is</a></span></dt> 239<dt><span class="sect2"><a href="#echo-literal">15.3.2. Echoing a string exactly as-is</a></span></dt>
@@ -3179,30 +3178,29 @@ anymore, you can remove that file and ru @@ -3179,30 +3178,29 @@ anymore, you can remove that file and ru
3179<dt><span class="sect1"><a href="#build.wrapper">13.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt> 3178<dt><span class="sect1"><a href="#build.wrapper">13.10. The <span class="emphasis"><em>wrapper</em></span> phase</a></span></dt>
3180<dt><span class="sect1"><a href="#build.configure">13.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt> 3179<dt><span class="sect1"><a href="#build.configure">13.11. The <span class="emphasis"><em>configure</em></span> phase</a></span></dt>
3181<dt><span class="sect1"><a href="#build.build">13.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt> 3180<dt><span class="sect1"><a href="#build.build">13.12. The <span class="emphasis"><em>build</em></span> phase</a></span></dt>
3182<dt><span class="sect1"><a href="#build.test">13.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt> 3181<dt><span class="sect1"><a href="#build.test">13.13. The <span class="emphasis"><em>test</em></span> phase</a></span></dt>
3183<dt><span class="sect1"><a href="#build.install">13.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt> 3182<dt><span class="sect1"><a href="#build.install">13.14. The <span class="emphasis"><em>install</em></span> phase</a></span></dt>
3184<dt><span class="sect1"><a href="#build.package">13.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt> 3183<dt><span class="sect1"><a href="#build.package">13.15. The <span class="emphasis"><em>package</em></span> phase</a></span></dt>
3185<dt><span class="sect1"><a href="#build.clean">13.16. Cleaning up</a></span></dt> 3184<dt><span class="sect1"><a href="#build.clean">13.16. Cleaning up</a></span></dt>
3186<dt><span class="sect1"><a href="#build.helpful-targets">13.17. Other helpful targets</a></span></dt> 3185<dt><span class="sect1"><a href="#build.helpful-targets">13.17. Other helpful targets</a></span></dt>
3187</dl></dd> 3186</dl></dd>
3188<dt><span class="chapter"><a href="#creating">14. Creating a new pkgsrc package from scratch</a></span></dt> 3187<dt><span class="chapter"><a href="#creating">14. Creating a new pkgsrc package from scratch</a></span></dt>
3189<dd><dl> 3188<dd><dl>
3190<dt><span class="sect1"><a href="#creating.common">14.1. Common types of packages</a></span></dt> 3189<dt><span class="sect1"><a href="#creating.common">14.1. Common types of packages</a></span></dt>
3191<dd><dl> 3190<dd><dl>
3192<dt><span class="sect2"><a href="#creating.perl-module">14.1.1. Perl modules</a></span></dt> 3191<dt><span class="sect2"><a href="#creating.python-module">14.1.1. Python modules and programs</a></span></dt>
3193<dt><span class="sect2"><a href="#creating.python-module">14.1.2. Python modules and programs</a></span></dt> 3192<dt><span class="sect2"><a href="#creating.R-package">14.1.2. R packages</a></span></dt>
3194<dt><span class="sect2"><a href="#creating.R-package">14.1.3. R packages</a></span></dt> 3193<dt><span class="sect2"><a href="#creating.TeX-package">14.1.3. TeXlive packages</a></span></dt>
3195<dt><span class="sect2"><a href="#creating.TeX-package">14.1.4. TeXlive packages</a></span></dt> 
3196</dl></dd> 3194</dl></dd>
3197<dt><span class="sect1"><a href="#creating.examples">14.2. Examples</a></span></dt> 3195<dt><span class="sect1"><a href="#creating.examples">14.2. Examples</a></span></dt>
3198<dd><dl><dt><span class="sect2"><a href="#creating.nvu">14.2.1. How the www/nvu package came into pkgsrc</a></span></dt></dl></dd> 3196<dd><dl><dt><span class="sect2"><a href="#creating.nvu">14.2.1. How the www/nvu package came into pkgsrc</a></span></dt></dl></dd>
3199</dl></dd> 3197</dl></dd>
3200<dt><span class="chapter"><a href="#makefile">15. Programming in <code class="filename">Makefile</code>s</a></span></dt> 3198<dt><span class="chapter"><a href="#makefile">15. Programming in <code class="filename">Makefile</code>s</a></span></dt>
3201<dd><dl> 3199<dd><dl>
3202<dt><span class="sect1"><a href="#makefile.style">15.1. Caveats</a></span></dt> 3200<dt><span class="sect1"><a href="#makefile.style">15.1. Caveats</a></span></dt>
3203<dt><span class="sect1"><a href="#makefile.variables">15.2. <code class="filename">Makefile</code> variables</a></span></dt> 3201<dt><span class="sect1"><a href="#makefile.variables">15.2. <code class="filename">Makefile</code> variables</a></span></dt>
3204<dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">15.2.1. Naming conventions</a></span></dt></dl></dd> 3202<dd><dl><dt><span class="sect2"><a href="#makefile.variables.names">15.2.1. Naming conventions</a></span></dt></dl></dd>
3205<dt><span class="sect1"><a href="#makefile.code">15.3. Code snippets</a></span></dt> 3203<dt><span class="sect1"><a href="#makefile.code">15.3. Code snippets</a></span></dt>
3206<dd><dl> 3204<dd><dl>
3207<dt><span class="sect2"><a href="#adding-to-list">15.3.1. Adding things to a list</a></span></dt> 3205<dt><span class="sect2"><a href="#adding-to-list">15.3.1. Adding things to a list</a></span></dt>
3208<dt><span class="sect2"><a href="#echo-literal">15.3.2. Echoing a string exactly as-is</a></span></dt> 3206<dt><span class="sect2"><a href="#echo-literal">15.3.2. Echoing a string exactly as-is</a></span></dt>
@@ -5056,172 +5054,161 @@ ${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${site @@ -5056,172 +5054,161 @@ ${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${site
5056 information on this target.</p> 5054 information on this target.</p>
5057</dd> 5055</dd>
5058</dl></div> 5056</dl></div>
5059</div> 5057</div>
5060</div> 5058</div>
5061<div class="chapter"> 5059<div class="chapter">
5062<div class="titlepage"><div><div><h2 class="title"> 5060<div class="titlepage"><div><div><h2 class="title">
5063<a name="creating"></a>Chapter 14. Creating a new pkgsrc package from scratch</h2></div></div></div> 5061<a name="creating"></a>Chapter 14. Creating a new pkgsrc package from scratch</h2></div></div></div>
5064<div class="toc"> 5062<div class="toc">
5065<p><b>Table of Contents</b></p> 5063<p><b>Table of Contents</b></p>
5066<dl class="toc"> 5064<dl class="toc">
5067<dt><span class="sect1"><a href="#creating.common">14.1. Common types of packages</a></span></dt> 5065<dt><span class="sect1"><a href="#creating.common">14.1. Common types of packages</a></span></dt>
5068<dd><dl> 5066<dd><dl>
5069<dt><span class="sect2"><a href="#creating.perl-module">14.1.1. Perl modules</a></span></dt> 5067<dt><span class="sect2"><a href="#creating.python-module">14.1.1. Python modules and programs</a></span></dt>
5070<dt><span class="sect2"><a href="#creating.python-module">14.1.2. Python modules and programs</a></span></dt> 5068<dt><span class="sect2"><a href="#creating.R-package">14.1.2. R packages</a></span></dt>
5071<dt><span class="sect2"><a href="#creating.R-package">14.1.3. R packages</a></span></dt> 5069<dt><span class="sect2"><a href="#creating.TeX-package">14.1.3. TeXlive packages</a></span></dt>
5072<dt><span class="sect2"><a href="#creating.TeX-package">14.1.4. TeXlive packages</a></span></dt> 
5073</dl></dd> 5070</dl></dd>
5074<dt><span class="sect1"><a href="#creating.examples">14.2. Examples</a></span></dt> 5071<dt><span class="sect1"><a href="#creating.examples">14.2. Examples</a></span></dt>
5075<dd><dl><dt><span class="sect2"><a href="#creating.nvu">14.2.1. How the www/nvu package came into pkgsrc</a></span></dt></dl></dd> 5072<dd><dl><dt><span class="sect2"><a href="#creating.nvu">14.2.1. How the www/nvu package came into pkgsrc</a></span></dt></dl></dd>
5076</dl> 5073</dl>
5077</div> 5074</div>
5078<p>When you find a package that is not yet in pkgsrc, you 5075<p>When you find a package that is not yet in pkgsrc, you
5079most likely have a URL from where you can download the source 5076most likely have a URL from where you can download the source
5080code. Starting with this URL, creating a package involves only a 5077code. Starting with this URL, creating a package involves only a
5081few steps.</p> 5078few steps.</p>
5082<div class="procedure"><ol class="procedure" type="1"> 5079<div class="procedure"><ol class="procedure" type="1">
5083<li class="step"><p>In your <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>, set <code class="code">PKG_DEVELOPER=yes</code> to 5080<li class="step"><p>In your <a class="link" href="#mk.conf"><code class="filename">mk.conf</code></a>, set <code class="code">PKG_DEVELOPER=yes</code> to
5084enable the basic quality checks.</p></li> 5081enable the basic quality checks.</p></li>
5085<li class="step"> 5082<li class="step">
5086<p>Install the package <a href="https://cdn.NetBSD.org/pub/pkgsrc/current/pkgsrc/meta-pkgs/pkg_developer/index.html" target="_top"><code class="filename">meta-pkgs/pkg_developer</code></a>, which among others will 5083<p>Install the package <a href="https://cdn.NetBSD.org/pub/pkgsrc/current/pkgsrc/meta-pkgs/pkg_developer/index.html" target="_top"><code class="filename">meta-pkgs/pkg_developer</code></a>, which among others will
5087install the utilities <span class="command"><strong>url2pkg</strong></span>, 5084install the utilities <span class="command"><strong>url2pkg</strong></span>,
5088<span class="command"><strong>pkglint</strong></span>, <span class="command"><strong>pkgvi</strong></span> and 5085<span class="command"><strong>pkglint</strong></span>, <span class="command"><strong>pkgvi</strong></span> and
5089<span class="command"><strong>mkpatches</strong></span>:</p> 5086<span class="command"><strong>mkpatches</strong></span>:</p>
5090<pre class="screen"><code class="prompt">$</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong> 5087<pre class="screen"><code class="prompt">$</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
5091<code class="prompt">$</code> <strong class="userinput"><code>(cd meta-pkgs/pkg_developer &amp;&amp; bmake update)</code></strong></pre> 5088<code class="prompt">$</code> <strong class="userinput"><code>(cd meta-pkgs/pkg_developer &amp;&amp; bmake update)</code></strong></pre>
5092</li> 5089</li>
5093<li class="step"> 5090<li class="step">
5094<p>Choose one of the top-level directories as the category in 5091<p>Choose one of the top-level directories as the category in
5095which you want to place your package. You can also create a directory of 5092which you want to place your package. You can also create a directory of
5096your own (maybe called <code class="filename">local</code>). In that category 5093your own (maybe called <code class="filename">local</code>). Change into that
5097directory, create another directory for your package and change into 5094category directory:</p>
5098it:</p> 5095<pre class="screen"><code class="prompt">$</code> <strong class="userinput"><code>cd <em class="replaceable"><code>category</code></em></code></strong></pre>
5099<pre class="screen"><code class="prompt">$</code> <strong class="userinput"><code>mkdir <em class="replaceable"><code>category</code></em>/<em class="replaceable"><code>package</code></em></code></strong> 
5100<code class="prompt">$</code> <strong class="userinput"><code>cd <em class="replaceable"><code>category</code></em>/<em class="replaceable"><code>package</code></em></code></strong></pre> 
5101</li> 5096</li>
5102<li class="step"> 5097<li class="step">
5103<p>Run the program <span class="command"><strong>url2pkg</strong></span>, which will ask 5098<p>Run the program <span class="command"><strong>url2pkg</strong></span>, passing as
5104you for a URL. Enter the URL of the distribution file (in most cases a 5099argument the URL of the distribution file (in most cases a
5105<code class="filename">.tar.gz</code> file) and watch how the basic ingredients 5100<code class="filename">.tar.gz</code> file). This will download the distribution
5106of your package are created automatically. The distribution file is 5101file and create the necessary files of the package, based on what's in
5107extracted automatically to fill in some details in the 5102the distribution file:</p>
5108<code class="filename">Makefile</code> that would otherwise have to be done 
5109manually:</p> 
5110<pre class="screen"><code class="prompt">$</code> <strong class="userinput"><code>url2pkg <em class="replaceable"><code>https://www.example.org/packages/package-1.0.tar.gz</code></em></code></strong></pre> 5103<pre class="screen"><code class="prompt">$</code> <strong class="userinput"><code>url2pkg <em class="replaceable"><code>https://www.example.org/packages/package-1.0.tar.gz</code></em></code></strong></pre>
5111</li> 5104</li>
5112<li class="step"> 5105<li class="step">
5113<p>Examine the extracted files to determine the dependencies of 5106<p>Examine the extracted files to determine the dependencies of
5114your package. Ideally, this is mentioned in some 5107your package. Ideally, this is mentioned in some
5115<code class="filename">README</code> file, but things may differ. For each of 5108<code class="filename">README</code> file, but things may differ. For each of
5116these dependencies, look where it exists in pkgsrc, and if there is a 5109these dependencies, look where it exists in pkgsrc, and if there is a
5117file called <code class="filename">buildlink3.mk</code> in that directory, add a 5110file called <code class="filename">buildlink3.mk</code> in that directory, add a
5118line to your package <code class="filename">Makefile</code> which includes that 5111line to your package <code class="filename">Makefile</code> which includes that
5119file just before the last line. If the 5112file just before the last line. If the
5120<code class="filename">buildlink3.mk</code> file does not exist, it must be 5113<code class="filename">buildlink3.mk</code> file does not exist, it must be
5121created first. The <code class="filename">buildlink3.mk</code> file makes sure 5114created first. The <code class="filename">buildlink3.mk</code> file makes sure
5122that the package's include files and libraries are provided.</p> 5115that the package's include files and libraries are provided.</p>
5123<p>If you just need binaries from a package, add a 5116<p>If you just need binaries from a dependent package, add a
5124<code class="varname">DEPENDS</code> line to the Makefile, which specifies the 5117<code class="varname">DEPENDS</code> line to the Makefile, which specifies the
5125version of the dependency and where it can be found in pkgsrc. This line 5118version of the dependency and where it can be found in pkgsrc. This line
5126should be placed in the third paragraph. If the dependency is only 5119should be placed in the third paragraph. If the dependency is only
5127needed for building the package, but not when using it, use 5120needed for building the package, but not when using it, use
5128<code class="varname">TOOL_DEPENDS</code> or <code class="varname">BUILD_DEPENDS</code> 5121<code class="varname">TOOL_DEPENDS</code> or <code class="varname">BUILD_DEPENDS</code>
5129instead of <code class="varname">DEPENDS</code>. 5122instead of <code class="varname">DEPENDS</code>.
5130The difference between <code class="varname">TOOL_DEPENDS</code> and 5123The difference between <code class="varname">TOOL_DEPENDS</code> and
5131<code class="varname">BUILD_DEPENDS</code> occurs when cross-compiling: 5124<code class="varname">BUILD_DEPENDS</code> occurs when cross-compiling:
5132<code class="varname">TOOL_DEPENDS</code> are <span class="emphasis"><em>native</em></span> 5125<code class="varname">TOOL_DEPENDS</code> are <span class="emphasis"><em>native</em></span>
5133packages, i.e. packages for the architecture where the package 5126packages, i.e. packages for the platform where the package is built;
5134is built; 
5135<code class="varname">BUILD_DEPENDS</code> are <span class="emphasis"><em>target</em></span> 5127<code class="varname">BUILD_DEPENDS</code> are <span class="emphasis"><em>target</em></span>
5136packages, i.e. packages for the architecture for which the package 5128packages, i.e. packages for the platform for which the package
5137is built. There is also <code class="varname">TEST_DEPENDS</code>, which is used 5129is built. There is also <code class="varname">TEST_DEPENDS</code>, which
5138to specify a dependency used only for testing the resulting package 5130specifies a dependency used only for testing the resulting package
5139built, using the upstream project's included test suite. 5131built, using the upstream project's included test suite, on the native
 5132platform.
5140Your package may then look like this:</p> 5133Your package may then look like this:</p>
5141<pre class="programlisting"> 5134<pre class="programlisting">
5142[...] 5135[...]
5143 5136
5144TOOL_DEPENDS+= libxslt-[0-9]*:../../textproc/libxslt 5137TOOL_DEPENDS+= libxslt-[0-9]*:../../textproc/libxslt
5145DEPENDS+= screen-[0-9]*:../../misc/screen 5138DEPENDS+= screen-[0-9]*:../../misc/screen
5146DEPENDS+= screen&gt;=4.0:../../misc/screen 5139DEPENDS+= screen&gt;=4.0:../../misc/screen
5147 5140
5148[...] 5141[...]
5149 5142
5150.include "../../<em class="replaceable"><code>category</code></em>/<em class="replaceable"><code>package</code></em>/buildlink3.mk" 5143.include "../../<em class="replaceable"><code>category</code></em>/<em class="replaceable"><code>package</code></em>/buildlink3.mk"
5151.include "../../devel/glib2/buildlink3.mk" 5144.include "../../devel/glib2/buildlink3.mk"
5152.include "../../mk/bsd.pkg.mk" 5145.include "../../mk/bsd.pkg.mk"
5153</pre> 5146</pre>
5154</li> 5147</li>
5155<li class="step"><p>Run <span class="command"><strong>pkglint</strong></span> to see what things still need 5148<li class="step"><p>Run <span class="command"><strong>pkglint</strong></span> to see what things still need
5156to be done to make your package a <span class="quote">&#8220;<span class="quote">good</span>&#8221;</span> one. If you don't 5149to be done to make your package a <span class="quote">&#8220;<span class="quote">good</span>&#8221;</span> one. If you don't
5157know what pkglint's warnings want to tell you, try <span class="command"><strong>pkglint 5150know what pkglint's warnings want to tell you, try <span class="command"><strong>pkglint
5158--explain</strong></span> or <span class="command"><strong>pkglint -e</strong></span>, which outputs 5151--explain</strong></span> or <span class="command"><strong>pkglint -e</strong></span>, which outputs
5159additional explanations.</p></li> 5152additional explanations.</p></li>
5160<li class="step"><p>In many cases the package is not yet ready to build. You can 5153<li class="step"><p>In many cases the package is not yet ready to build. You can
5161find instructions for the most common cases in the next section, <a class="xref" href="#creating.common" title="14.1. Common types of packages">Section 14.1, &#8220;Common types of packages&#8221;</a>. After you have followed the instructions 5154find instructions for the most common cases in the next section, <a class="xref" href="#creating.common" title="14.1. Common types of packages">Section 14.1, &#8220;Common types of packages&#8221;</a>. After you have followed the instructions
5162over there, you can hopefully continue here.</p></li> 5155over there, you can hopefully continue here.</p></li>
5163<li class="step"><p>Run <span class="command"><strong>bmake clean</strong></span> to clean the working 5156<li class="step"><p>Run <span class="command"><strong>bmake clean</strong></span> to clean the working
5164directory from the extracted files. Besides these files, a lot of cache 5157directory from the extracted files. Besides these files, a lot of cache
5165files and other system information has been saved in the working 5158files and other system information have been saved in the working
5166directory, which may become wrong after you edited the 5159directory, which may have become outdated after you edited the
5167<code class="filename">Makefile</code>.</p></li> 5160<code class="filename">Makefile</code>.</p></li>
5168<li class="step"> 5161<li class="step">
5169<p>Now, run <span class="command"><strong>bmake</strong></span> to build the package. For 5162<p>Now, run <span class="command"><strong>bmake</strong></span> to build the package. For
5170the various things that can go wrong in this phase, consult <a class="xref" href="#fixes" title="Chapter 21. Making your package work">Chapter 21, <i>Making your package work</i></a>.</p> 5163the various things that can go wrong in this phase, consult <a class="xref" href="#fixes" title="Chapter 21. Making your package work">Chapter 21, <i>Making your package work</i></a>.</p>
5171<p>If the extracted files from the package need to be fixed, run multiple rounds of these commands:</p> 5164<p>If the extracted files from the package need to be fixed, run
5172<pre class="screen"><code class="prompt">$</code> <strong class="userinput"><code>make</code></strong> 5165multiple rounds of these commands:</p>
 5166<pre class="screen"><code class="prompt">$</code> <strong class="userinput"><code>bmake</code></strong>
5173<code class="prompt">$</code> <strong class="userinput"><code>pkgvi ${WRKSRC}/some/file/that/does/not/compile</code></strong> 5167<code class="prompt">$</code> <strong class="userinput"><code>pkgvi ${WRKSRC}/some/file/that/does/not/compile</code></strong>
5174<code class="prompt">$</code> <strong class="userinput"><code>mkpatches</code></strong> 5168<code class="prompt">$</code> <strong class="userinput"><code>mkpatches</code></strong>
5175<code class="prompt">$</code> <strong class="userinput"><code>make mps</code></strong> 5169<code class="prompt">$</code> <strong class="userinput"><code>bmake mps</code></strong>
5176<code class="prompt">$</code> <strong class="userinput"><code>make clean</code></strong></pre> 5170<code class="prompt">$</code> <strong class="userinput"><code>bmake clean</code></strong></pre>
5177</li> 5171</li>
5178<li class="step"><p>When the package builds fine, the next step is to install 5172<li class="step"><p>When the package builds fine, the next step is to install
5179the package. Run <span class="command"><strong>bmake install</strong></span> and hope that 5173the package. Run <span class="command"><strong>bmake install</strong></span> and hope that
5180everything works.</p></li> 5174everything works.</p></li>
5181<li class="step"><p>Up to now, the file <code class="filename">PLIST</code>, which 5175<li class="step"><p>Up to now, the file <code class="filename">PLIST</code>, which
5182contains a list of the files that are installed by the package, is 5176contains a list of the files that are installed by the package, is
5183nearly empty. Run <span class="command"><strong>bmake print-PLIST 5177nearly empty. Run <span class="command"><strong>bmake print-PLIST
5184&gt;PLIST</strong></span> to generate a probably correct list. Check 5178&gt;PLIST</strong></span> to generate a probably correct list. Check
5185the file using your preferred text editor to see if the list of 5179the file using your preferred text editor to see if the list of
5186files looks plausible.</p></li> 5180files looks plausible.</p></li>
5187<li class="step"><p>Run <span class="command"><strong>pkglint</strong></span> again to see if the generated 5181<li class="step"><p>Run <span class="command"><strong>pkglint</strong></span> again to see if the generated
5188<code class="filename">PLIST</code> contains garbage or not.</p></li> 5182<code class="filename">PLIST</code> contains garbage or not.</p></li>
5189<li class="step"><p>When you ran <span class="command"><strong>bmake install</strong></span>, the package 5183<li class="step"><p>When you ran <span class="command"><strong>bmake install</strong></span>, the package
5190had been registered in the database of installed files, but with an 5184had been registered in the database of installed files, but with an
5191empty list of files. To fix this, run <span class="command"><strong>bmake deinstall</strong></span> 5185empty list of files. To fix this, run <span class="command"><strong>bmake deinstall</strong></span>
5192and <span class="command"><strong>bmake install</strong></span> again. Now the package is 5186and <span class="command"><strong>bmake install</strong></span> again. Now the package is
5193registered with the list of files from 5187registered with the list of files from
5194<code class="filename">PLIST</code>.</p></li> 5188<code class="filename">PLIST</code>.</p></li>
5195<li class="step"><p>Run <span class="command"><strong>bmake package</strong></span> to create a binary 
5196package from the set of installed files.</p></li> 
5197<li class="step"><p>Run <span class="command"><strong>bmake clean update</strong></span> to run everything 5189<li class="step"><p>Run <span class="command"><strong>bmake clean update</strong></span> to run everything
5198from above again in a single step, making sure that the PLIST is correct 5190from above again in a single step, making sure that the PLIST is correct
5199and the whole package is created as intended.</p></li> 5191and the whole package is created as intended.</p></li>
5200<li class="step"><p>Run <span class="command"><strong>pkglint</strong></span> to see if there's anything left to do.</p></li> 5192<li class="step"><p>Run <span class="command"><strong>pkglint</strong></span> to see if there's anything
 5193left to do.</p></li>
5201<li class="step"><p>Commit the package to pkgsrc-wip or main pkgsrc; see <a class="xref" href="#submit" title="Chapter 23. Submitting and Committing">Chapter 23, <i>Submitting and Committing</i></a>.</p></li> 5194<li class="step"><p>Commit the package to pkgsrc-wip or main pkgsrc; see <a class="xref" href="#submit" title="Chapter 23. Submitting and Committing">Chapter 23, <i>Submitting and Committing</i></a>.</p></li>
5202</ol></div> 5195</ol></div>
5203<div class="sect1"> 5196<div class="sect1">
5204<div class="titlepage"><div><div><h2 class="title" style="clear: both"> 5197<div class="titlepage"><div><div><h2 class="title" style="clear: both">
5205<a name="creating.common"></a>14.1. Common types of packages</h2></div></div></div> 5198<a name="creating.common"></a>14.1. Common types of packages</h2></div></div></div>
5206<div class="sect2"> 5199<div class="sect2">
5207<div class="titlepage"><div><div><h3 class="title"> 5200<div class="titlepage"><div><div><h3 class="title">
5208<a name="creating.perl-module"></a>14.1.1. Perl modules</h3></div></div></div> 5201<a name="creating.python-module"></a>14.1.1. Python modules and programs</h3></div></div></div>
5209<p>Simple Perl modules are handled automatically by 
5210<span class="command"><strong>url2pkg</strong></span>, including dependencies.</p> 
5211</div> 
5212<div class="sect2"> 
5213<div class="titlepage"><div><div><h3 class="title"> 
5214<a name="creating.python-module"></a>14.1.2. Python modules and programs</h3></div></div></div> 
5215<p>Python modules and programs packages are easily created using a 5202<p>Python modules and programs packages are easily created using a
5216set of predefined variables.</p> 5203set of predefined variables.</p>
5217<p> 5204<p>
5218If some Python versions are not supported by the software, set the 5205If some Python versions are not supported by the software, set the
5219<code class="varname">PYTHON_VERSIONS_INCOMPATIBLE</code> variable to the Python versions 5206<code class="varname">PYTHON_VERSIONS_INCOMPATIBLE</code> variable to the Python versions
5220that are not supported, e.g. 5207that are not supported, e.g.
5221</p> 5208</p>
5222<pre class="programlisting"> 5209<pre class="programlisting">
5223PYTHON_VERSIONS_INCOMPATIBLE= 27 5210PYTHON_VERSIONS_INCOMPATIBLE= 27
5224</pre> 5211</pre>
5225<p> 5212<p>
5226If the packaged software is a Python module, include one of 5213If the packaged software is a Python module, include one of
5227<code class="filename">../../lang/python/egg.mk</code> or 5214<code class="filename">../../lang/python/egg.mk</code> or
@@ -5256,42 +5243,42 @@ packages that should be depended upon an @@ -5256,42 +5243,42 @@ packages that should be depended upon an
5256<span class="quote">&#8220;<span class="quote"><code class="filename">../../lang/python/versioned_dependencies.mk</code></span>&#8221;</span>, 5243<span class="quote">&#8220;<span class="quote"><code class="filename">../../lang/python/versioned_dependencies.mk</code></span>&#8221;</span>,
5257then the pkgsrc infrastructure will depend on the appropriate package 5244then the pkgsrc infrastructure will depend on the appropriate package
5258version. For example: 5245version. For example:
5259</p> 5246</p>
5260<pre class="programlisting"> 5247<pre class="programlisting">
5261PYTHON_VERSIONED_DEPENDENCIES=dialog 5248PYTHON_VERSIONED_DEPENDENCIES=dialog
5262</pre> 5249</pre>
5263<p> 5250<p>
5264Look inside <code class="filename">versioned_dependencies.mk</code> for a list 5251Look inside <code class="filename">versioned_dependencies.mk</code> for a list
5265of supported packages.</p> 5252of supported packages.</p>
5266</div> 5253</div>
5267<div class="sect2"> 5254<div class="sect2">
5268<div class="titlepage"><div><div><h3 class="title"> 5255<div class="titlepage"><div><div><h3 class="title">
5269<a name="creating.R-package"></a>14.1.3. R packages</h3></div></div></div> 5256<a name="creating.R-package"></a>14.1.2. R packages</h3></div></div></div>
5270<p>Simple R packages from <a class="ulink" href="https://cran.r-project.org/web/packages/available_packages_by_name.html" target="_top">CRAN</a> 5257<p>Simple R packages from <a class="ulink" href="https://cran.r-project.org/web/packages/available_packages_by_name.html" target="_top">CRAN</a>
5271are handled automatically by <span class="command"><strong>R2pkg</strong></span>, which is 5258are handled automatically by <span class="command"><strong>R2pkg</strong></span>, which is
5272available in <a href="https://cdn.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/R2pkg/index.html" target="_top"><code class="filename">pkgtools/R2pkg</code></a>. 5259available in <a href="https://cdn.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/R2pkg/index.html" target="_top"><code class="filename">pkgtools/R2pkg</code></a>.
5273Individual packages (and optionally their dependencies) may be created 5260Individual packages (and optionally their dependencies) may be created
5274and updated. R packages generally follow the same form, and most of 5261and updated. R packages generally follow the same form, and most of
5275the relevant information needed is contained in a 5262the relevant information needed is contained in a
5276<code class="filename">DESCRIPTION</code> file as part of each R package on 5263<code class="filename">DESCRIPTION</code> file as part of each R package on
5277<a class="ulink" href="https://cran.r-project.org/web/packages/available_packages_by_name.html" target="_top">CRAN</a>. 5264<a class="ulink" href="https://cran.r-project.org/web/packages/available_packages_by_name.html" target="_top">CRAN</a>.
5278Consequently, <span class="command"><strong>R2pkg</strong></span> downloads that information and 5265Consequently, <span class="command"><strong>R2pkg</strong></span> downloads that information and
5279creates or updates a package in the canonical form. The resulting 5266creates or updates a package in the canonical form. The resulting
5280package should be reviewed for correctness.</p> 5267package should be reviewed for correctness.</p>
5281</div> 5268</div>
5282<div class="sect2"> 5269<div class="sect2">
5283<div class="titlepage"><div><div><h3 class="title"> 5270<div class="titlepage"><div><div><h3 class="title">
5284<a name="creating.TeX-package"></a>14.1.4. TeXlive packages</h3></div></div></div> 5271<a name="creating.TeX-package"></a>14.1.3. TeXlive packages</h3></div></div></div>
5285<p>TeXlive packages from <a class="ulink" href="https://www.ctan.org/" target="_top">CTAN</a> are handled automatically by 5272<p>TeXlive packages from <a class="ulink" href="https://www.ctan.org/" target="_top">CTAN</a> are handled automatically by
5286<span class="command"><strong>texlive2pkg</strong></span>, which is available in <a href="https://cdn.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/texlive2pkg/index.html" target="_top"><code class="filename">pkgtools/texlive2pkg</code></a>.</p> 5273<span class="command"><strong>texlive2pkg</strong></span>, which is available in <a href="https://cdn.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/texlive2pkg/index.html" target="_top"><code class="filename">pkgtools/texlive2pkg</code></a>.</p>
5287<p>If the TeXlive package name is not known, it may be useful to 5274<p>If the TeXlive package name is not known, it may be useful to
5288search <a class="ulink" href="https://www.ctan.org/" target="_top">CTAN</a>. A 5275search <a class="ulink" href="https://www.ctan.org/" target="_top">CTAN</a>. A
5289<span class="quote">&#8220;<span class="quote">Contained in</span>&#8221;</span> field on the package page typically 5276<span class="quote">&#8220;<span class="quote">Contained in</span>&#8221;</span> field on the package page typically
5290identifies the basename of the package file in the <a class="ulink" href="https://www.ctan.org/tex-archive/systems/texlive/tlnet/archive" target="_top">TeXlive 5277identifies the basename of the package file in the <a class="ulink" href="https://www.ctan.org/tex-archive/systems/texlive/tlnet/archive" target="_top">TeXlive
5291archive</a>.</p> 5278archive</a>.</p>
5292<p>If the TeXlive package name is known, download the files from 5279<p>If the TeXlive package name is known, download the files from
5293the <a class="ulink" href="https://www.ctan.org/tex-archive/systems/texlive/tlnet/archive" target="_top">TeXlive 5280the <a class="ulink" href="https://www.ctan.org/tex-archive/systems/texlive/tlnet/archive" target="_top">TeXlive
5294archive</a>. For package <code class="filename">foo</code>, you will need 5281archive</a>. For package <code class="filename">foo</code>, you will need
5295to download <code class="filename">foo.tar.xz</code>. Most TeXlive packages 5282to download <code class="filename">foo.tar.xz</code>. Most TeXlive packages
5296also have associated documentation packages, so download 5283also have associated documentation packages, so download
5297<code class="filename">foo.doc.tar.xz</code> at the same time. These files 5284<code class="filename">foo.doc.tar.xz</code> at the same time. These files
@@ -11025,84 +11012,84 @@ such as ASLR. Some operating systems su @@ -11025,84 +11012,84 @@ such as ASLR. Some operating systems su
11025(ASLR), which causes different addresses to be used each time a program is run. 11012(ASLR), which causes different addresses to be used each time a program is run.
11026This makes it more difficult for an attacker to guess addresses and thus makes 11013This makes it more difficult for an attacker to guess addresses and thus makes
11027exploits harder to construct. With PIE, ASLR can really be applied to the entire 11014exploits harder to construct. With PIE, ASLR can really be applied to the entire
11028program, instead of the stack and heap only. 11015program, instead of the stack and heap only.
11029</p> 11016</p>
11030<p> 11017<p>
11031PIE executables will only be built for toolchains that are known to support PIE. 11018PIE executables will only be built for toolchains that are known to support PIE.
11032Currently, this means NetBSD on x86, ARM, SPARC64, m68k, and MIPS. 11019Currently, this means NetBSD on x86, ARM, SPARC64, m68k, and MIPS.
11033</p> 11020</p>
11034<p> 11021<p>
11035<code class="varname">PKGSRC_MKPIE</code> was enabled by default after the pkgsrc-2021Q3 branch. 11022<code class="varname">PKGSRC_MKPIE</code> was enabled by default after the pkgsrc-2021Q3 branch.
11036</p> 11023</p>
11037</div> 11024</div>
11038</div> 
11039<div class="sect2"> 
11040<div class="titlepage"><div><div><h3 class="title"> 
11041<a name="hardening.mechanisms.disabled"></a>B.1.2. Not enabled by default</h3></div></div></div> 
11042<div class="sect3"> 11025<div class="sect3">
11043<div class="titlepage"><div><div><h4 class="title"> 11026<div class="titlepage"><div><div><h4 class="title">
11044<a name="hardening.mechanisms.disabled.repro"></a>B.1.2.1. PKGSRC_MKREPRO</h4></div></div></div> 11027<a name="hardening.mechanisms.enabled.relro"></a>B.1.1.4. PKGSRC_USE_RELRO</h4></div></div></div>
11045<p> 
11046With this option, pkgsrc will try to build packages reproducibly. This allows 
11047packages built from the same tree and with the same options, to produce 
11048identical results bit by bit. This option should be combined with ASLR and 
11049<code class="varname">PKGSRC_MKPIE</code> to avoid predictable address offsets for 
11050attackers attempting to exploit security vulnerabilities. 
11051</p> 
11052<p> 
11053More details can be found here: 
11054</p> 
11055<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p> 
11056<a class="ulink" href="https://reproducible-builds.org/" target="_top">Reproducible Builds - a set of software development practices that create an independently-verifiable path from source to binary code</a> 
11057</p></li></ul></div> 
11058<p> 
11059More work likely needs to be done before pkgsrc is fully reproducible. 
11060</p> 
11061</div> 
11062<div class="sect3"> 
11063<div class="titlepage"><div><div><h4 class="title"> 
11064<a name="hardening.mechanisms.enabled.relro"></a>B.1.2.2. PKGSRC_USE_RELRO</h4></div></div></div> 
11065<p> 11028<p>
11066This also makes the exploitation of some security vulnerabilities more 11029This also makes the exploitation of some security vulnerabilities more
11067difficult in some cases. 11030difficult in some cases.
11068</p> 11031</p>
11069<p>Two different mitigation levels are available:</p> 11032<p>Two different mitigation levels are available:</p>
11070<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> 11033<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
11071<li class="listitem"><p> 11034<li class="listitem"><p>
11072partial: the ELF sections are reordered so that internal data sections 11035partial (the default): the ELF sections are reordered so that internal data sections
11073precede the program's own data sections, and non-PLT GOT is read-only; 11036precede the program's own data sections, and non-PLT GOT is read-only;
11074</p></li> 11037</p></li>
11075<li class="listitem"><p> 11038<li class="listitem"><p>
11076full: in addition to partial RELRO, every relocation is performed immediately 11039full: in addition to partial RELRO, every relocation is performed immediately
11077when starting the program, allowing the entire GOT to be read-only. This 11040when starting the program, allowing the entire GOT to be read-only. This
11078can greatly slow down startup of large programs. 11041can greatly slow down startup of large programs.
11079</p></li> 11042</p></li>
11080</ul></div> 11043</ul></div>
11081<p> 11044<p>
11082This is currently supported by GCC. Many software distributions now enable this 11045This is currently supported by GCC. Many software distributions now enable this
11083feature by default, at the "partial" level. However, it cannot yet be enforced 11046feature by default, at the "partial" level. However, it cannot yet be enforced
11084globally in pkgsrc through cwrappers. 11047globally in pkgsrc through cwrappers.
11085</p> 11048</p>
11086<p> 11049<p>
11087More details can be found here: 11050More details can be found here:
11088</p> 11051</p>
11089<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p> 11052<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
11090<a class="ulink" href="https://www.redhat.com/en/blog/hardening-elf-binaries-using-relocation-read-only-relro" target="_top">Hardening ELF binaries using Relocation Read-Only (RELRO)</a> 11053<a class="ulink" href="https://www.redhat.com/en/blog/hardening-elf-binaries-using-relocation-read-only-relro" target="_top">Hardening ELF binaries using Relocation Read-Only (RELRO)</a>
11091</p></li></ul></div> 11054</p></li></ul></div>
11092</div> 11055</div>
 11056</div>
 11057<div class="sect2">
 11058<div class="titlepage"><div><div><h3 class="title">
 11059<a name="hardening.mechanisms.disabled"></a>B.1.2. Not enabled by default</h3></div></div></div>
 11060<div class="sect3">
 11061<div class="titlepage"><div><div><h4 class="title">
 11062<a name="hardening.mechanisms.disabled.repro"></a>B.1.2.1. PKGSRC_MKREPRO</h4></div></div></div>
 11063<p>
 11064With this option, pkgsrc will try to build packages reproducibly. This allows
 11065packages built from the same tree and with the same options, to produce
 11066identical results bit by bit. This option should be combined with ASLR and
 11067<code class="varname">PKGSRC_MKPIE</code> to avoid predictable address offsets for
 11068attackers attempting to exploit security vulnerabilities.
 11069</p>
 11070<p>
 11071More details can be found here:
 11072</p>
 11073<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
 11074<a class="ulink" href="https://reproducible-builds.org/" target="_top">Reproducible Builds - a set of software development practices that create an independently-verifiable path from source to binary code</a>
 11075</p></li></ul></div>
 11076<p>
 11077More work likely needs to be done before pkgsrc is fully reproducible.
 11078</p>
 11079</div>
11093<div class="sect3"> 11080<div class="sect3">
11094<div class="titlepage"><div><div><h4 class="title"> 11081<div class="titlepage"><div><div><h4 class="title">
11095<a name="hardening.mechanisms.disabled.stackcheck"></a>B.1.2.3. PKGSRC_USE_STACK_CHECK</h4></div></div></div> 11082<a name="hardening.mechanisms.disabled.stackcheck"></a>B.1.2.2. PKGSRC_USE_STACK_CHECK</h4></div></div></div>
11096<p> 11083<p>
11097This uses <code class="literal">-fstack-check</code> with GCC for 11084This uses <code class="literal">-fstack-check</code> with GCC for
11098another stack protection mitigation. 11085another stack protection mitigation.
11099</p> 11086</p>
11100<p> 11087<p>
11101It asks the compiler to generate code verifying that it does not corrupt the 11088It asks the compiler to generate code verifying that it does not corrupt the
11102stack. According to GCC's manual page, this is really only useful for 11089stack. According to GCC's manual page, this is really only useful for
11103multi-threaded programs. 11090multi-threaded programs.
11104</p> 11091</p>
11105</div> 11092</div>
11106</div> 11093</div>
11107</div> 11094</div>
11108<div class="sect1"> 11095<div class="sect1">

cvs diff -r1.331 -r1.332 pkgsrc/doc/pkgsrc.txt (expand / switch to unified diff)

--- pkgsrc/doc/pkgsrc.txt 2022/02/11 08:06:21 1.331
+++ pkgsrc/doc/pkgsrc.txt 2022/02/13 11:16:54 1.332
@@ -195,30 +195,29 @@ II. The pkgsrc developer's guide @@ -195,30 +195,29 @@ II. The pkgsrc developer's guide
195 13.10. The wrapper phase 195 13.10. The wrapper phase
196 13.11. The configure phase 196 13.11. The configure phase
197 13.12. The build phase 197 13.12. The build phase
198 13.13. The test phase 198 13.13. The test phase
199 13.14. The install phase 199 13.14. The install phase
200 13.15. The package phase 200 13.15. The package phase
201 13.16. Cleaning up 201 13.16. Cleaning up
202 13.17. Other helpful targets 202 13.17. Other helpful targets
203 203
204 14. Creating a new pkgsrc package from scratch 204 14. Creating a new pkgsrc package from scratch
205 205
206 14.1. Common types of packages 206 14.1. Common types of packages
207 207
208 14.1.1. Perl modules 208 14.1.1. Python modules and programs
209 14.1.2. Python modules and programs 209 14.1.2. R packages
210 14.1.3. R packages 210 14.1.3. TeXlive packages
211 14.1.4. TeXlive packages 
212 211
213 14.2. Examples 212 14.2. Examples
214 213
215 14.2.1. How the www/nvu package came into pkgsrc 214 14.2.1. How the www/nvu package came into pkgsrc
216 215
217 15. Programming in Makefiles 216 15. Programming in Makefiles
218 217
219 15.1. Caveats 218 15.1. Caveats
220 15.2. Makefile variables 219 15.2. Makefile variables
221 220
222 15.2.1. Naming conventions 221 15.2.1. Naming conventions
223 222
224 15.3. Code snippets 223 15.3. Code snippets
@@ -2721,30 +2720,29 @@ Table of Contents @@ -2721,30 +2720,29 @@ Table of Contents
2721 13.10. The wrapper phase 2720 13.10. The wrapper phase
2722 13.11. The configure phase 2721 13.11. The configure phase
2723 13.12. The build phase 2722 13.12. The build phase
2724 13.13. The test phase 2723 13.13. The test phase
2725 13.14. The install phase 2724 13.14. The install phase
2726 13.15. The package phase 2725 13.15. The package phase
2727 13.16. Cleaning up 2726 13.16. Cleaning up
2728 13.17. Other helpful targets 2727 13.17. Other helpful targets
2729 2728
273014. Creating a new pkgsrc package from scratch 272914. Creating a new pkgsrc package from scratch
2731 2730
2732 14.1. Common types of packages 2731 14.1. Common types of packages
2733 2732
2734 14.1.1. Perl modules 2733 14.1.1. Python modules and programs
2735 14.1.2. Python modules and programs 2734 14.1.2. R packages
2736 14.1.3. R packages 2735 14.1.3. TeXlive packages
2737 14.1.4. TeXlive packages 
2738 2736
2739 14.2. Examples 2737 14.2. Examples
2740 2738
2741 14.2.1. How the www/nvu package came into pkgsrc 2739 14.2.1. How the www/nvu package came into pkgsrc
2742 2740
274315. Programming in Makefiles 274115. Programming in Makefiles
2744 2742
2745 15.1. Caveats 2743 15.1. Caveats
2746 15.2. Makefile variables 2744 15.2. Makefile variables
2747 2745
2748 15.2.1. Naming conventions 2746 15.2.1. Naming conventions
2749 2747
2750 15.3. Code snippets 2748 15.3. Code snippets
@@ -4205,158 +4203,146 @@ print-PLIST @@ -4205,158 +4203,146 @@ print-PLIST
4205 If the package installs files via tar(1) or other methods that don't update 4203 If the package installs files via tar(1) or other methods that don't update
4206 file access times, be sure to add these files manually to your PLIST, as 4204 file access times, be sure to add these files manually to your PLIST, as
4207 the "find -newer" command used by this target won't catch them! 4205 the "find -newer" command used by this target won't catch them!
4208 4206
4209 See Section 19.3, "Tweaking output of make print-PLIST" for more 4207 See Section 19.3, "Tweaking output of make print-PLIST" for more
4210 information on this target. 4208 information on this target.
4211 4209
4212Chapter 14. Creating a new pkgsrc package from scratch 4210Chapter 14. Creating a new pkgsrc package from scratch
4213 4211
4214Table of Contents 4212Table of Contents
4215 4213
421614.1. Common types of packages 421414.1. Common types of packages
4217 4215
4218 14.1.1. Perl modules 4216 14.1.1. Python modules and programs
4219 14.1.2. Python modules and programs 4217 14.1.2. R packages
4220 14.1.3. R packages 4218 14.1.3. TeXlive packages
4221 14.1.4. TeXlive packages 
4222 4219
422314.2. Examples 422014.2. Examples
4224 4221
4225 14.2.1. How the www/nvu package came into pkgsrc 4222 14.2.1. How the www/nvu package came into pkgsrc
4226 4223
4227When you find a package that is not yet in pkgsrc, you most likely have a URL 4224When you find a package that is not yet in pkgsrc, you most likely have a URL
4228from where you can download the source code. Starting with this URL, creating a 4225from where you can download the source code. Starting with this URL, creating a
4229package involves only a few steps. 4226package involves only a few steps.
4230 4227
4231 1. In your mk.conf, set PKG_DEVELOPER=yes to enable the basic quality checks. 4228 1. In your mk.conf, set PKG_DEVELOPER=yes to enable the basic quality checks.
4232 4229
4233 2. Install the package meta-pkgs/pkg_developer, which among others will 4230 2. Install the package meta-pkgs/pkg_developer, which among others will
4234 install the utilities url2pkg, pkglint, pkgvi and mkpatches: 4231 install the utilities url2pkg, pkglint, pkgvi and mkpatches:
4235 4232
4236 $ cd /usr/pkgsrc 4233 $ cd /usr/pkgsrc
4237 $ (cd meta-pkgs/pkg_developer && bmake update) 4234 $ (cd meta-pkgs/pkg_developer && bmake update)
4238 4235
4239 3. Choose one of the top-level directories as the category in which you want 4236 3. Choose one of the top-level directories as the category in which you want
4240 to place your package. You can also create a directory of your own (maybe 4237 to place your package. You can also create a directory of your own (maybe
4241 called local). In that category directory, create another directory for 4238 called local). Change into that category directory:
4242 your package and change into it: 
4243 4239
4244 $ mkdir category/package 4240 $ cd category
4245 $ cd category/package 
4246 4241
4247 4. Run the program url2pkg, which will ask you for a URL. Enter the URL of the 4242 4. Run the program url2pkg, passing as argument the URL of the distribution
4248 distribution file (in most cases a .tar.gz file) and watch how the basic 4243 file (in most cases a .tar.gz file). This will download the distribution
4249 ingredients of your package are created automatically. The distribution 4244 file and create the necessary files of the package, based on what's in the
4250 file is extracted automatically to fill in some details in the Makefile 4245 distribution file:
4251 that would otherwise have to be done manually: 
4252 4246
4253 $ url2pkg https://www.example.org/packages/package-1.0.tar.gz 4247 $ url2pkg https://www.example.org/packages/package-1.0.tar.gz
4254 4248
4255 5. Examine the extracted files to determine the dependencies of your package. 4249 5. Examine the extracted files to determine the dependencies of your package.
4256 Ideally, this is mentioned in some README file, but things may differ. For 4250 Ideally, this is mentioned in some README file, but things may differ. For
4257 each of these dependencies, look where it exists in pkgsrc, and if there is 4251 each of these dependencies, look where it exists in pkgsrc, and if there is
4258 a file called buildlink3.mk in that directory, add a line to your package 4252 a file called buildlink3.mk in that directory, add a line to your package
4259 Makefile which includes that file just before the last line. If the 4253 Makefile which includes that file just before the last line. If the
4260 buildlink3.mk file does not exist, it must be created first. The 4254 buildlink3.mk file does not exist, it must be created first. The
4261 buildlink3.mk file makes sure that the package's include files and 4255 buildlink3.mk file makes sure that the package's include files and
4262 libraries are provided. 4256 libraries are provided.
4263 4257
4264 If you just need binaries from a package, add a DEPENDS line to the 4258 If you just need binaries from a dependent package, add a DEPENDS line to
4265 Makefile, which specifies the version of the dependency and where it can be 4259 the Makefile, which specifies the version of the dependency and where it
4266 found in pkgsrc. This line should be placed in the third paragraph. If the 4260 can be found in pkgsrc. This line should be placed in the third paragraph.
4267 dependency is only needed for building the package, but not when using it, 4261 If the dependency is only needed for building the package, but not when
4268 use TOOL_DEPENDS or BUILD_DEPENDS instead of DEPENDS. The difference 4262 using it, use TOOL_DEPENDS or BUILD_DEPENDS instead of DEPENDS. The
4269 between TOOL_DEPENDS and BUILD_DEPENDS occurs when cross-compiling: 4263 difference between TOOL_DEPENDS and BUILD_DEPENDS occurs when
4270 TOOL_DEPENDS are native packages, i.e. packages for the architecture where 4264 cross-compiling: TOOL_DEPENDS are native packages, i.e. packages for the
4271 the package is built; BUILD_DEPENDS are target packages, i.e. packages for 4265 platform where the package is built; BUILD_DEPENDS are target packages,
4272 the architecture for which the package is built. There is also 4266 i.e. packages for the platform for which the package is built. There is
4273 TEST_DEPENDS, which is used to specify a dependency used only for testing 4267 also TEST_DEPENDS, which specifies a dependency used only for testing the
4274 the resulting package built, using the upstream project's included test 4268 resulting package built, using the upstream project's included test suite,
4275 suite. Your package may then look like this: 4269 on the native platform. Your package may then look like this:
4276 4270
4277 [...] 4271 [...]
4278 4272
4279 TOOL_DEPENDS+= libxslt-[0-9]*:../../textproc/libxslt 4273 TOOL_DEPENDS+= libxslt-[0-9]*:../../textproc/libxslt
4280 DEPENDS+= screen-[0-9]*:../../misc/screen 4274 DEPENDS+= screen-[0-9]*:../../misc/screen
4281 DEPENDS+= screen>=4.0:../../misc/screen 4275 DEPENDS+= screen>=4.0:../../misc/screen
4282 4276
4283 [...] 4277 [...]
4284 4278
4285 .include "../../category/package/buildlink3.mk" 4279 .include "../../category/package/buildlink3.mk"
4286 .include "../../devel/glib2/buildlink3.mk" 4280 .include "../../devel/glib2/buildlink3.mk"
4287 .include "../../mk/bsd.pkg.mk" 4281 .include "../../mk/bsd.pkg.mk"
4288 4282
4289 6. Run pkglint to see what things still need to be done to make your package a 4283 6. Run pkglint to see what things still need to be done to make your package a
4290 "good" one. If you don't know what pkglint's warnings want to tell you, try 4284 "good" one. If you don't know what pkglint's warnings want to tell you, try
4291 pkglint --explain or pkglint -e, which outputs additional explanations. 4285 pkglint --explain or pkglint -e, which outputs additional explanations.
4292 4286
4293 7. In many cases the package is not yet ready to build. You can find 4287 7. In many cases the package is not yet ready to build. You can find
4294 instructions for the most common cases in the next section, Section 14.1, 4288 instructions for the most common cases in the next section, Section 14.1,
4295 "Common types of packages". After you have followed the instructions over 4289 "Common types of packages". After you have followed the instructions over
4296 there, you can hopefully continue here. 4290 there, you can hopefully continue here.
4297 4291
4298 8. Run bmake clean to clean the working directory from the extracted files. 4292 8. Run bmake clean to clean the working directory from the extracted files.
4299 Besides these files, a lot of cache files and other system information has 4293 Besides these files, a lot of cache files and other system information have
4300 been saved in the working directory, which may become wrong after you 4294 been saved in the working directory, which may have become outdated after
4301 edited the Makefile. 4295 you edited the Makefile.
4302 4296
4303 9. Now, run bmake to build the package. For the various things that can go 4297 9. Now, run bmake to build the package. For the various things that can go
4304 wrong in this phase, consult Chapter 21, Making your package work. 4298 wrong in this phase, consult Chapter 21, Making your package work.
4305 4299
4306 If the extracted files from the package need to be fixed, run multiple 4300 If the extracted files from the package need to be fixed, run multiple
4307 rounds of these commands: 4301 rounds of these commands:
4308 4302
4309 $ make 4303 $ bmake
4310 $ pkgvi ${WRKSRC}/some/file/that/does/not/compile 4304 $ pkgvi ${WRKSRC}/some/file/that/does/not/compile
4311 $ mkpatches 4305 $ mkpatches
4312 $ make mps 4306 $ bmake mps
4313 $ make clean 4307 $ bmake clean
4314 4308
431510. When the package builds fine, the next step is to install the package. Run  430910. When the package builds fine, the next step is to install the package. Run
4316 bmake install and hope that everything works. 4310 bmake install and hope that everything works.
4317 4311
431811. Up to now, the file PLIST, which contains a list of the files that are 431211. Up to now, the file PLIST, which contains a list of the files that are
4319 installed by the package, is nearly empty. Run bmake print-PLIST >PLIST to 4313 installed by the package, is nearly empty. Run bmake print-PLIST >PLIST to
4320 generate a probably correct list. Check the file using your preferred text 4314 generate a probably correct list. Check the file using your preferred text
4321 editor to see if the list of files looks plausible. 4315 editor to see if the list of files looks plausible.
4322 4316
432312. Run pkglint again to see if the generated PLIST contains garbage or not. 431712. Run pkglint again to see if the generated PLIST contains garbage or not.
4324 4318
432513. When you ran bmake install, the package had been registered in the database 431913. When you ran bmake install, the package had been registered in the database
4326 of installed files, but with an empty list of files. To fix this, run bmake 4320 of installed files, but with an empty list of files. To fix this, run bmake
4327 deinstall and bmake install again. Now the package is registered with the 4321 deinstall and bmake install again. Now the package is registered with the
4328 list of files from PLIST. 4322 list of files from PLIST.
4329 4323
433014. Run bmake package to create a binary package from the set of installed 432414. Run bmake clean update to run everything from above again in a single step,
4331 files. 
4332 
433315. Run bmake clean update to run everything from above again in a single step, 
4334 making sure that the PLIST is correct and the whole package is created as 4325 making sure that the PLIST is correct and the whole package is created as
4335 intended. 4326 intended.
4336 4327
433716. Run pkglint to see if there's anything left to do. 432815. Run pkglint to see if there's anything left to do.
4338 4329
433917. Commit the package to pkgsrc-wip or main pkgsrc; see Chapter 23, Submitting 433016. Commit the package to pkgsrc-wip or main pkgsrc; see Chapter 23, Submitting
4340 and Committing. 4331 and Committing.
4341 4332
434214.1. Common types of packages 433314.1. Common types of packages
4343 4334
434414.1.1. Perl modules 433514.1.1. Python modules and programs
4345 
4346Simple Perl modules are handled automatically by url2pkg, including 
4347dependencies. 
4348 
434914.1.2. Python modules and programs 
4350 4336
4351Python modules and programs packages are easily created using a set of 4337Python modules and programs packages are easily created using a set of
4352predefined variables. 4338predefined variables.
4353 4339
4354If some Python versions are not supported by the software, set the 4340If some Python versions are not supported by the software, set the
4355PYTHON_VERSIONS_INCOMPATIBLE variable to the Python versions that are not 4341PYTHON_VERSIONS_INCOMPATIBLE variable to the Python versions that are not
4356supported, e.g. 4342supported, e.g.
4357 4343
4358PYTHON_VERSIONS_INCOMPATIBLE= 27 4344PYTHON_VERSIONS_INCOMPATIBLE= 27
4359 4345
4360If the packaged software is a Python module, include one of ../../lang/python/ 4346If the packaged software is a Python module, include one of ../../lang/python/
4361egg.mk or ../../lang/python/extension.mk. 4347egg.mk or ../../lang/python/extension.mk.
4362 4348
@@ -4376,37 +4362,37 @@ be corrected. For example: @@ -4376,37 +4362,37 @@ be corrected. For example:
4376 4362
4377REPLACE_PYTHON= *.py 4363REPLACE_PYTHON= *.py
4378 4364
4379Some Python modules have separate distributions for Python-2.x and Python-3.x 4365Some Python modules have separate distributions for Python-2.x and Python-3.x
4380support. In pkgsrc this is handled by the versioned_dependencies.mk file. Set 4366support. In pkgsrc this is handled by the versioned_dependencies.mk file. Set
4381PYTHON_VERSIONED_DEPENDENCIES to the list of packages that should be depended 4367PYTHON_VERSIONED_DEPENDENCIES to the list of packages that should be depended
4382upon and include "../../lang/python/versioned_dependencies.mk", then the pkgsrc 4368upon and include "../../lang/python/versioned_dependencies.mk", then the pkgsrc
4383infrastructure will depend on the appropriate package version. For example: 4369infrastructure will depend on the appropriate package version. For example:
4384 4370
4385PYTHON_VERSIONED_DEPENDENCIES=dialog 4371PYTHON_VERSIONED_DEPENDENCIES=dialog
4386 4372
4387Look inside versioned_dependencies.mk for a list of supported packages. 4373Look inside versioned_dependencies.mk for a list of supported packages.
4388 4374
438914.1.3. R packages 437514.1.2. R packages
4390 4376
4391Simple R packages from CRAN are handled automatically by R2pkg, which is 4377Simple R packages from CRAN are handled automatically by R2pkg, which is
4392available in pkgtools/R2pkg. Individual packages (and optionally their 4378available in pkgtools/R2pkg. Individual packages (and optionally their
4393dependencies) may be created and updated. R packages generally follow the same 4379dependencies) may be created and updated. R packages generally follow the same
4394form, and most of the relevant information needed is contained in a DESCRIPTION 4380form, and most of the relevant information needed is contained in a DESCRIPTION
4395file as part of each R package on CRAN. Consequently, R2pkg downloads that 4381file as part of each R package on CRAN. Consequently, R2pkg downloads that
4396information and creates or updates a package in the canonical form. The 4382information and creates or updates a package in the canonical form. The
4397resulting package should be reviewed for correctness. 4383resulting package should be reviewed for correctness.
4398 4384
439914.1.4. TeXlive packages 438514.1.3. TeXlive packages
4400 4386
4401TeXlive packages from CTAN are handled automatically by texlive2pkg, which is 4387TeXlive packages from CTAN are handled automatically by texlive2pkg, which is
4402available in pkgtools/texlive2pkg. 4388available in pkgtools/texlive2pkg.
4403 4389
4404If the TeXlive package name is not known, it may be useful to search CTAN. A " 4390If the TeXlive package name is not known, it may be useful to search CTAN. A "
4405Contained in" field on the package page typically identifies the basename of 4391Contained in" field on the package page typically identifies the basename of
4406the package file in the TeXlive archive. 4392the package file in the TeXlive archive.
4407 4393
4408If the TeXlive package name is known, download the files from the TeXlive 4394If the TeXlive package name is known, download the files from the TeXlive
4409archive. For package foo, you will need to download foo.tar.xz. Most TeXlive 4395archive. For package foo, you will need to download foo.tar.xz. Most TeXlive
4410packages also have associated documentation packages, so download 4396packages also have associated documentation packages, so download
4411foo.doc.tar.xz at the same time. These files should be placed in the 4397foo.doc.tar.xz at the same time. These files should be placed in the
4412appropriate category directory, which is often but not always print. Then run 4398appropriate category directory, which is often but not always print. Then run
@@ -9024,66 +9010,67 @@ executables. The PIE mechanism is normal @@ -9024,66 +9010,67 @@ executables. The PIE mechanism is normal
9024they can be loaded at differing addresses at runtime. PIE itself does not have 9010they can be loaded at differing addresses at runtime. PIE itself does not have
9025useful security properties; however, it is necessary to fully leverage some, 9011useful security properties; however, it is necessary to fully leverage some,
9026such as ASLR. Some operating systems support Address Space Layout Randomization 9012such as ASLR. Some operating systems support Address Space Layout Randomization
9027(ASLR), which causes different addresses to be used each time a program is run. 9013(ASLR), which causes different addresses to be used each time a program is run.
9028This makes it more difficult for an attacker to guess addresses and thus makes 9014This makes it more difficult for an attacker to guess addresses and thus makes
9029exploits harder to construct. With PIE, ASLR can really be applied to the 9015exploits harder to construct. With PIE, ASLR can really be applied to the
9030entire program, instead of the stack and heap only. 9016entire program, instead of the stack and heap only.
9031 9017
9032PIE executables will only be built for toolchains that are known to support 9018PIE executables will only be built for toolchains that are known to support
9033PIE. Currently, this means NetBSD on x86, ARM, SPARC64, m68k, and MIPS. 9019PIE. Currently, this means NetBSD on x86, ARM, SPARC64, m68k, and MIPS.
9034 9020
9035PKGSRC_MKPIE was enabled by default after the pkgsrc-2021Q3 branch. 9021PKGSRC_MKPIE was enabled by default after the pkgsrc-2021Q3 branch.
9036 9022
9037B.1.2. Not enabled by default 9023B.1.1.4. PKGSRC_USE_RELRO
9038 
9039B.1.2.1. PKGSRC_MKREPRO 
9040 
9041With this option, pkgsrc will try to build packages reproducibly. This allows 
9042packages built from the same tree and with the same options, to produce 
9043identical results bit by bit. This option should be combined with ASLR and 
9044PKGSRC_MKPIE to avoid predictable address offsets for attackers attempting to 
9045exploit security vulnerabilities. 
9046 
9047More details can be found here: 
9048 
9049 * Reproducible Builds - a set of software development practices that create 
9050 an independently-verifiable path from source to binary code 
9051 
9052More work likely needs to be done before pkgsrc is fully reproducible. 
9053 
9054B.1.2.2. PKGSRC_USE_RELRO 
9055 9024
9056This also makes the exploitation of some security vulnerabilities more 9025This also makes the exploitation of some security vulnerabilities more
9057difficult in some cases. 9026difficult in some cases.
9058 9027
9059Two different mitigation levels are available: 9028Two different mitigation levels are available:
9060 9029
9061 * partial: the ELF sections are reordered so that internal data sections 9030 * partial (the default): the ELF sections are reordered so that internal data
9062 precede the program's own data sections, and non-PLT GOT is read-only; 9031 sections precede the program's own data sections, and non-PLT GOT is
 9032 read-only;
9063 9033
9064 * full: in addition to partial RELRO, every relocation is performed 9034 * full: in addition to partial RELRO, every relocation is performed
9065 immediately when starting the program, allowing the entire GOT to be 9035 immediately when starting the program, allowing the entire GOT to be
9066 read-only. This can greatly slow down startup of large programs. 9036 read-only. This can greatly slow down startup of large programs.
9067 9037
9068This is currently supported by GCC. Many software distributions now enable this 9038This is currently supported by GCC. Many software distributions now enable this
9069feature by default, at the "partial" level. However, it cannot yet be enforced 9039feature by default, at the "partial" level. However, it cannot yet be enforced
9070globally in pkgsrc through cwrappers. 9040globally in pkgsrc through cwrappers.
9071 9041
9072More details can be found here: 9042More details can be found here:
9073 9043
9074 * Hardening ELF binaries using Relocation Read-Only (RELRO) 9044 * Hardening ELF binaries using Relocation Read-Only (RELRO)
9075 9045
9076B.1.2.3. PKGSRC_USE_STACK_CHECK 9046B.1.2. Not enabled by default
 9047
 9048B.1.2.1. PKGSRC_MKREPRO
 9049
 9050With this option, pkgsrc will try to build packages reproducibly. This allows
 9051packages built from the same tree and with the same options, to produce
 9052identical results bit by bit. This option should be combined with ASLR and
 9053PKGSRC_MKPIE to avoid predictable address offsets for attackers attempting to
 9054exploit security vulnerabilities.
 9055
 9056More details can be found here:
 9057
 9058 * Reproducible Builds - a set of software development practices that create
 9059 an independently-verifiable path from source to binary code
 9060
 9061More work likely needs to be done before pkgsrc is fully reproducible.
 9062
 9063B.1.2.2. PKGSRC_USE_STACK_CHECK
9077 9064
9078This uses -fstack-check with GCC for another stack protection mitigation. 9065This uses -fstack-check with GCC for another stack protection mitigation.
9079 9066
9080It asks the compiler to generate code verifying that it does not corrupt the 9067It asks the compiler to generate code verifying that it does not corrupt the
9081stack. According to GCC's manual page, this is really only useful for 9068stack. According to GCC's manual page, this is really only useful for
9082multi-threaded programs. 9069multi-threaded programs.
9083 9070
9084B.2. Caveats 9071B.2. Caveats
9085 9072
9086B.2.1. Problems with PKGSRC_MKPIE 9073B.2.1. Problems with PKGSRC_MKPIE
9087 9074
9088B.2.1.1. Packages failing to build 9075B.2.1.1. Packages failing to build
9089 9076