summaryrefslogtreecommitdiff
path: root/doc/guide/files/debug.xml
blob: 2e0611f7682d906a06cb872243db73447007ea6d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<!-- $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>