Annotation of htdocs/docs/pkgsrc/creating.html, revision 1.141

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

CVSweb <webmaster@jp.NetBSD.org>