website view en/doc/cookbook/receipts.html @ rev 562
cn:update and fix some bugs
author | Chen Yufei <tsjz@ymail.com> |
---|---|
date | Sat Nov 07 12:58:44 2009 +0800 (2009-11-07) |
parents | 489aa5f8f2f0 |
children | 0e0bc81a63ee |
line source
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4 <head>
5 <title>SliTaz Cookbook (en) - Receipts</title>
6 <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
7 <meta name="description" content="slitaz English cookbook" />
8 <meta name="expires" content="never" />
9 <meta name="modified" content="2008-07-16 21:45:00" />
10 <meta name="publisher" content="www.slitaz.org" />
11 <meta name="author" content="Christophe Lincoln"/>
12 <link rel="shortcut icon" href="favicon.ico" />
13 <link rel="stylesheet" type="text/css" href="book.css" />
14 </head>
15 <body bgcolor="#ffffff">
17 <!-- Header and quick navigation -->
18 <div id="header">
19 <div align="right" id="quicknav">
20 <a name="top"></a>
21 <a href="build-host.html">Build Host</a> |
22 <a href="index.html">Table of contents</a>
23 </div>
24 <h1><font color="#3E1220">SliTaz Cookbook (en)</font></h1>
25 </div>
27 <!-- Content. -->
28 <div id="content">
29 <div class="content-right"></div>
32 <h2><font color="#df8f06">Receipts</font></h2>
34 <p>
35 This document describes the opportunities offered by the receipt used by
36 Tazwok to compile and generate packages for SliTaz and Tazpkg through
37 <a href="wok-tools.html">The wok and tools</a>. The receipt for a package is
38 also used by Tazpkg to install/uninstall and provide information about a
39 .tazpkg package. Each receipt begins with a comment in English:
40 </p>
41 <pre class="script">
42 # SliTaz package receipt.
43 </pre>
45 <h3>Variables</h3>
46 <p>
47 The first 5 variables should always be present and defined. They respectively
48 configure the package ($PACKAGE), its version, its category, provide a short
49 description and the name of the maintainer. Example for the package, file
50 manager Clex:
51 </p>
52 <pre class="script">
53 PACKAGE="clex"
54 VERSION="3.16"
55 CATEGORY="base-apps"
56 SHORT_DESC="Text mode file manager."
57 MAINTAINER="pankso@slitaz.org"
58 </pre>
60 <h3>Variables (optional)</h3>
61 <p>
62 Tazwok also knows how to use various optional variables. It can, for example,
63 use the name of another source package. There are also variables that are
64 used by Tazpkg to manage dependencies or provide information about the package.
65 </p>
66 <p>
67 <a name="depends"></a>
68 <code>$DEPENDS</code>: Set dependencies, there may be several dependencies
69 seperated by a space or on several lines. This variable is used mainly by
70 Tazpkg when installing the package and Tazwok to build large packages such
71 as Xorg. Example for Clex which depends on ncurses:
72 </p>
73 <pre class="script">
74 DEPENDS="ncurses"
75 </pre>
76 <p>
77 <a name="build_depends"></a>
78 <code>$BUILD_DEPENDS</code>: Set compilation dependencies, again seperated
79 by a space or several lines. This variable is used by Tazwok during the
80 cooking of a package. Example:
81 </p>
82 <pre class="script">
83 BUILD_DEPENDS="ncurses-dev"
84 </pre>
85 <p>
86 <a name="tarball"></a>
87 <code>$TARBALL</code> : The archive is a source with the extension (tar.gz,
88 tgz or tar.bz2). In general, the variables $PACKAGE and $VERSION are used to
89 just change the extension, it helps to upgrade the package without changing
90 the $VERSION variable. Generic example (see also $SOURCE example):
91 </p>
92 <pre class="script">
93 TARBALL="$PACKAGE-$VERSION.tar.gz"
94 </pre>
95 <p>
96 <a name="web_site"></a>
97 <code>$WEB_SITE</code> : The official website of the package. It may be that
98 some libraries have no website, in this case, there is no need to specify a
99 URL. Note Tazwok and Tazpkg both expect to find a URL with the complete HTTP:
100 </p>
101 <pre class="script">
102 WEB_SITE="http://www.clex.sk/"
103 </pre>
104 <p>
105 <a name="wget_url"></a>
106 <code>$WGET_URL</code> : URL to download the source file. In general the
107 variable $TARBALL should be used to facilitate the updating of the package
108 without changing the $VERSION. Using a configuration file, Tazwok also
109 configures by default 3 mirrors: $GNU_MIRROR for the GNU mirror, $SF_MIRROR
110 for SourceForge and XORG_MIRROR for mirroring the graphical server Xorg.
111 Example for Clex:
112 </p>
113 <pre class="script">
114 WGET_URL="http://www.clex.sk/download/$TARBALL"
115 </pre>
116 <p>
117 <a name="config_files"></a>
118 <code>$CONFIG_FILES</code> : Some packages provide customized
119 configuration files. The $CONFIG_FILES variable provides a list of these
120 files that can be saved by the 'tazpkg repack-config' command.
121 These files are not overwritten when reinstalling the package if they already
122 exist and the package can be successfully recreated with 'tazpkg repack',
123 (even if they have been modified since). Netatalk for example:
124 </p>
125 <pre class="script"> CONFIG_FILES="/etc/netatalk/AppleVolumes.* /etc/netatalk/*.conf"
126 </pre>
127 <p>
128 <a name="suggested"></a>
129 <code>$SUGGESTED</code> : Lists useful packages without being essential.
130 Also used to activate optional features.
131 </p>
132 <p>
133 <a name="wanted"></a>
134 <code>$WANTED</code> : SliTaz packages normally depend on the compilation of
135 a source package. Sometimes the receipt of a package requires no compilation
136 of rules, then $WANTED is used to copy files from the source of another
137 package by using the variable $ src.
138 </p>
139 <p>
140 <a name="source"></a>
141 <code>$SOURCE</code> : It may be that the Tazpkg package name differs from
142 the name of the source package. Example for Xorg packages, the name of Tazpkg
143 library X11 is 'xorg-libX11' and the name of the package source is libX11.
144 $SOURCE allows you to use the variables $src and $_pkg during the cooking of
145 a package. It should be noted that in the case of libX11, the name of the
146 source archive becomes $SOURCE-$VERSION.tar.gz.
147 </p>
148 <p>
149 <a name="provide"></a>
150 <code>$PROVIDE</code> : Some packages offer the same functionality, for
151 instance the web server was at first lighttpd; now apache is available.
152 All packages dependent on a web server refer to lighttpd.
153 The <code>$PROVIDE="apache"</code> variable in the apache receipt says
154 that packages dependent on lighttpd do not need to install the lighttpd
155 package if apache is already on the system. Some packages may vary according
156 to the webserver you choose, ie. the php package is dependent on lighttpd,
157 as is php-apache on apache. The <code>PROVIDE="php:apache"</code> in the
158 apache receipt says that you must install php-apache instead of php, if
159 apache is already on the system. Therefore each package dependent on php
160 will install either php-apache or php according to the webserver on the
161 system. This variable also chooses packages compiled with different options.
162 The <code>PROVIDE="epdfview:cups"</code> in the epdfview-cups receipt allows
163 you to install epdfview with printer support via cups if cups is already on
164 the system.
165 </p>
166 <p>
167 You can also define virtual packages with this variable.
168 The lines <code>PROVIDE="libgl"</code> in the mesa package and
169 <code>PROVIDE="libgl:nvidia"</code> in the nvidia-glx package, define that
170 libgl is an optimized version when the nvidia package is installed.
171 </p>
172 <p>
173 <a name="self_install"></a>
174 <code>$SELF_INSTALL</code> : Certain packages use commands provided by
175 the package itself in the post_install function. To install this package
176 into a directory other than root and still be able to use these commands,
177 the package must have been installed in / in earlier stages. The line:
178 <code>SELF_INSTALL=1</code> alerts tazpkg to this feature.
179 </p>
181 <h3>Variables automatically generated by Tazwok</h3>
182 <p>
183 Certain factors are known only during the cooking of
184 a package or after the package has been cooked. Tazwok
185 will add them to the receipt automatically.
186 </p>
187 <p>
188 <a name="packed_size"></a>
189 <code>$PACKED_SIZE</code> : Tazpkg file size.
190 </p>
191 <p>
192 <a name="unpacked_size"></a>
193 <code>$UNPACKED_SIZE</code> : Space taken up by the package after
194 installation.
195 </p>
196 <p>
197 <a name="extraversion"></a>
198 <code>$EXTRAVERSION</code> : Some packages have 2 different versions.
199 This is in case of modules added to the Linux kernel, such as squashfs,
200 because the module depends on the version of the kernel with which it was
201 compiled. In this case $EXTRAVERSION contains the kernel version and Tazwok
202 determines the module from the contents of /lib/modules.
203 </p>
205 <h3>Variables used in functions</h3>
206 <p>
207 Tazwok configures several variables that facilitate the compilation and
208 construction of Tazpkg packages. These variables are controlled automatically
209 by Tazwok using the information contained in the receipt; they can be used
210 by the functions compile_rules and genpkg_rules described in the chapter
211 Functions.
212 </p>
213 <p>
214 <a name="src"></a>
215 <code>$src</code> : Defines the path to the directory of unarchived sources.
216 </p>
217 <p>
218 <a name="pkg"></a>
219 <code>$_pkg</code> : Defines the path to the compiled binaries installed via
220 'make DESTDIR=$PWD/_pkg install'. This variable is used to copy the generated
221 files and create Tazpkg packages.
222 </p>
223 <p>
224 <a name="fs"></a>
225 <code>$fs</code> : Defines the path to the pseudo filesystem (fs) in each
226 package. The 'fs' of the package corresponds to the root of the system, a bit
227 like Clex will for example be in $fs/usr/bin/clex. Note the need to create the
228 necessary directories via function genpkg_rules() before copying the files.
229 </p>
230 <p>
231 <a name="configure_args"></a>
232 <code>$CONFIGURE_ARGS</code> : This variable is defined in the Tazwok
233 configuration file (tazwok.conf). It allows you to specify generic optimization
234 arguments during construction of a package. Default is the i486 architecture.
235 </p>
237 <h3>Functions</h3>
238 <p>
239 A receipt may contain 4 functions. Tazwok knows how to deal with functions
240 containing compilation rules (compile_rules) and rules used to generate a
241 package (genpkg_rules). These functions may contain all sorts of GNU/Linux
242 standard commands, such as sed, awk, patch and variables automatically
243 configured.
244 </p>
245 <a name="compile_rules"></a>
246 <h4>compile_rules()</h4>
247 <p>
248 To compile a package you can use the variable $src to move (cd) in the
249 directory of sources and use $CONFIGURE_ARGS to include arguments from the
250 Tazwok configuration file. To build the package you usually launch 'make'
251 without any arguments, and to install the package into the directory _pkg,
252 it is necessary to use the command 'make DESTDIR=$PWD/_pkg install'. Generic
253 example:
254 </p>
255 <pre class="script">
256 # Rules to configure and make the package.
257 compile_rules()
258 {
259 cd $src
260 ./configure --prefix=/usr --infodir=/usr/share/info \
261 --mandir=/usr/share/man $CONFIGURE_ARGS
262 make
263 make DESTDIR=$PWD/_pkg install
264 }
265 </pre>
266 <a name="genpkg_rules"></a>
267 <h4>genpkg_rules()</h4>
268 <p>
269 To generate a tazkg package we must specify commands in the function
270 <code>genpkg_rules</code>. In this example we create a psuedo directory
271 <code>usr/</code> in the filesystem of the package, copy the whole
272 binary(s) and finally use strip to clean the files:
273 </p>
274 <pre class="script">
275 # Rules to gen a SliTaz package suitable for Tazpkg.
276 genpkg_rules()
277 {
278 mkdir -p $fs/usr
279 cp -a $_pkg/usr/bin $fs/usr
280 strip -s $fs/usr/bin/*
281 }
282 </pre>
283 <a name="pre_install"></a>
284 <h4>pre_install() and post_install()</h4>
285 <p>
286 These 2 functions are initiated by Tazpkg when installing the package. They
287 must be defined before generating the .tazpkg package with Tazwok. If no rules
288 are given for these functions, they have no raison d'etre and can be removed.
289 Example using echo to display some text (no function should be empty):
290 </p>
291 <pre class="script">
292 # Pre and post install commands for Tazpkg.
293 pre_install()
294 {
295 echo "Processing pre-install commands..."
296 }
297 post_install()
298 {
299 echo "Processing post-install commands..."
300 }
301 </pre>
302 <a name="clean_wok"></a>
303 <h4>clean_wok()</h4>
304 <p>
305 This function helps to define additional commands to be run when cleaning the wok,
306 it is useful to delete files or directories that are not supported by Tazwok.
307 </p>
308 <pre class="script"># clean commands for Tazwok.
309 clean_wok()
310 {
311 rm -rf $WOK/$PACKAGE/vim71
312 }
313 </pre>
315 <!-- End of content -->
316 </div>
318 <!-- Footer. -->
319 <div id="footer">
320 <div class="footer-right"></div>
321 <a href="receipts.html#top">Top of the page</a> |
322 <a href="index.html">Table of contents</a>
323 </div>
325 <div id="copy">
326 Copyright © 2008 <a href="http://www.slitaz.org/en/">SliTaz</a> -
327 <a href="http://www.gnu.org/licenses/gpl.html">GNU General Public License</a>;<br />
328 Documentation is under
329 <a href="http://www.gnu.org/copyleft/fdl.html">GNU Free Documentation License</a>
330 and code is <a href="http://validator.w3.org/">valid xHTML 1.0</a>.
331 </div>
333 </body>
334 </html>