Tue Jul 15 23:41:55 2014 UTC ()
Document pbulk setup using pbulk.sh


(asau)
diff -r1.13 -r1.14 pkgsrc/doc/guide/files/bulk.xml

cvs diff -r1.13 -r1.14 pkgsrc/doc/guide/files/bulk.xml (switch to unified diff)

--- pkgsrc/doc/guide/files/bulk.xml 2014/05/31 20:49:16 1.13
+++ pkgsrc/doc/guide/files/bulk.xml 2014/07/15 23:41:55 1.14
@@ -1,190 +1,249 @@ @@ -1,190 +1,249 @@
1<!-- $NetBSD: bulk.xml,v 1.13 2014/05/31 20:49:16 asau Exp $ --> 1<!-- $NetBSD: bulk.xml,v 1.14 2014/07/15 23:41:55 asau Exp $ -->
2 2
3<chapter id="bulk"> 3<chapter id="bulk">
4<title>Creating binary packages for everything in pkgsrc (bulk 4<title>Creating binary packages for everything in pkgsrc (bulk
5builds)</title> 5builds)</title>
6 6
7<para>When you have multiple machines that should run the same packages, 7<para>When you have multiple machines that should run the same packages,
8it is wasted time if they all build their packages themselves from 8it is wasted time if they all build their packages themselves from
9source. There is a ways of getting a set of binary packages: 9source. There is a ways of getting a set of binary packages:
10The bulk build system, or pbulk ("p" stands for "parallel). 10The bulk build system, or pbulk ("p" stands for "parallel).
11This chapter describes how to set it up so that the packages 11This chapter describes how to set it up so that the packages
12are most likely to be usable later.</para> 12are most likely to be usable later.</para>
13 13
14<sect1 id="bulk.pre"> 14<sect1 id="bulk.pre">
15<title>Think first, build later</title> 15<title>Think first, build later</title>
16 16
17<para>Since a bulk build takes several days or even weeks to finish, you 17<para>Since a bulk build takes several days or even weeks to finish, you
18should think about the setup before you start everything. Pay attention 18should think about the setup before you start everything. Pay attention
19to at least the following points:</para> 19to at least the following points:</para>
20 20
21<itemizedlist> 21<itemizedlist>
22 22
23<listitem><para>If you want to upload the binary packages to 23<listitem><para>If you want to upload the binary packages to
24ftp.NetBSD.org, make sure the setup complies to the requirements for binary 24ftp.NetBSD.org, make sure the setup complies to the requirements for binary
25packages:</para> 25packages:</para>
26 26
27<itemizedlist> 27<itemizedlist>
28 28
29<listitem><para>To end up on ftp.NetBSD.org, the packages must be built 29<listitem><para>To end up on ftp.NetBSD.org, the packages must be built
30by a NetBSD developer on a trusted machine (that is, where you and only 30by a NetBSD developer on a trusted machine (that is, where you and only
31you have root access).</para></listitem> 31you have root access).</para></listitem>
32 32
33<listitem><para>Packages on ftp.NetBSD.org should only be created from 33<listitem><para>Packages on ftp.NetBSD.org should only be created from
34the stable branches (like 2009Q1), so that users browsing the available 34the stable branches (like 2009Q1), so that users browsing the available
35collections can see at a glance how old the packages 35collections can see at a glance how old the packages
36are.</para></listitem> 36are.</para></listitem>
37 37
38<listitem><para>The packages must be built as root, since some packages 38<listitem><para>The packages must be built as root, since some packages
39require set-uid binaries at runtime, and creating those packages as 39require set-uid binaries at runtime, and creating those packages as
40unprivileged user doesn't work well at the moment.</para></listitem> 40unprivileged user doesn't work well at the moment.</para></listitem>
41 41
42</itemizedlist> 42</itemizedlist>
43</listitem> 43</listitem>
44 44
45<listitem><para>Make sure that the bulk build cannot break anything in 45<listitem><para>Make sure that the bulk build cannot break anything in
46your system. Most bulk builds run as root, so they should be run at least 46your system. Most bulk builds run as root, so they should be run at least
47in a chroot environment or something even more restrictive, depending on 47in a chroot environment or something even more restrictive, depending on
48what the operating system provides. There have been numerous cases where 48what the operating system provides. There have been numerous cases where
49certain packages tried to install files outside the 49certain packages tried to install files outside the
50<filename>LOCALBASE</filename> or wanted to edit some files in 50<filename>LOCALBASE</filename> or wanted to edit some files in
51<filename>/etc</filename>. Furthermore, the bulk builds install and 51<filename>/etc</filename>. Furthermore, the bulk builds install and
52deinstall packages in <filename>/usr/pkg</filename> (or whatever 52deinstall packages in <filename>/usr/pkg</filename> (or whatever
53<filename>LOCALBASE</filename> is) during their operation, so be sure 53<filename>LOCALBASE</filename> is) during their operation, so be sure
54that you don't need any package during the build.</para></listitem> 54that you don't need any package during the build.</para></listitem>
55 55
56</itemizedlist> 56</itemizedlist>
57</sect1> 57</sect1>
58 58
59<sect1 id="bulk.req"> 59<sect1 id="bulk.req">
60<title>Requirements of a bulk build</title> 60<title>Requirements of a bulk build</title>
61 61
62<para>A complete bulk build requires lots of disk space. Some of the 62<para>A complete bulk build requires lots of disk space. Some of the
63disk space can be read-only, some other must be writable. Some can be on 63disk space can be read-only, some other must be writable. Some can be on
64remote filesystems (such as NFS) and some should be local. Some can be 64remote filesystems (such as NFS) and some should be local. Some can be
65temporary filesystems, others must survive a sudden reboot.</para> 65temporary filesystems, others must survive a sudden reboot.</para>
66 66
67<itemizedlist> 67<itemizedlist>
68 68
69<listitem><para>40 GB for the distfiles (read-write, remote, temporary)</para></listitem> 69<listitem><para>40 GB for the distfiles (read-write, remote, temporary)</para></listitem>
70 70
71<listitem><para>30 GB for the binary packages (read-write, remote, permanent)</para></listitem> 71<listitem><para>30 GB for the binary packages (read-write, remote, permanent)</para></listitem>
72 72
73<listitem><para>1 GB for the pkgsrc tree (read-only, remote, permanent)</para></listitem> 73<listitem><para>1 GB for the pkgsrc tree (read-only, remote, permanent)</para></listitem>
74 74
75<listitem><para>5 GB for <filename>LOCALBASE</filename> (read-write, local, temporary for pbulk, permanent for old-bulk)</para></listitem> 75<listitem><para>5 GB for <filename>LOCALBASE</filename> (read-write, local, temporary for pbulk, permanent for old-bulk)</para></listitem>
76 76
77<listitem><para>10 GB for the log files (read-write, remote, permanent)</para></listitem> 77<listitem><para>10 GB for the log files (read-write, remote, permanent)</para></listitem>
78 78
79<listitem><para>5 GB for temporary files (read-write, local, temporary)</para></listitem> 79<listitem><para>5 GB for temporary files (read-write, local, temporary)</para></listitem>
80 80
81</itemizedlist> 81</itemizedlist>
82 82
83</sect1> 83</sect1>
84 84
85<sect1 id="bulk.pbulk"> 85<sect1 id="bulk.pbulk">
86<title>Running a pbulk-style bulk build</title> 86<title>Running a pbulk-style bulk build</title>
87 87
88<para>Running a pbulk-style bulk build works roughly as follows:</para> 88<para>Running a pbulk-style bulk build works roughly as follows:</para>
89 89
90<itemizedlist> 90<itemizedlist>
91<listitem><para>First, build the pbulk infrastructure in a fresh pkgsrc location.</para></listitem> 91<listitem><para>First, build the pbulk infrastructure in a fresh pkgsrc location.</para></listitem>
92<listitem><para>Then, build each of the packages from a clean installation directory using the infrastructure.</para></listitem> 92<listitem><para>Then, build each of the packages from a clean installation directory using the infrastructure.</para></listitem>
93</itemizedlist> 93</itemizedlist>
94 94
95<sect2 id="bulk.pbulk.prepare"> 95<sect2 id="bulk.pbulk.prepare">
96<title>Preparation</title> 96<title>Preparation</title>
97 97
98<para>First, you need to create a pkgsrc installation for the pbulk infrastructure. No matter on which platform you are (even on NetBSD), you should bootstrap into its own directory. Let's take the directory <filename>/usr/pbulk</filename> or <filename>$HOME/pbulk</filename> for it. This installation will be bootstrapped and all the tools that are required for the bulk build will be installed there.</para> 98<para>First, you need to create a pkgsrc installation for the pbulk infrastructure. No matter on which platform you are (even on NetBSD), you should bootstrap into its own directory. Let's take the directory <filename>/usr/pbulk</filename> or <filename>$HOME/pbulk</filename> for it. This installation will be bootstrapped and all the tools that are required for the bulk build will be installed there.</para>
99 99
100<screen> 100<screen>
101$ <userinput>cd /usr/pkgsrc</userinput> 101$ <userinput>cd /usr/pkgsrc</userinput>
102$ <userinput>./bootstrap/bootstrap --prefix=/usr/pbulk --varbase=/usr/pbulk/var --workdir=/tmp/pbulk-bootstrap</userinput> 102$ <userinput>./bootstrap/bootstrap --prefix=/usr/pbulk --varbase=/usr/pbulk/var --workdir=/tmp/pbulk-bootstrap</userinput>
103$ <userinput>rm -rf /tmp/pbulk-bootstrap</userinput> 103$ <userinput>rm -rf /tmp/pbulk-bootstrap</userinput>
104</screen> 104</screen>
105 105
106<para>Now the basic environment for the pbulk infrastructure is installed. The specific tools are still missing. This is a good time to edit the pkgsrc configuration file <filename>/usr/pbulk/etc/mk.conf</filename> to fit your needs. Typical things you might set now are:</para> 106<para>Now the basic environment for the pbulk infrastructure is installed. The specific tools are still missing. This is a good time to edit the pkgsrc configuration file <filename>/usr/pbulk/etc/mk.conf</filename> to fit your needs. Typical things you might set now are:</para>
107 107
108<itemizedlist> 108<itemizedlist>
109<listitem><para><literal><varname>PKG_DEVELOPER</varname>=yes</literal>, to enable many consistency checks,</para></listitem> 109<listitem><para><literal><varname>PKG_DEVELOPER</varname>=yes</literal>, to enable many consistency checks,</para></listitem>
110<listitem><para><literal><varname>WRKOBJDIR</varname>=/tmp/pbulk-outer</literal>, to keep <filename>/usr/pkgsrc</filename> free from any modifications,</para></listitem> 110<listitem><para><literal><varname>WRKOBJDIR</varname>=/tmp/pbulk-outer</literal>, to keep <filename>/usr/pkgsrc</filename> free from any modifications,</para></listitem>
111<listitem><para><literal><varname>DISTDIR</varname>=/distfiles</literal>, to have only one directory in which all distfiles (for the infrastructure and for the actual packages) are downloaded,</para></listitem> 111<listitem><para><literal><varname>DISTDIR</varname>=/distfiles</literal>, to have only one directory in which all distfiles (for the infrastructure and for the actual packages) are downloaded,</para></listitem>
112<listitem><para><literal><varname>ACCEPTABLE_LICENSES</varname>+=...</literal>, to select some licenses additional to the usual Free/Open Source licenses that are acceptable to you,</para></listitem> 112<listitem><para><literal><varname>ACCEPTABLE_LICENSES</varname>+=...</literal>, to select some licenses additional to the usual Free/Open Source licenses that are acceptable to you,</para></listitem>
113<listitem><para><literal><varname>SKIP_LICENSE_CHECK</varname>=yes</literal>, to bypass the license checks.</para></listitem> 113<listitem><para><literal><varname>SKIP_LICENSE_CHECK</varname>=yes</literal>, to bypass the license checks.</para></listitem>
114</itemizedlist> 114</itemizedlist>
115 115
116<para>Now you are ready to build the rest of the pbulk infrastructure.</para> 116<para>Now you are ready to build the rest of the pbulk infrastructure.</para>
117 117
118<screen> 118<screen>
119$ <userinput>cd pkgtools/pbulk</userinput> 119$ <userinput>cd pkgtools/pbulk</userinput>
120$ <userinput>/usr/pbulk/bin/bmake install</userinput> 120$ <userinput>/usr/pbulk/bin/bmake install</userinput>
121$ <userinput>rm -rf /tmp/pbulk-outer</userinput> 121$ <userinput>rm -rf /tmp/pbulk-outer</userinput>
122</screen> 122</screen>
123 123
124<para>Now the pbulk infrastructure is built and installed. It still needs to be configured, and after some more preparation, we will be able to start the real bulk build.</para> 124<para>Now the pbulk infrastructure is built and installed. It still needs to be configured, and after some more preparation, we will be able to start the real bulk build.</para>
125</sect2> 125</sect2>
126 126
127<sect2 id="bulk.pbulk.conf"> 127<sect2 id="bulk.pbulk.conf">
128<title>Configuration</title> 128<title>Configuration</title>
129 129
130<para>TODO; see pkgsrc/doc/HOWTO-pbulk for more information.</para> 130<para>To simplify configuration we provide helper script <filename>mk/pbulk/pbulk.sh</filename>.</para>
131 131
132<para>TODO: continue writing</para> 132<para>In order to use it, prepare a clear system (real one, chroot environment, jail, zone, virtual machine).
 133Configure network access to fetch distribution files.
 134Create user with name "pbulk".</para>
 135
 136<para>Fetch and extract pkgsrc. Use a command like one of these:</para>
 137
 138<screen>
 139&rprompt; <userinput>(cd /usr &amp;&amp; ftp -o - http://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc.tar.gz | tar -zxf-)</userinput>
 140&rprompt; <userinput>(cd /usr &amp;&amp; fetch -o - http://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc.tar.gz | tar -zxf-)</userinput>
 141&rprompt; <userinput>(cd /usr &amp;&amp; cvs -Q -z3 -d anoncvs@anoncvs.netbsd.org:/cvsroot get -P pkgsrc)</userinput>
 142</screen>
 143
 144<para>Or any other way that fits (e.g., curl, wget).</para>
 145
 146<para>Deploy and configure pbulk tools, e.g.:</para>
 147
 148<screen>
 149&rprompt; <userinput>sh pbulk.sh -n # native (NetBSD)</userinput>
 150&rprompt; <userinput>sh pbulk.sh -n -c mk.conf.frag # native, apply settings from given mk.conf fragment</userinput>
 151&rprompt; <userinput>sh pbulk.sh -nlc mk.conf.frag # native, apply settings, configure for limited build</userinput>
 152</screen>
 153
 154<note><para><filename>mk.conf.frag</filename> is a fragment of
 155<filename>mk.conf</filename> that contains settings you want to
 156apply to packages you build. For instance,</para>
 157
 158<programlisting>
 159PKG_DEVELOPER= yes # perform more checks
 160X11_TYPE= modular # use pkgsrc X11
 161SKIP_LICENSE_CHECK= yes # accept all licences (useful when building all packages)
 162</programlisting>
 163</note>
 164
 165<para>If configured for limited list, replace the list in <filename>/usr/pbulk/etc/pbulk.list</filename>
 166with your list of packages one per line without empty lines or comments. E.g.:</para>
 167
 168<programlisting>
 169www/firefox
 170mail/thunderbird
 171misc/libreoffice4
 172</programlisting>
 173
 174<para>Start it:</para>
 175
 176<screen>
 177&rprompt; <userinput>/usr/pbulk/bin/bulkbuild</userinput>
 178</screen>
 179
 180<para>After it finishes, you'll have <filename>/mnt</filename> filled with distribution files, binary packages, and reports,
 181plain text summary in <filename>/mnt/bulklog/meta/report.txt</filename>
 182</para>
 183
 184<note><para>The <filename>pbulk.sh</filename> script does not cover all possible use cases.
 185While being ready to run, it serves as a good starting point to understand and build more complex setups.
 186The script is kept small enough for better understanding.</para>
 187</note>
 188
 189<note><para>The <filename>pbulk.sh</filename> script supports running
 190unprivileged bulk build and helps configuring distributed bulk builds.</para>
 191</note>
133 192
134</sect2> 193</sect2>
135 194
136</sect1> 195</sect1>
137 196
138 <sect1 id="creating-cdroms"> 197 <sect1 id="creating-cdroms">
139 <title>Creating a multiple CD-ROM packages collection</title> 198 <title>Creating a multiple CD-ROM packages collection</title>
140 199
141 <para>After your pkgsrc bulk-build has completed, you may wish to 200 <para>After your pkgsrc bulk-build has completed, you may wish to
142 create a CD-ROM set of the resulting binary packages to assist 201 create a CD-ROM set of the resulting binary packages to assist
143 in installing packages on other machines. The 202 in installing packages on other machines. The
144 <filename role="pkg">pkgtools/cdpack</filename> package provides 203 <filename role="pkg">pkgtools/cdpack</filename> package provides
145 a simple tool for creating the ISO 9660 images. 204 a simple tool for creating the ISO 9660 images.
146 <command>cdpack</command> arranges the packages on the CD-ROMs in a 205 <command>cdpack</command> arranges the packages on the CD-ROMs in a
147 way that keeps all the dependencies for a given package on the same 206 way that keeps all the dependencies for a given package on the same
148 CD as that package.</para> 207 CD as that package.</para>
149 208
150 <sect2 id="cdpack-example"> 209 <sect2 id="cdpack-example">
151 <title>Example of cdpack</title> 210 <title>Example of cdpack</title>
152 211
153 <para>Complete documentation for cdpack is found in the cdpack(1) 212 <para>Complete documentation for cdpack is found in the cdpack(1)
154 man page. The following short example assumes that the binary 213 man page. The following short example assumes that the binary
155 packages are left in 214 packages are left in
156 <filename>/usr/pkgsrc/packages/All</filename> and that 215 <filename>/usr/pkgsrc/packages/All</filename> and that
157 sufficient disk space exists in <filename>/u2</filename> to 216 sufficient disk space exists in <filename>/u2</filename> to
158 hold the ISO 9660 images.</para> 217 hold the ISO 9660 images.</para>
159 218
160 <screen> 219 <screen>
161&rprompt; <userinput>mkdir /u2/images</userinput> 220&rprompt; <userinput>mkdir /u2/images</userinput>
162&rprompt; <userinput>pkg_add /usr/pkgsrc/packages/All/cdpack</userinput> 221&rprompt; <userinput>pkg_add /usr/pkgsrc/packages/All/cdpack</userinput>
163&rprompt; <userinput>cdpack /usr/pkgsrc/packages/All /u2/images</userinput> 222&rprompt; <userinput>cdpack /usr/pkgsrc/packages/All /u2/images</userinput>
164 </screen> 223 </screen>
165 224
166 <para>If you wish to include a common set of files 225 <para>If you wish to include a common set of files
167 (<filename>COPYRIGHT</filename>, <filename>README</filename>, 226 (<filename>COPYRIGHT</filename>, <filename>README</filename>,
168 etc.) on each CD in the collection, then you need to create a 227 etc.) on each CD in the collection, then you need to create a
169 directory which contains these files. e.g.</para> 228 directory which contains these files. e.g.</para>
170 229
171 <screen> 230 <screen>
172&rprompt; <userinput>mkdir /tmp/common</userinput> 231&rprompt; <userinput>mkdir /tmp/common</userinput>
173&rprompt; <userinput>echo "This is a README" &gt; /tmp/common/README</userinput> 232&rprompt; <userinput>echo "This is a README" &gt; /tmp/common/README</userinput>
174&rprompt; <userinput>echo "Another file" &gt; /tmp/common/COPYING</userinput> 233&rprompt; <userinput>echo "Another file" &gt; /tmp/common/COPYING</userinput>
175&rprompt; <userinput>mkdir /tmp/common/bin</userinput> 234&rprompt; <userinput>mkdir /tmp/common/bin</userinput>
176&rprompt; <userinput>echo "#!/bin/sh" &gt; /tmp/common/bin/myscript</userinput> 235&rprompt; <userinput>echo "#!/bin/sh" &gt; /tmp/common/bin/myscript</userinput>
177&rprompt; <userinput>echo "echo Hello world" &gt;&gt; /tmp/common/bin/myscript</userinput> 236&rprompt; <userinput>echo "echo Hello world" &gt;&gt; /tmp/common/bin/myscript</userinput>
178&rprompt; <userinput>chmod 755 /tmp/common/bin/myscript</userinput> 237&rprompt; <userinput>chmod 755 /tmp/common/bin/myscript</userinput>
179 </screen> 238 </screen>
180 239
181 <para>Now create the images:</para> 240 <para>Now create the images:</para>
182 241
183 <screen>&rprompt; <userinput>cdpack -x /tmp/common /usr/pkgsrc/packages/All /u2/images</userinput></screen> 242 <screen>&rprompt; <userinput>cdpack -x /tmp/common /usr/pkgsrc/packages/All /u2/images</userinput></screen>
184 243
185 <para>Each image will contain <filename>README</filename>, 244 <para>Each image will contain <filename>README</filename>,
186 <filename>COPYING</filename>, and <filename>bin/myscript</filename> 245 <filename>COPYING</filename>, and <filename>bin/myscript</filename>
187 in their root directories.</para> 246 in their root directories.</para>
188 </sect2> 247 </sect2>
189 </sect1> 248 </sect1>
190</chapter> 249</chapter>