cookutils view doc/receipts-v2.md @ rev 993

Tiny edits
author Paul Issott <paul@slitaz.org>
date Mon Oct 30 18:41:22 2017 +0000 (2017-10-30)
parents c13b693c75c8
children 0a44898b817d
line source
1 Brief info about SliTaz receipts v2
2 ===================================
4 Version 2 was developed as an extension of the receipts in order to facilitate
5 the maintenance of packages by small forces.
7 In order to switch to version 2, you must specify 'v2' in the first line of the
8 receipt:
10 ```bash
11 # SliTaz package receipt v2.
12 ```
14 You can write the single receipt v2 to compile, for example `attr` sources and
15 then make two packages: `attr` and `attr-dev` using compiled files. Next we will
16 call `attr` the *main package*, while `attr-dev` -- the *split package*.
18 You must specify all the names of *split packages* that must be created after
19 the compilation in the SPLIT variable. Example for our `attr` receipt:
21 ```bash
22 SPLIT="attr-dev"
23 ```
25 You must specify rules to generate each package inside the genpkg_rules().
26 Example for package `attr`:
28 ```bash
29 genpkg_rules() {
30 case $PACKAGE in
31 attr) copy @std ;;
32 attr-dev) copy @dev ;;
33 esac
34 }
35 ```
37 Here, in every rule you can:
39 * use the `copy()` function or other methods to copy specified files from
40 $install to $fs.
41 * define the DEPENDS variable for specified packages; you may omit this
42 definition, then it will mean the following:
43 * for the *main package*: it doesn't depend on any package;
44 * for the *split packages*: it depends exclusively on a *main package*.
45 Note, a receipt is the shell script with all its restrictions: there's no
46 difference if you define an empty DEPENDS variable or do not define it at all.
47 Here's the small trick: if you really want to define empty dependencies,
48 put single spaces between the quotes: `DEPENDS=" "`.
49 * define the two-in-one CAT variable for *split packages*. Variable format:
51 ```bash
52 CAT="category|addition"
53 ```
55 Where `category` is just the chosen category for the specified *split
56 package*. And `addition` you will find in the brackets at the end of a
57 short description of the specified *split package*. You may omit this
58 definition for the "dev" packages. In this case it will be implicitly
59 defined as:
61 ```bash
62 CAT="development|development files"
63 ```
64 * define some other variables, like COOKOPTS.
67 Long descriptions
68 -----------------
70 You may provide a `description.txt` for the *main package* and/or
71 `description.package-name.txt` for any of the *split packages*.
74 `post_install()` and friends
75 ----------------------------
77 You may define one of the following functions:
79 * `pre_install()`;
80 * `post_install()`;
81 * `pre_remove()`;
82 * `post_remove()`.
84 These functions may be defined for every one of *main* or *split packages*, so
85 you need to extend function names with underscores (`_`) and the package name.
86 Like this for the `cookutils` package:
88 post_install_cookutils()
90 Attention! You should know that some characters that are valid in package names
91 are not allowed in function names. Please, substitute each symbol that doesn't
92 belong to the intervals `A-Z, a-z, 0-9` by yet another underscore (`_`).
93 Example for `coreutils-disk`:
95 post_install_coreutils_disk()
98 Function `copy()`
99 -----------------
101 It's the flexible tool allowing you to copy files and folders from `$install` to
102 `$fs` using patterns. All files are copied with the folder structure preserved:
104 $install/my/folder/ -> $fs/my/folder/
105 $install/my/system/file -> $fs/my/system/file
107 Now `copy()` understands 4 main forms of patterns:
109 * `@std` - all the "standard" files;
110 * `@dev` - all the "developer" files;
111 * `folder/` - append folder name in question by slash;
112 * `file` - file name without the slash at the end.
114 Both patterns `@std` and `@dev` are meta-patterns making the most common actions
115 extremely simple. Here all files are divided into three types: standard,
116 development and all the others (documentation, translations, etc). You may put
117 `@std` into "standard" package, `@dev` into "developer" package, not packaging
118 any documentation, man pages, translations, BASH completion, etc...
120 In the `folder/` and `file` forms of the patterns you can use the asterisk (`*`)
121 symbol meaning any number of any characters.
123 Some examples (executed in the chroot with the "busybox" package installed):
125 Pattern | Result
126 -----------|--------------------------------------------------------------------
127 ` bin/ `|`/bin`<br>`/usr/bin`
128 ` *bin/ `|`/bin`<br>`/sbin`<br>`/usr/bin`<br>`/usr/sbin`<br>`/var/www/cgi-bin`
129 `/usr/bin/`|`/usr/bin`
130 ` usr/bin/`|`/usr/bin`
131 ` r/bin/`|` `
132 ` cat `|`/bin/cat`
133 ` *.sh `|`/lib/libtaz.sh`<br>`/sbin/mktazdevs.sh`<br>`/usr/bin/gettext.sh`<br>`/usr/bin/httpd_helper.sh`<br>`/usr/lib/slitaz/httphelper.sh`<br>`/usr/lib/slitaz/libpkg.sh`<br>`/var/www/cgi-bin/cgi-env.sh`
134 ` pt* `|`/dev/pts`<br>`/usr/share/locale/pt_BR`<br>`/usr/share/locale/pt_BR/LC_MESSAGES`
135 `/bin/*.sh`|`/usr/bin/gettext.sh`<br>`/usr/bin/httpd_helper.sh`
136 `/lib/*.sh`|`/lib/libtaz.sh`<br>`/usr/lib/slitaz/httphelper.sh`<br>`/usr/lib/slitaz/libpkg.sh`
138 Also, `copy()` understands the `@rm` pattern. It does not copy anything, but it
139 removes already copied files that have already been packed.
141 ### Some more examples of using `copy()`
143 If your packages are used only for development purposes (like automake, flex, vala
144 and some others), you may use the next command to put all the files you want
145 to pack into one package:
147 ```bash
148 copy @std @dev
149 ```
151 In most cases, the package breaks up into "main" and "dev" packages. In this
152 case, your code might look like this:
154 ```bash
155 PACKAGE="my-package"
156 SPLIT="my-package-dev"
158 genpkg_rules() {
159 case $PACKAGE in
160 my-package)
161 copy @std
162 DEPENDS="your-package"
163 ;;
164 *-dev)
165 copy @dev
166 ;;
167 esac
168 }
169 ```
171 In the following example, a package can contain libraries (which can be used by
172 other programs) and executables that use these libraries. We need to split
173 `@std` into two parts: libraries and executable files. This can be done in a few
174 ways.
176 ```bash
177 PACKAGE="my-pkg"
178 # We omit "my-pkg" in the $SPLIT, then it is implicit in the first place
179 SPLIT="my-pkg-bin my-pkg-dev"
180 genpkg_rules() {
181 case $PACKAGE in
182 my-pkg) copy *.so*;; # (1) copy all the libs
183 *-bin) copy bin/;; # (2) copy all the execs from /usr/bin/
184 *-dev) copy @dev;; # (3) copy development files
185 esac
186 }
187 ```
189 ```bash
190 # If a package contains some more files outside of the /bin/ (for example, configs),
191 # that we want to pack with the "bin" package:
192 PACKAGE="my-pkg"
193 SPLIT="my-pkg-bin my-pkg-dev"
194 genpkg_rules() {
195 case $PACKAGE in
196 my-pkg) copy *.so*;; # (1) copy all the libs
197 *-bin) copy @std @rm;; # (2) copy standard (binaries and configs, etc),
198 # then remove already packed (libs)
199 *-dev) copy @dev;; # (3) copy development files
200 esac
201 }
202 ```
204 ```bash
205 # Pack two different libraries into two packages, and the rest into a third
206 # package:
207 PACKAGE="my-pkg"
208 # We explicitly specify all the packages, therefore they will be processed
209 # in the specified order
210 SPLIT="my-pkg-lib1 my-pkg-lib2 my-pkg my-pkg-dev"
211 genpkg_rules() {
212 case $PACKAGE in
213 *-lib1) copy lib-cli.so*;; # (1) copy first libraries
214 *-lib2) copy lib-gui.so*;; # (2) copy second libraries
215 my-pkg) copy @std @rm;; # (3) copy all the standard files,
216 # then remove already packed (libs)
217 *-dev) copy @dev;; # (4) copy development files
218 esac
219 }
220 ```