Annotation of htdocs/docs/pkgsrc/creating.html, revision 1.135
1.120 sevan 1: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
1.1 dsieger 2: <html>
3: <head>
4: <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
1.135 ! rillig 5: <title>Chapter 14. Creating a new pkgsrc package from scratch</title>
1.26 spz 6: <link rel="stylesheet" type="text/css" href="/global.css">
1.1 dsieger 7: <meta name="generator" content="DocBook XSL Stylesheets VX.X.X">
1.15 rillig 8: <link rel="home" href="index.html" title="The pkgsrc guide">
1.1 dsieger 9: <link rel="up" href="developers-guide.html" title="Part II. The pkgsrc developer's guide">
1.135 ! rillig 10: <link rel="prev" href="build.html" title="Chapter 13. The build process">
! 11: <link rel="next" href="makefile.html" title="Chapter 15. Programming in Makefiles">
1.1 dsieger 12: </head>
13: <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
14: <div class="navheader">
15: <table width="100%" summary="Navigation header">
1.135 ! rillig 16: <tr><th colspan="3" align="center">Chapter 14. Creating a new pkgsrc package from scratch</th></tr>
1.1 dsieger 17: <tr>
18: <td width="20%" align="left">
1.135 ! rillig 19: <a accesskey="p" href="build.html">Prev</a> </td>
1.1 dsieger 20: <th width="60%" align="center">Part II. The pkgsrc developer's guide</th>
1.135 ! rillig 21: <td width="20%" align="right"> <a accesskey="n" href="makefile.html">Next</a>
1.1 dsieger 22: </td>
23: </tr>
24: </table>
25: <hr>
26: </div>
1.42 asau 27: <div class="chapter">
1.1 dsieger 28: <div class="titlepage"><div><div><h2 class="title">
1.135 ! rillig 29: <a name="creating"></a>Chapter 14. Creating a new pkgsrc package from scratch</h2></div></div></div>
1.1 dsieger 30: <div class="toc">
31: <p><b>Table of Contents</b></p>
1.100 leot 32: <dl class="toc">
1.135 ! rillig 33: <dt><span class="sect1"><a href="creating.html#creating.common">14.1. Common types of packages</a></span></dt>
1.1 dsieger 34: <dd><dl>
1.135 ! rillig 35: <dt><span class="sect2"><a href="creating.html#creating.perl-module">14.1.1. Perl modules</a></span></dt>
! 36: <dt><span class="sect2"><a href="creating.html#creating.python-module">14.1.2. Python modules and programs</a></span></dt>
! 37: <dt><span class="sect2"><a href="creating.html#creating.R-package">14.1.3. R packages</a></span></dt>
! 38: <dt><span class="sect2"><a href="creating.html#creating.TeX-package">14.1.4. TeXlive packages</a></span></dt>
1.1 dsieger 39: </dl></dd>
1.135 ! rillig 40: <dt><span class="sect1"><a href="creating.html#creating.examples">14.2. Examples</a></span></dt>
! 41: <dd><dl><dt><span class="sect2"><a href="creating.html#creating.nvu">14.2.1. How the www/nvu package came into pkgsrc</a></span></dt></dl></dd>
1.1 dsieger 42: </dl>
43: </div>
44: <p>When you find a package that is not yet in pkgsrc, you
45: most likely have a URL from where you can download the source
46: code. Starting with this URL, creating a package involves only a
47: few steps.</p>
1.24 wiz 48: <div class="procedure"><ol class="procedure" type="1">
1.135 ! rillig 49: <li class="step"><p>In your <a class="link" href="configuring.html#mk.conf"><code class="filename">mk.conf</code></a>, set <code class="code">PKG_DEVELOPER=yes</code> to
! 50: enable the basic quality checks.</p></li>
! 51: <li class="step">
! 52: <p>Install the package <a href="https://cdn.NetBSD.org/pub/pkgsrc/current/pkgsrc/meta-pkgs/pkg_developer/README.html" target="_top"><code class="filename">meta-pkgs/pkg_developer</code></a>, which among others will
! 53: install the utilities <span class="command"><strong>url2pkg</strong></span>,
! 54: <span class="command"><strong>pkglint</strong></span>, <span class="command"><strong>pkgvi</strong></span> and
! 55: <span class="command"><strong>mkpatches</strong></span>:</p>
! 56: <pre class="screen"><code class="prompt">$</code> <strong class="userinput"><code>cd /usr/pkgsrc</code></strong>
! 57: <code class="prompt">$</code> <strong class="userinput"><code>(cd meta-pkgs/pkg_developer && bmake update)</code></strong></pre>
! 58: </li>
! 59: <li class="step">
! 60: <p>Choose one of the top-level directories as the category in
! 61: which you want to place your package. You can also create a directory of
! 62: your own (maybe called <code class="filename">local</code>). In that category
! 63: directory, create another directory for your package and change into
! 64: it:</p>
! 65: <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>
! 66: <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>
! 67: </li>
! 68: <li class="step">
! 69: <p>Run the program <span class="command"><strong>url2pkg</strong></span>, which will ask
1.1 dsieger 70: you for a URL. Enter the URL of the distribution file (in most cases a
71: <code class="filename">.tar.gz</code> file) and watch how the basic ingredients
72: of your package are created automatically. The distribution file is
73: extracted automatically to fill in some details in the
74: <code class="filename">Makefile</code> that would otherwise have to be done
1.135 ! rillig 75: manually:</p>
! 76: <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>
! 77: </li>
1.42 asau 78: <li class="step">
1.1 dsieger 79: <p>Examine the extracted files to determine the dependencies of
80: your package. Ideally, this is mentioned in some
81: <code class="filename">README</code> file, but things may differ. For each of
82: these dependencies, look where it exists in pkgsrc, and if there is a
83: file called <code class="filename">buildlink3.mk</code> in that directory, add a
84: line to your package <code class="filename">Makefile</code> which includes that
85: file just before the last line. If the
1.26 spz 86: <code class="filename">buildlink3.mk</code> file does not exist, it must be
1.133 leot 87: created first. The <code class="filename">buildlink3.mk</code> file makes sure
88: that the package's include files and libraries are provided.</p>
1.26 spz 89: <p>If you just need binaries from a package, add a
1.1 dsieger 90: <code class="varname">DEPENDS</code> line to the Makefile, which specifies the
91: version of the dependency and where it can be found in pkgsrc. This line
92: should be placed in the third paragraph. If the dependency is only
93: needed for building the package, but not when using it, use
1.129 leot 94: <code class="varname">TOOL_DEPENDS</code> or <code class="varname">BUILD_DEPENDS</code>
95: instead of <code class="varname">DEPENDS</code>.
96: The difference between <code class="varname">TOOL_DEPENDS</code> and
97: <code class="varname">BUILD_DEPENDS</code> occurs when cross-compiling:
98: <code class="varname">TOOL_DEPENDS</code> are <span class="emphasis"><em>native</em></span>
99: packages, i.e. packages for the architecture where the package
100: is built;
101: <code class="varname">BUILD_DEPENDS</code> are <span class="emphasis"><em>target</em></span>
102: packages, i.e. packages for the architecture for which the package
1.134 gutterid 103: is built. There is also <code class="varname">TEST_DEPENDS</code>, which is used
104: to specify a dependency used only for testing the resulting package
105: built, using the upstream project's included test suite.
1.1 dsieger 106: Your package may then look like this:</p>
107: <pre class="programlisting">
108: [...]
109:
1.129 leot 110: TOOL_DEPENDS+= libxslt-[0-9]*:../../textproc/libxslt
1.1 dsieger 111: DEPENDS+= screen-[0-9]*:../../misc/screen
112: DEPENDS+= screen>=4.0:../../misc/screen
113:
114: [...]
115:
116: .include "../../<em class="replaceable"><code>category</code></em>/<em class="replaceable"><code>package</code></em>/buildlink3.mk"
117: .include "../../devel/glib2/buildlink3.mk"
118: .include "../../mk/bsd.pkg.mk"
119: </pre>
120: </li>
1.42 asau 121: <li class="step"><p>Run <span class="command"><strong>pkglint</strong></span> to see what things still need
1.24 wiz 122: to be done to make your package a <span class="quote">“<span class="quote">good</span>”</span> one. If you don't
1.10 hubertf 123: know what pkglint's warnings want to tell you, try <span class="command"><strong>pkglint
1.135 ! rillig 124: --explain</strong></span> or <span class="command"><strong>pkglint -e</strong></span>, which outputs
! 125: additional explanations.</p></li>
1.42 asau 126: <li class="step"><p>In many cases the package is not yet ready to build. You can
1.135 ! rillig 127: find instructions for the most common cases in the next section, <a class="xref" href="creating.html#creating.common" title="14.1. Common types of packages">Section 14.1, “Common types of packages”</a>. After you have followed the instructions
1.1 dsieger 128: over there, you can hopefully continue here.</p></li>
1.42 asau 129: <li class="step"><p>Run <span class="command"><strong>bmake clean</strong></span> to clean the working
1.1 dsieger 130: directory from the extracted files. Besides these files, a lot of cache
131: files and other system information has been saved in the working
132: directory, which may become wrong after you edited the
133: <code class="filename">Makefile</code>.</p></li>
1.135 ! rillig 134: <li class="step">
! 135: <p>Now, run <span class="command"><strong>bmake</strong></span> to build the package. For
! 136: the various things that can go wrong in this phase, consult <a class="xref" href="fixes.html" title="Chapter 21. Making your package work">Chapter 21, <i>Making your package work</i></a>.</p>
! 137: <p>If the extracted files from the package need to be fixed, run multiple rounds of these commands:</p>
! 138: <pre class="screen"><code class="prompt">$</code> <strong class="userinput"><code>make</code></strong>
! 139: <code class="prompt">$</code> <strong class="userinput"><code>pkgvi ${WRKSRC}/some/file/that/does/not/compile</code></strong>
! 140: <code class="prompt">$</code> <strong class="userinput"><code>mkpatches</code></strong>
! 141: <code class="prompt">$</code> <strong class="userinput"><code>make mps</code></strong>
! 142: <code class="prompt">$</code> <strong class="userinput"><code>make clean</code></strong></pre>
! 143: </li>
1.42 asau 144: <li class="step"><p>When the package builds fine, the next step is to install
1.10 hubertf 145: the package. Run <span class="command"><strong>bmake install</strong></span> and hope that
1.1 dsieger 146: everything works.</p></li>
1.42 asau 147: <li class="step"><p>Up to now, the file <code class="filename">PLIST</code>, which
1.1 dsieger 148: contains a list of the files that are installed by the package, is
1.10 hubertf 149: nearly empty. Run <span class="command"><strong>bmake print-PLIST
1.1 dsieger 150: >PLIST</strong></span> to generate a probably correct list. Check
151: the file using your preferred text editor to see if the list of
152: files looks plausible.</p></li>
1.42 asau 153: <li class="step"><p>Run <span class="command"><strong>pkglint</strong></span> again to see if the generated
1.1 dsieger 154: <code class="filename">PLIST</code> contains garbage or not.</p></li>
1.42 asau 155: <li class="step"><p>When you ran <span class="command"><strong>bmake install</strong></span>, the package
1.135 ! rillig 156: had been registered in the database of installed files, but with an
1.10 hubertf 157: empty list of files. To fix this, run <span class="command"><strong>bmake deinstall</strong></span>
158: and <span class="command"><strong>bmake install</strong></span> again. Now the package is
1.1 dsieger 159: registered with the list of files from
160: <code class="filename">PLIST</code>.</p></li>
1.42 asau 161: <li class="step"><p>Run <span class="command"><strong>bmake package</strong></span> to create a binary
1.1 dsieger 162: package from the set of installed files.</p></li>
1.135 ! rillig 163: <li class="step"><p>Run <span class="command"><strong>bmake clean update</strong></span> to run everything
! 164: from above again in a single step, making sure that the PLIST is correct
! 165: and the whole package is created as intended.</p></li>
! 166: <li class="step"><p>Run <span class="command"><strong>pkglint</strong></span> to see if there's anything left to do.</p></li>
! 167: <li class="step"><p>Commit the package to pkgsrc-wip or main pkgsrc; see <a class="xref" href="submit.html" title="Chapter 23. Submitting and Committing">Chapter 23, <i>Submitting and Committing</i></a>.</p></li>
1.1 dsieger 168: </ol></div>
1.42 asau 169: <div class="sect1">
1.1 dsieger 170: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.135 ! rillig 171: <a name="creating.common"></a>14.1. Common types of packages</h2></div></div></div>
1.42 asau 172: <div class="sect2">
1.1 dsieger 173: <div class="titlepage"><div><div><h3 class="title">
1.135 ! rillig 174: <a name="creating.perl-module"></a>14.1.1. Perl modules</h3></div></div></div>
1.1 dsieger 175: <p>Simple Perl modules are handled automatically by
1.10 hubertf 176: <span class="command"><strong>url2pkg</strong></span>, including dependencies.</p>
1.1 dsieger 177: </div>
1.42 asau 178: <div class="sect2">
1.1 dsieger 179: <div class="titlepage"><div><div><h3 class="title">
1.135 ! rillig 180: <a name="creating.python-module"></a>14.1.2. Python modules and programs</h3></div></div></div>
1.17 imil 181: <p>Python modules and programs packages are easily created using a
182: set of predefined variables.</p>
183: <p>
1.63 wiz 184: If some Python versions are not supported by the software, set the
185: <code class="varname">PYTHON_VERSIONS_INCOMPATIBLE</code> variable to the Python versions
186: that are not supported, e.g.
1.17 imil 187: </p>
188: <pre class="programlisting">
1.93 sevan 189: PYTHON_VERSIONS_INCOMPATIBLE= 27
1.17 imil 190: </pre>
191: <p>
1.103 wiz 192: If the packaged software is a Python module, include one of
193: <code class="filename">../../lang/python/egg.mk</code>,
194: <code class="filename">../../lang/python/distutils.mk</code>, or
195: <code class="filename">../../lang/python/extension.mk</code>.</p>
196: <p>Most Python packages use either <span class="quote">“<span class="quote">distutils</span>”</span> or
197: easy-setup/setuptools (<span class="quote">“<span class="quote">eggs</span>”</span>).
1.134 gutterid 198: If the packaged software is using setuptools, you only need
1.103 wiz 199: to include <span class="quote">“<span class="quote"><code class="filename">../../lang/python/egg.mk</code></span>”</span>.
200: Otherwise, if the software uses <span class="quote">“<span class="quote">distutils</span>”</span>, include
1.134 gutterid 201: <span class="quote">“<span class="quote"><code class="filename">../../lang/python/distutils.mk</code></span>”</span>,
1.103 wiz 202: so pkgsrc will use this framework.
1.134 gutterid 203: <span class="quote">“<span class="quote">distutils</span>”</span> uses a script called <code class="filename">setup.py</code>;
1.103 wiz 204: if the <span class="quote">“<span class="quote">distutils</span>”</span> driver is not called
205: <code class="filename">setup.py</code>, set the <code class="varname">PYSETUP</code> variable
206: to the name of the script.</p>
207: <p>Either way, the package directory should be called
1.24 wiz 208: <span class="quote">“<span class="quote">py-software</span>”</span> and <code class="varname">PKGNAME</code> should be set to
209: <span class="quote">“<span class="quote">${PYPKGPREFIX}-${DISTNAME}</span>”</span>, e.g.
1.17 imil 210: </p>
211: <pre class="programlisting">
212: DISTNAME= foopymodule-1.2.10
213: PKGNAME= ${PYPKGPREFIX}-${DISTNAME}
214: </pre>
1.63 wiz 215: <p>If it is an application, include
216: <span class="quote">“<span class="quote"><code class="filename">../../lang/python/application.mk</code></span>”</span>.
217: In order to correctly set the path to the Python interpreter, use the
1.17 imil 218: <code class="varname">REPLACE_PYTHON</code> variable and set it to the list of files
1.36 wiz 219: (paths relative to <code class="varname">WRKSRC</code>) that must be corrected.
1.63 wiz 220: For example:
1.17 imil 221: </p>
222: <pre class="programlisting">
1.36 wiz 223: REPLACE_PYTHON= *.py
1.17 imil 224: </pre>
1.63 wiz 225: <p>Some Python modules have separate distributions for Python-2.x
226: and Python-3.x support. In pkgsrc this is handled by the
227: <code class="filename">versioned_dependencies.mk</code> file. Set
228: <code class="varname">PYTHON_VERSIONED_DEPENDENCIES</code> to the list of
229: packages that should be depended upon and include
230: <span class="quote">“<span class="quote"><code class="filename">../../lang/python/versioned_dependencies.mk</code></span>”</span>,
231: then the pkgsrc infrastructure will depend on the appropriate package
232: version. For example:
233: </p>
234: <pre class="programlisting">
1.125 wiz 235: PYTHON_VERSIONED_DEPENDENCIES=dialog
1.63 wiz 236: </pre>
237: <p>
238: Look inside <code class="filename">versioned_dependencies.mk</code> for a list
239: of supported packages.</p>
1.17 imil 240: </div>
1.132 brook 241: <div class="sect2">
242: <div class="titlepage"><div><div><h3 class="title">
1.135 ! rillig 243: <a name="creating.R-package"></a>14.1.3. R packages</h3></div></div></div>
1.132 brook 244: <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>
245: are handled automatically by <span class="command"><strong>R2pkg</strong></span>, which is
246: available in <a href="https://cdn.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/R2pkg/README.html" target="_top"><code class="filename">pkgtools/R2pkg</code></a>.
247: Individual packages (and optionally their dependencies) may be created
248: and updated. R packages generally follow the same form, and most of
249: the relevant information needed is contained in a
250: <code class="filename">DESCRIPTION</code> file as part of each R package on
251: <a class="ulink" href="https://cran.r-project.org/web/packages/available_packages_by_name.html" target="_top">CRAN</a>.
252: Consequently, <span class="command"><strong>R2pkg</strong></span> downloads that information and
253: creates or updates a package in the canonical form. The resulting
254: package should be reviewed for correctness.</p>
255: </div>
256: <div class="sect2">
257: <div class="titlepage"><div><div><h3 class="title">
1.135 ! rillig 258: <a name="creating.TeX-package"></a>14.1.4. TeXlive packages</h3></div></div></div>
1.132 brook 259: <p>TeXlive packages from <a class="ulink" href="https://www.ctan.org/" target="_top">CTAN</a> are handled automatically by
260: <span class="command"><strong>texlive2pkg</strong></span>, which is available in <a href="https://cdn.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/texlive2pkg/README.html" target="_top"><code class="filename">pkgtools/texlive2pkg</code></a>.</p>
261: <p>If the TeXlive package name is not known, it may be useful to
262: search <a class="ulink" href="https://www.ctan.org/" target="_top">CTAN</a>. A
263: <span class="quote">“<span class="quote">Contained in</span>”</span> field on the package page typically
264: identifies 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
265: archive</a>.</p>
266: <p>If the TeXlive package name is known, download the files from
267: the <a class="ulink" href="https://www.ctan.org/tex-archive/systems/texlive/tlnet/archive" target="_top">TeXlive
268: archive</a>. For package <code class="filename">foo</code>, you will need
269: to download <code class="filename">foo.tar.xz</code>. Most TeXlive packages
270: also have associated documentation packages, so download
271: <code class="filename">foo.doc.tar.xz</code> at the same time. These files
272: should be placed in the appropriate category directory, which is often
273: but not always <code class="filename">print</code>. Then run the following
274: command in the category directory.</p>
275: <pre class="programlisting">
276: texlive2pkg foo.tar.xz foo.doc.tar.xz
277: </pre>
278: <p>This will create two packages, <code class="filename">tex-foo</code> and
279: <code class="filename">tex-foo-doc</code>. Be sure to check that both packages
280: are correct.</p>
281: <p>Finally, <a class="ulink" href="https://www.ctan.org/" target="_top">CTAN</a>
282: currently does not include version information in package filenames
283: and changes their contents periodically when updates occur.
284: Consequently, pkgsrc avoids downloading distfiles directly from <a class="ulink" href="https://www.ctan.org/" target="_top">CTAN</a> and instead relies on the
285: pkgsrc archives. For each new or updated TeXlive package, e.g., the
286: main one and the corresponding documentation, upload the distfiles
287: with the following command in each package directory.</p>
288: <pre class="programlisting">
289: make upload-distfiles
290: </pre>
291: </div>
1.1 dsieger 292: </div>
1.42 asau 293: <div class="sect1">
1.1 dsieger 294: <div class="titlepage"><div><div><h2 class="title" style="clear: both">
1.135 ! rillig 295: <a name="creating.examples"></a>14.2. Examples</h2></div></div></div>
1.42 asau 296: <div class="sect2">
1.1 dsieger 297: <div class="titlepage"><div><div><h3 class="title">
1.135 ! rillig 298: <a name="creating.nvu"></a>14.2.1. How the www/nvu package came into pkgsrc</h3></div></div></div>
1.42 asau 299: <div class="sect3">
1.1 dsieger 300: <div class="titlepage"><div><div><h4 class="title">
1.135 ! rillig 301: <a name="creating.nvu.init"></a>14.2.1.1. The initial package</h4></div></div></div>
1.1 dsieger 302: <p>Looking at the file <code class="filename">pkgsrc/doc/TODO</code>, I saw
1.24 wiz 303: that the <span class="quote">“<span class="quote">nvu</span>”</span> package has not yet been imported into
1.1 dsieger 304: pkgsrc. As the description says it has to do with the web, the obvious
1.24 wiz 305: choice for the category is <span class="quote">“<span class="quote">www</span>”</span>.</p>
1.1 dsieger 306: <pre class="programlisting">
307: <code class="prompt">$</code> mkdir www/nvu
308: <code class="prompt">$</code> cd www/nvu
309: </pre>
310: <p>The web site says that the sources are available as a tar file, so
1.10 hubertf 311: I fed that URL to the <span class="command"><strong>url2pkg</strong></span> program:</p>
1.1 dsieger 312: <pre class="programlisting">
313: <code class="prompt">$</code> url2pkg http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
314: </pre>
315: <p>My editor popped up, and I added a <code class="varname">PKGNAME</code> line
316: below the <code class="varname">DISTNAME</code> line, as the package name should
1.24 wiz 317: not have the word <span class="quote">“<span class="quote">sources</span>”</span> in it. I also filled in the
1.1 dsieger 318: <code class="varname">MAINTAINER</code>, <code class="varname">HOMEPAGE</code> and
319: <code class="varname">COMMENT</code> fields. Then the package
320: <code class="filename">Makefile</code> looked like that:</p>
321: <pre class="programlisting">
1.121 sevan 322: # $NetBSD $
1.1 dsieger 323: #
324:
325: DISTNAME= nvu-1.0-sources
326: PKGNAME= nvu-1.0
327: CATEGORIES= www
328: MASTER_SITES= http://cvs.nvu.com/download/
329: EXTRACT_SUFX= .tar.bz2
330:
331: MAINTAINER= rillig@NetBSD.org
332: HOMEPAGE= http://cvs.nvu.com/
333: COMMENT= Web Authoring System
334:
335: # url2pkg-marker (please do not remove this line.)
336: .include "../../mk/bsd.pkg.mk"
337: </pre>
1.123 wiz 338: <p>On the first line of output above, an artificial space has been added between NetBSD and $,
1.121 sevan 339: this is a workaround to prevent CVS expanding to the filename of the
340: guide.</p>
1.1 dsieger 341: <p>Then, I quit the editor and watched pkgsrc downloading a large
342: source archive:</p>
343: <pre class="programlisting">
344: url2pkg> Running "make makesum" ...
345: => Required installed package digest>=20010302: digest-20060826 found
346: => Fetching nvu-1.0-sources.tar.bz2
347: Requesting http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
348: 100% |*************************************| 28992 KB 150.77 KB/s00:00 ETA
349: 29687976 bytes retrieved in 03:12 (150.77 KB/s)
350: url2pkg> Running "make extract" ...
351: => Required installed package digest>=20010302: digest-20060826 found
352: => Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
353: => Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
354: work.bacc -> /tmp/roland/pkgsrc/www/nvu/work.bacc
355: ===> Installing dependencies for nvu-1.0
356: ===> Overriding tools for nvu-1.0
357: ===> Extracting for nvu-1.0
358: url2pkg> Adjusting the Makefile.
359:
360: Remember to correct CATEGORIES, HOMEPAGE, COMMENT, and DESCR when you're done!
361:
362: Good luck! (See pkgsrc/doc/pkgsrc.txt for some more help :-)
363: </pre>
364: </div>
1.42 asau 365: <div class="sect3">
1.1 dsieger 366: <div class="titlepage"><div><div><h4 class="title">
1.135 ! rillig 367: <a name="creating.nvu.problems"></a>14.2.1.2. Fixing all kinds of problems to make the package work</h4></div></div></div>
1.1 dsieger 368: <p>Now that the package has been extracted, let's see what's inside
369: it. The package has a <code class="filename">README.txt</code>, but that only
370: says something about mozilla, so it's probably useless for seeing what
371: dependencies this package has. But since there is a GNU configure script
372: in the package, let's hope that it will complain about everything it
373: needs.</p>
374: <pre class="programlisting">
375: <code class="prompt">$</code> bmake
376: => Required installed package digest>=20010302: digest-20060826 found
377: => Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
378: => Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
379: ===> Patching for nvu-1.0
380: ===> Creating toolchain wrappers for nvu-1.0
381: ===> Configuring for nvu-1.0
382: [...]
383: configure: error: Perl 5.004 or higher is required.
384: [...]
385: WARNING: Please add USE_TOOLS+=perl to the package Makefile.
386: [...]
387: </pre>
388: <p>That worked quite well. So I opened the package Makefile in my
389: editor, and since it already has a <code class="varname">USE_TOOLS</code> line, I
1.24 wiz 390: just appended <span class="quote">“<span class="quote">perl</span>”</span> to it. Since the dependencies of the
1.1 dsieger 391: package have changed now, and since a perl wrapper is automatically
1.24 wiz 392: installed in the <span class="quote">“<span class="quote">tools</span>”</span> phase, I need to build the package
1.1 dsieger 393: from scratch.</p>
394: <pre class="programlisting">
395: <code class="prompt">$</code> bmake clean
396: ===> Cleaning for nvu-1.0
397: <code class="prompt">$</code> bmake
398: [...]
399: *** /tmp/roland/pkgsrc/www/nvu/work.bacc/.tools/bin/make is not \
400: GNU Make. You will not be able to build Mozilla without GNU Make.
401: [...]
402: </pre>
1.24 wiz 403: <p>So I added <span class="quote">“<span class="quote">gmake</span>”</span> to the
1.1 dsieger 404: <code class="varname">USE_TOOLS</code> line and tried again (from scratch).</p>
405: <pre class="programlisting">
406: [...]
407: checking for GTK - version >= 1.2.0... no
408: *** Could not run GTK test program, checking why...
409: [...]
410: </pre>
411: <p>Now to the other dependencies. The first question is: Where is the
412: GTK package hidden in pkgsrc?</p>
413: <pre class="programlisting">
414: <code class="prompt">$</code> echo ../../*/gtk*
415: [many packages ...]
416: <code class="prompt">$</code> echo ../../*/gtk
417: ../../x11/gtk
418: <code class="prompt">$</code> echo ../../*/gtk2
419: ../../x11/gtk2
420: <code class="prompt">$</code> echo ../../*/gtk2/bui*
421: ../../x11/gtk2/buildlink3.mk
422: </pre>
423: <p>The first try was definitely too broad. The second one had exactly
424: one result, which is very good. But there is one pitfall with GNOME
425: packages. Before GNOME 2 had been released, there were already many
426: GNOME 1 packages in pkgsrc. To be able to continue to use these
427: packages, the GNOME 2 packages were imported as separate packages, and
1.24 wiz 428: their names usually have a <span class="quote">“<span class="quote">2</span>”</span> appended. So I checked
1.1 dsieger 429: whether this was the case here, and indeed it was.</p>
430: <p>Since the GTK2 package has a <code class="filename">buildlink3.mk</code>
431: file, adding the dependency is very easy. I just inserted an
432: <code class="literal">.include</code> line before the last line of the package
433: <code class="filename">Makefile</code>, so that it now looks like this:</p>
434: <pre class="programlisting">
435: [...]
436: .include "../../x11/gtk2/buildlink3.mk"
437: .include "../../mk/bsd.pkg.mk
438: </pre>
1.10 hubertf 439: <p>After another <span class="command"><strong>bmake clean && bmake</strong></span>, the answer
1.1 dsieger 440: was:</p>
441: <pre class="programlisting">
442: [...]
443: checking for gtk-config... /home/roland/pkg/bin/gtk-config
444: checking for GTK - version >= 1.2.0... no
445: *** Could not run GTK test program, checking why...
446: *** The test program failed to compile or link. See the file config.log for the
447: *** exact error that occured. This usually means GTK was incorrectly installed
448: *** or that you have moved GTK since it was installed. In the latter case, you
449: *** may want to edit the gtk-config script: /home/roland/pkg/bin/gtk-config
450: configure: error: Test for GTK failed.
451: [...]
452: </pre>
1.24 wiz 453: <p>In this particular case, the assumption that <span class="quote">“<span class="quote">every package
454: prefers GNOME 2</span>”</span> had been wrong. The first of the lines above
1.1 dsieger 455: told me that this package really wanted to have the GNOME 1 version of
456: GTK. If the package had looked for GTK2, it would have looked for
1.10 hubertf 457: <span class="command"><strong>pkg-config</strong></span> instead of <span class="command"><strong>gtk-config</strong></span>.
1.1 dsieger 458: So I changed the <code class="literal">x11/gtk2</code> to
459: <code class="literal">x11/gtk</code> in the package <code class="filename">Makefile</code>,
460: and tried again.</p>
461: <pre class="programlisting">
462: [...]
1.59 jnemeth 463: cc -o xpidl.o -c -DOSTYPE=\"NetBSD3\" -DOSARCH=\"NetBSD\" [...]
1.1 dsieger 464: In file included from xpidl.c:42:
465: xpidl.h:53:24: libIDL/IDL.h: No such file or directory
466: In file included from xpidl.c:42:
467: xpidl.h:132: error: parse error before "IDL_ns"
468: [...]
469: </pre>
470: <p>The package still does not find all of its dependencies. Now the
471: question is: Which package provides the
472: <code class="filename">libIDL/IDL.h</code> header file?</p>
473: <pre class="programlisting">
474: <code class="prompt">$</code> echo ../../*/*idl*
475: ../../devel/py-idle ../../wip/idled ../../x11/acidlaunch
476: <code class="prompt">$</code> echo ../../*/*IDL*
477: ../../net/libIDL
478: </pre>
479: <p>Let's take the one from the second try. So I included the
480: <code class="filename">../../net/libIDL/buildlink3.mk</code> file and tried
481: again. But the error didn't change. After digging through some of the
482: code, I concluded that the build process of the package was broken and
483: couldn't have ever worked, but since the Mozilla source tree is quite
484: large, I didn't want to fix it. So I added the following to the package
485: <code class="filename">Makefile</code> and tried again:</p>
486: <pre class="programlisting">
487: CPPFLAGS+= -I${BUILDLINK_PREFIX.libIDL}/include/libIDL-2.0
1.127 leot 488: BUILDLINK_TRANSFORM+= l:IDL:IDL-2
1.1 dsieger 489: </pre>
490: <p>The latter line is needed because the package expects the library
491: <code class="filename">libIDL.so</code>, but only
492: <code class="filename">libIDL-2.so</code> is available. So I told the compiler
493: wrapper to rewrite that on the fly.</p>
494: <p>The next problem was related to a recent change of the FreeType
1.126 leot 495: interface. I looked up in <a href="https://cdn.NetBSD.org/pub/pkgsrc/current/pkgsrc/www/seamonkey/README.html" target="_top"><code class="filename">www/seamonkey</code></a>
1.1 dsieger 496: which patch files were relevant for this issue and copied them to the
497: <code class="filename">patches</code> directory. Then I retried, fixed the
498: patches so that they applied cleanly and retried again. This time,
499: everything worked.</p>
500: </div>
1.42 asau 501: <div class="sect3">
1.1 dsieger 502: <div class="titlepage"><div><div><h4 class="title">
1.135 ! rillig 503: <a name="creating.nvu.inst"></a>14.2.1.3. Installing the package</h4></div></div></div>
1.1 dsieger 504: <pre class="programlisting">
505: <code class="prompt">$</code> bmake CHECK_FILES=no install
506: [...]
507: <code class="prompt">$</code> bmake print-PLIST >PLIST
508: <code class="prompt">$</code> bmake deinstall
509: <code class="prompt">$</code> bmake install
510: </pre>
511: </div>
512: </div>
513: </div>
514: </div>
515: <div class="navfooter">
516: <hr>
517: <table width="100%" summary="Navigation footer">
518: <tr>
519: <td width="40%" align="left">
1.135 ! rillig 520: <a accesskey="p" href="build.html">Prev</a> </td>
1.1 dsieger 521: <td width="20%" align="center"><a accesskey="u" href="developers-guide.html">Up</a></td>
1.135 ! rillig 522: <td width="40%" align="right"> <a accesskey="n" href="makefile.html">Next</a>
1.1 dsieger 523: </td>
524: </tr>
525: <tr>
1.135 ! rillig 526: <td width="40%" align="left" valign="top">Chapter 13. The build process </td>
1.1 dsieger 527: <td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td>
1.135 ! rillig 528: <td width="40%" align="right" valign="top"> Chapter 15. Programming in <code class="filename">Makefile</code>s</td>
1.1 dsieger 529: </tr>
530: </table>
531: </div>
532: </body>
533: </html>
CVSweb <webmaster@jp.NetBSD.org>