[BACK]Return to examples.html CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / htdocs / docs / pkgsrc

File: [cvs.NetBSD.org] / htdocs / docs / pkgsrc / examples.html (download) (as text)

Revision 1.208, Wed Oct 6 06:28:22 2021 UTC (2 years, 6 months ago) by nia
Branch: MAIN
Changes since 1.207: +0 -0 lines

regen

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Appendix Á. Á simple example package: bison</title>
<link rel="stylesheet" type="text/css" href="/global.css">
<meta name="generator" content="DocBook XSL Stylesheets VX.X.X">
<link rel="home" href="index.html" title="The pkgsrc guide">
<link rel="up" href="index.html" title="The pkgsrc guide">
<link rel="prev" href="porting.html" title="Chapter7. Ðorting pkgsrc">
<link rel="next" href="hardening.html" title="Appendix Â. Óecurity hardening">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="navheader">
<table width="100%" summary="Navigation header">
<tr><th colspan="3" align="center">Appendix Á. Á simple example package: bison</th></tr>
<tr>
<td width="20%" align="left">
<a accesskey="p" href="porting.html">Prev</a>/td>
<th width="60%" align="center">/th>
<td width="20%" align="right">a accesskey="n" href="hardening.html">Next</a>
</td>
</tr>
</table>
<hr>
</div>
<div class="appendix">
<div class="titlepage"><div><div><h1 class="title">
<a name="examples"></a>Appendix Á. Á simple example package: bison</h1></div></div></div>
<div class="toc">
<p><b>Table of Contents</b></p>
<dl class="toc">
<dt><span class="sect1"><a href="examples.html#example-files">A.1. files</a></span></dt>
<dd><dl>
<dt><span class="sect2"><a href="examples.html#example-Makefile">A.1.1. Makefile</a></span></dt>
<dt><span class="sect2"><a href="examples.html#example-descr">A.1.2. DESCR</a></span></dt>
<dt><span class="sect2"><a href="examples.html#example-plist">A.1.3. PLIST</a></span></dt>
<dt><span class="sect2"><a href="examples.html#checking-package-with-pkglint">A.1.4. Checking a package with pkglint</a></span></dt>
</dl></dd>
<dt><span class="sect1"><a href="examples.html#steps-for-b-i-p">A.2. Steps for building, installing, packaging</a></span></dt>
</dl>
</div>
<p>We checked to find a piece of software that wasn't in the packages
    collection, and picked GNU bison. Quite why someone would want to have
    <span class="command"><strong>bison</strong></span> when Berkeley <span class="command"><strong>yacc</strong></span> is already
    present in the tree is beyond us, but it's useful for the purposes of
    this exercise.</p>
<div class="sect1">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="example-files"></a>A.1. æiles</h2></div></div></div>
<div class="sect2">
<div class="titlepage"><div><div><h3 class="title">
<a name="example-Makefile"></a>A.1.1. Íakefile</h3></div></div></div>
<pre class="programlisting">
# $NetBSD: examples.html,v 1.208 2021/10/06 06:28:22 nia Exp $
#

DISTNAME=       bison-1.25
CATEGORIES=     devel
MASTER_SITES=   ${MASTER_SITE_GNU:=bison/}

MAINTAINER=     pkgsrc-users@NetBSD.org
HOMEPAGE=       https://www.gnu.org/software/bison/bison.html
COMMENT=        GNU yacc clone

GNU_CONFIGURE=  yes
INFO_FILES=     yes

.include "../../mk/bsd.pkg.mk"
</pre>
</div>
<div class="sect2">
<div class="titlepage"><div><div><h3 class="title">
<a name="example-descr"></a>A.1.2. ÄESCR</h3></div></div></div>
<pre class="programlisting">
GNU version of yacc.  Can make re-entrant parsers, and numerous other
improvements.  Why you would want this when Berkeley <a class="citerefentry" href="//man.NetBSD.org/NetBSD-9.2/i386/yacc.1"><span class="citerefentry"><span class="refentrytitle">yacc</span>(1)</span></a> is part
of the NetBSD source tree is beyond me.
</pre>
</div>
<div class="sect2">
<div class="titlepage"><div><div><h3 class="title">
<a name="example-plist"></a>A.1.3. ÐLIST</h3></div></div></div>
<pre class="programlisting">
@comment $NetBSD: examples.html,v 1.208 2021/10/06 06:28:22 nia Exp $
bin/bison
man/man1/bison.1.gz
share/bison.simple
share/bison.hairy
</pre>
</div>
<div class="sect2">
<div class="titlepage"><div><div><h3 class="title">
<a name="checking-package-with-pkglint"></a>A.1.4. Ãhecking a package with pkglint</h3></div></div></div>
<p>The NetBSD package system comes with
        <a href="https://cdn.NetBSD.org/pub/pkgsrc/current/pkgsrc/pkgtools/pkglint/index.html" target="_top"><code class="filename">pkgtools/pkglint</code></a>
	which helps to check the contents of these
	files. After installation it is quite easy to use, just change to the
	directory of the package you wish to examine and run
	<span class="command"><strong>pkglint</strong></span>:</p>
<pre class="screen"><code class="prompt">$</code> <strong class="userinput"><code>pkglint</code></strong>
ERROR: Makefile: Each package must define its LICENSE.
WARN: Makefile:9: HOMEPAGE should migrate from http to https.
NOTE: PLIST:3: The .gz extension is unnecessary for manual pages.
WARN: PLIST:5: "share/bison.hairy" should be sorted before "share/bison.simple".
1 error, 2 warnings and 1 note found.
(Run "pkglint -e" to show explanations.)
(Run "pkglint -fs" to show what can be fixed automatically.)
(Run "pkglint -F" to automatically fix some issues.)</pre>
<p>Depending on the supplied command line arguments (see pkglint(1)),
	more checks will be performed. Use e.g. <span class="command"><strong>pkglint
	-Wall</strong></span> for a very thorough check.</p>
</div>
</div>
<div class="sect1">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="steps-for-b-i-p"></a>A.2. Óteps for building, installing, packaging</h2></div></div></div>
<p>Create the directory where the package lives,
      plus any auxiliary directories:</p>
<pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>cd /usr/pkgsrc/lang</code></strong>
<code class="prompt">#</code> <strong class="userinput"><code>mkdir bison</code></strong>
<code class="prompt">#</code> <strong class="userinput"><code>cd bison</code></strong>
<code class="prompt">#</code> <strong class="userinput"><code>mkdir patches</code></strong></pre>
<p>Create <code class="filename">Makefile</code>, <code class="filename">DESCR</code> and
      <code class="filename">PLIST</code> (see <a class="xref" href="components.html" title="Chapter2. Ðackage components - files, directories and contents">Chapter2, <i>Package components - files, directories and contents</i></a>)
      then continue with fetching the distfile:</p>
<pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make fetch</code></strong>
&gt;&gt; bison-1.25.tar.gz doesn't seem to exist on this system.
&gt;&gt; Attempting to fetch from ftp://prep.ai.mit.edu/pub/gnu//.
Requesting ftp://prep.ai.mit.edu/pub/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
ftp: Error retrieving file: 500 Internal error

&gt;&gt; Attempting to fetch from ftp://wuarchive.wustl.edu/systems/gnu//.
Requesting ftp://wuarchive.wustl.edu/systems/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
ftp: Error retrieving file: 500 Internal error

&gt;&gt; Attempting to fetch from ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//.
Requesting ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
Successfully retrieved file.</pre>
<p>Generate the checksum of the distfile into
      <code class="filename">distinfo</code>:</p>
<pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make makedistinfo</code></strong></pre>
<p>Now compile:</p>
<pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make</code></strong>
&gt;&gt; Checksum OK for bison-1.25.tar.gz.
===&gt;  Extracting for bison-1.25
===&gt;  Patching for bison-1.25
===&gt;   Ignoring empty patch directory
===&gt;  Configuring for bison-1.25
creating cache ./config.cache
checking for gcc... cc
checking whether we are using GNU C... yes
checking for a BSD compatible install... /usr/bin/install -c -o bin -g bin
checking how to run the C preprocessor... cc -E
checking for minix/config.h... no
checking for POSIXized ISC... no
checking whether cross-compiling... no
checking for ANSI C header files... yes
checking for string.h... yes
checking for stdlib.h... yes
checking for memory.h... yes
checking for working const... yes
checking for working alloca.h... no
checking for alloca... yes
checking for strerror... yes
updating cache ./config.cache
creating ./config.status
creating Makefile
===&gt;  Building for bison-1.25
cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g LR0.c
cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g allocate.c
cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g closure.c
cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g conflicts.c
cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g derives.c
cc -c -DXPFILE=\"/usr/pkg/share/bison.simple\"  -DXPFILE1=\"/usr/pkg/share/bison.hairy\" -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1  -g  ./files.c
cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g getargs.c
cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g gram.c
cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g lalr.c
cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g lex.c
cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g main.c
cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g nullable.c
cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g output.c
cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g print.c
cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g reader.c
cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g reduce.c
cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g symtab.c
cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g warshall.c
cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g version.c
cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g getopt.c
cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g getopt1.c
cc  -g -o bison LR0.o allocate.o closure.o conflicts.o derives.o files.o         getargs.o gram.o lalr.o lex.o                                   main.o nullable.o output.o print.o reader.o reduce.o symtab.o   warshall.o version.o getopt.o getopt1.o
./files.c:240: warning: mktemp() possibly used unsafely, consider using mkstemp()
rm -f bison.s1
sed -e "/^#line/ s|bison|/usr/pkg/share/bison|" &lt; ./bison.simple &gt; bison.s1</pre>
<p>Everything seems OK, so install the files:</p>
<pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make install</code></strong>
&gt;&gt; Checksum OK for bison-1.25.tar.gz.
===&gt;  Installing for bison-1.25
sh ./mkinstalldirs /usr/pkg/bin /usr/pkg/share  /usr/pkg/info /usr/pkg/man/man1
rm -f /usr/pkg/bin/bison
cd /usr/pkg/share; rm -f bison.simple bison.hairy
rm -f /usr/pkg/man/man1/bison.1 /usr/pkg/info/bison.info*
install -c  -o bin -g bin -m 555 bison /usr/pkg/bin/bison
/usr/bin/install -c -o bin -g bin -m 644 bison.s1 /usr/pkg/share/bison.simple
/usr/bin/install -c -o bin -g bin -m 644 ./bison.hairy /usr/pkg/share/bison.hairy
cd .; for f in bison.info*;  do /usr/bin/install -c -o bin -g bin -m 644 $f /usr/pkg/info/$f; done
/usr/bin/install -c -o bin -g bin -m 644 ./bison.1 /usr/pkg/man/man1/bison.1
===&gt;  Registering installation for bison-1.25</pre>
<p>You can now use bison, and also - if you decide so - remove it with
      <span class="command"><strong>pkg_delete bison</strong></span>. Should you decide that you want a
      binary package, do this now:</p>
<pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make package</code></strong>
&gt;&gt; Checksum OK for bison-1.25.tar.gz.
===&gt;  Building package for bison-1.25
Creating package bison-1.25.tgz
Registering depends:.
Creating gzip'd tar ball in '/u/pkgsrc/lang/bison/bison-1.25.tgz'</pre>
<p>Now that you don't need the source and object files
      any more, clean up:</p>
<pre class="screen"><code class="prompt">#</code> <strong class="userinput"><code>make clean</code></strong>
===&gt;  Cleaning for bison-1.25</pre>
</div>
</div>
<div class="navfooter">
<hr>
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left">
<a accesskey="p" href="porting.html">Prev</a>/td>
<td width="20%" align="center">/td>
<td width="40%" align="right">a accesskey="n" href="hardening.html">Next</a>
</td>
</tr>
<tr>
<td width="40%" align="left" valign="top">Chapter7. Ðorting pkgsrc/td>
<td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td>
<td width="40%" align="right" valign="top"> Áppendix Â. Óecurity hardening</td>
</tr>
</table>
</div>
</body>
</html>