pkgsrc-ng/doc/guide/files/debug.xml
2013-09-26 17:14:40 +02:00

131 lines
4.5 KiB
XML

<!-- $NetBSD: debug.xml,v 1.7 2007/08/15 06:33:44 rillig Exp $ -->
<chapter id="debug">
<title>Debugging</title>
<para>To check out all the gotchas when building a package, here are
the steps that I do in order to get a package working. Please note
this is basically the same as what was explained in the previous
sections, only with some debugging aids.</para>
<itemizedlist>
<listitem>
<para>Be sure to set <varname>PKG_DEVELOPER=yes</varname> in &mk.conf;.</para>
</listitem>
<listitem>
<para>Install <filename role="pkg">pkgtools/url2pkg</filename>,
create a directory for a new package, change into it, then run
<command>url2pkg</command>:</para>
<screen>&cprompt; <userinput>mkdir /usr/pkgsrc/<replaceable>category</replaceable>/<replaceable>examplepkg</replaceable></userinput>
&cprompt; <userinput>cd /usr/pkgsrc/<replaceable>category</replaceable>/<replaceable>examplepkg</replaceable></userinput>
&cprompt; <userinput>url2pkg http://www.example.com/path/to/distfile.tar.gz</userinput></screen>
</listitem>
<listitem>
<para>Edit the <filename>Makefile</filename> as requested.</para>
</listitem>
<listitem>
<para>Fill in the <filename>DESCR</filename> file</para>
</listitem>
<listitem>
<para>Run <command>make configure</command></para>
</listitem>
<listitem>
<para>Add any dependencies glimpsed from documentation and the
configure step to the package's
<filename>Makefile</filename>.</para>
</listitem>
<listitem>
<para>Make the package compile, doing multiple rounds of</para>
<screen>&cprompt; <userinput>make</userinput>
&cprompt; <userinput>pkgvi ${WRKSRC}/some/file/that/does/not/compile</userinput>
&cprompt; <userinput>mkpatches</userinput>
&cprompt; <userinput>patchdiff</userinput>
&cprompt; <userinput>mv ${WRKDIR}/.newpatches/* patches</userinput>
&cprompt; <userinput>make mps</userinput>
&cprompt; <userinput>make clean</userinput></screen>
<para>Doing this step as non-root user will ensure that no files
are modified that shouldn't be, especially during the build
phase. <command>mkpatches</command>,
<command>patchdiff</command> and <command>pkgvi</command> are
from the <filename role="pkg">pkgtools/pkgdiff</filename>
package.</para>
</listitem>
<listitem>
<para>Look at the <filename>Makefile</filename>, fix if
necessary; see <xref linkend="components.Makefile"/>.</para>
</listitem>
<listitem>
<para>Generate a <filename>PLIST</filename>:</para>
<screen>&rprompt; <userinput>make install</userinput>
&rprompt; <userinput>make print-PLIST &gt;PLIST</userinput>
&rprompt; <userinput>make deinstall</userinput>
&rprompt; <userinput>make install</userinput>
&rprompt; <userinput>make deinstall</userinput></screen>
<para>You usually need to be <username>root</username> to do
this. Look if there are any files left:</para>
<screen>&rprompt; <userinput>make print-PLIST</userinput></screen>
<para>If this reveals any files that are missing in
<filename>PLIST</filename>, add them.</para>
</listitem>
<listitem>
<para>Now that the <filename>PLIST</filename> is OK, install the
package again and make a binary package:</para>
<screen>&rprompt; <userinput>make reinstall</userinput>
&rprompt; <userinput>make package</userinput></screen>
</listitem>
<listitem>
<para>Delete the installed package:</para>
<screen>&rprompt; <userinput>pkg_delete <replaceable>examplepkg</replaceable></userinput></screen>
</listitem>
<listitem>
<para>Repeat the above <command>make print-PLIST</command>
command, which shouldn't find anything now:</para>
<screen>&rprompt; <userinput>make print-PLIST</userinput></screen>
</listitem>
<listitem>
<para>Reinstall the binary package:</para>
<screen>&rprompt; <userinput>pkg_add .../<replaceable>examplepkg</replaceable>.tgz</userinput></screen>
</listitem>
<listitem>
<para>Play with it. Make sure everything works.</para>
</listitem>
<listitem>
<para>Run <command>pkglint</command> from <filename
role="pkg">pkgtools/pkglint</filename>, and fix the problems it
reports:</para>
<screen>&rprompt; <userinput>pkglint</userinput></screen>
</listitem>
<listitem>
<para>Submit (or commit, if you have cvs access); see <xref
linkend="submit"/>.</para>
</listitem>
</itemizedlist>
</chapter>