]>
Commit | Line | Data |
---|---|---|
5e84b8b7 | 1 | // -*- mode:doc; -*- |
3edb0271 | 2 | // vim: set syntax=asciidoc: |
5e84b8b7 | 3 | |
86a415df | 4 | === Package directory |
41c1cb44 TP |
5 | |
6 | First of all, create a directory under the +package+ directory for | |
7 | your software, for example +libfoo+. | |
8 | ||
9 | Some packages have been grouped by topic in a sub-directory: | |
813016df | 10 | +x11r7+, +qt5+ and +gstreamer+. If your package fits in |
41c1cb44 | 11 | one of these categories, then create your package directory in these. |
65f66c17 | 12 | New subdirectories are discouraged, however. |
41c1cb44 | 13 | |
1b3ac72d | 14 | === Config files |
22937a37 | 15 | |
1b3ac72d JH |
16 | For the package to be displayed in the configuration tool, you need to |
17 | create a Config file in your package directory. There are two types: | |
18 | +Config.in+ and +Config.in.host+. | |
41c1cb44 | 19 | |
1b3ac72d JH |
20 | ==== +Config.in+ file |
21 | ||
22 | For packages used on the target, create a file named +Config.in+. This | |
23 | file will contain the option descriptions related to our +libfoo+ software | |
24 | that will be used and displayed in the configuration tool. It should basically | |
25 | contain: | |
41c1cb44 TP |
26 | |
27 | --------------------------- | |
28 | config BR2_PACKAGE_LIBFOO | |
29 | bool "libfoo" | |
30 | help | |
ad35a3a4 RM |
31 | This is a comment that explains what libfoo is. The help text |
32 | should be wrapped. | |
41c1cb44 TP |
33 | |
34 | http://foosoftware.org/libfoo/ | |
35 | --------------------------- | |
36 | ||
0fed833c | 37 | The +bool+ line, +help+ line and other metadata information about the |
d031a031 | 38 | configuration option must be indented with one tab. The help text |
5284dcf7 | 39 | itself should be indented with one tab and two spaces, lines should |
ad35a3a4 RM |
40 | be wrapped to fit 72 columns, where tab counts for 8, so 62 characters |
41 | in the text itself. The help text must mention the upstream URL of the | |
42 | project after an empty line. | |
d031a031 | 43 | |
cd615368 YM |
44 | As a convention specific to Buildroot, the ordering of the attributes |
45 | is as follows: | |
46 | ||
47 | 1. The type of option: +bool+, +string+... with the prompt | |
48 | 2. If needed, the +default+ value(s) | |
e1759f06 AVEM |
49 | 3. Any dependencies on the target in +depends on+ form |
50 | 4. Any dependencies on the toolchain in +depends on+ form | |
51 | 5. Any dependencies on other packages in +depends on+ form | |
52 | 6. Any dependency of the +select+ form | |
53 | 7. The help keyword and help text. | |
cd615368 | 54 | |
04d8fee3 YM |
55 | You can add other sub-options into a +if BR2_PACKAGE_LIBFOO...endif+ |
56 | statement to configure particular things in your software. You can look at | |
57 | examples in other packages. The syntax of the +Config.in+ file is the same | |
58 | as the one for the kernel Kconfig file. The documentation for this syntax is | |
59 | available at http://kernel.org/doc/Documentation/kbuild/kconfig-language.txt[] | |
41c1cb44 TP |
60 | |
61 | Finally you have to add your new +libfoo/Config.in+ to | |
62 | +package/Config.in+ (or in a category subdirectory if you decided to | |
63 | put your package in one of the existing categories). The files | |
64 | included there are 'sorted alphabetically' per category and are 'NOT' | |
65 | supposed to contain anything but the 'bare' name of the package. | |
66 | ||
67 | -------------------------- | |
68 | source "package/libfoo/Config.in" | |
69 | -------------------------- | |
70 | ||
1b3ac72d JH |
71 | |
72 | ==== +Config.in.host+ file | |
73 | ||
74 | Some packages also need to be built for the host system. There are two | |
75 | options here: | |
76 | ||
77 | * The host package is only required to satisfy build-time | |
78 | dependencies of one or more target packages. In this case, add | |
79 | +host-foo+ to the target package's +BAR_DEPENDENCIES+ variable. No | |
80 | +Config.in.host+ file should be created. | |
81 | ||
82 | * The host package should be explicitly selectable by the user from | |
83 | the configuration menu. In this case, create a +Config.in.host+ file | |
84 | for that host package: | |
85 | + | |
86 | --------------------------- | |
87 | config BR2_PACKAGE_HOST_FOO | |
88 | bool "host foo" | |
89 | help | |
90 | This is a comment that explains what foo for the host is. | |
91 | ||
92 | http://foosoftware.org/foo/ | |
93 | --------------------------- | |
94 | + | |
95 | The same coding style and options as for the +Config.in+ file are valid. | |
96 | + | |
97 | Finally you have to add your new +libfoo/Config.in.host+ to | |
98 | +package/Config.in.host+. The files included there are 'sorted alphabetically' | |
99 | and are 'NOT' supposed to contain anything but the 'bare' name of the package. | |
100 | + | |
101 | -------------------------- | |
102 | source "package/foo/Config.in.host" | |
103 | -------------------------- | |
104 | + | |
105 | The host package will then be available from the +Host utilities+ menu. | |
106 | ||
b4783b41 | 107 | [[depends-on-vs-select]] |
86a415df | 108 | ==== Choosing +depends on+ or +select+ |
722b82f0 | 109 | |
d0afbdad TP |
110 | The +Config.in+ file of your package must also ensure that |
111 | dependencies are enabled. Typically, Buildroot uses the following | |
112 | rules: | |
113 | ||
114 | * Use a +select+ type of dependency for dependencies on | |
115 | libraries. These dependencies are generally not obvious and it | |
116 | therefore make sense to have the kconfig system ensure that the | |
117 | dependencies are selected. For example, the _libgtk2_ package uses | |
118 | +select BR2_PACKAGE_LIBGLIB2+ to make sure this library is also | |
119 | enabled. | |
b143b6d0 | 120 | The +select+ keyword expresses the dependency with a backward |
b4783b41 | 121 | semantic. |
d0afbdad TP |
122 | |
123 | * Use a +depends on+ type of dependency when the user really needs to | |
124 | be aware of the dependency. Typically, Buildroot uses this type of | |
c3a832a7 TDS |
125 | dependency for dependencies on target architecture, MMU support and |
126 | toolchain options (see xref:dependencies-target-toolchain-options[]), | |
127 | or for dependencies on "big" things, such as the X.org system. | |
b143b6d0 | 128 | The +depends on+ keyword expresses the dependency with a forward |
b4783b41 SM |
129 | semantic. |
130 | ||
131 | .Note | |
132 | The current problem with the _kconfig_ language is that these two | |
133 | dependency semantics are not internally linked. Therefore, it may be | |
134 | possible to select a package, whom one of its dependencies/requirement | |
135 | is not met. | |
d0afbdad TP |
136 | |
137 | An example illustrates both the usage of +select+ and +depends on+. | |
138 | ||
139 | -------------------------- | |
9d188366 GZ |
140 | config BR2_PACKAGE_RRDTOOL |
141 | bool "rrdtool" | |
142 | depends on BR2_USE_WCHAR | |
143 | select BR2_PACKAGE_FREETYPE | |
144 | select BR2_PACKAGE_LIBART | |
145 | select BR2_PACKAGE_LIBPNG | |
146 | select BR2_PACKAGE_ZLIB | |
d0afbdad | 147 | help |
9d188366 GZ |
148 | RRDtool is the OpenSource industry standard, high performance |
149 | data logging and graphing system for time series data. | |
d0afbdad | 150 | |
9d188366 | 151 | http://oss.oetiker.ch/rrdtool/ |
d0afbdad | 152 | |
9d188366 GZ |
153 | comment "rrdtool needs a toolchain w/ wchar" |
154 | depends on !BR2_USE_WCHAR | |
d0afbdad TP |
155 | -------------------------- |
156 | ||
157 | ||
6372f4e6 SM |
158 | Note that these two dependency types are only transitive with the |
159 | dependencies of the same kind. | |
160 | ||
161 | This means, in the following example: | |
162 | ||
163 | -------------------------- | |
164 | config BR2_PACKAGE_A | |
165 | bool "Package A" | |
166 | ||
167 | config BR2_PACKAGE_B | |
168 | bool "Package B" | |
169 | depends on BR2_PACKAGE_A | |
170 | ||
171 | config BR2_PACKAGE_C | |
172 | bool "Package C" | |
173 | depends on BR2_PACKAGE_B | |
174 | ||
175 | config BR2_PACKAGE_D | |
176 | bool "Package D" | |
177 | select BR2_PACKAGE_B | |
178 | ||
179 | config BR2_PACKAGE_E | |
180 | bool "Package E" | |
181 | select BR2_PACKAGE_D | |
182 | -------------------------- | |
183 | ||
184 | * Selecting +Package C+ will be visible if +Package B+ has been | |
185 | selected, which in turn is only visible if +Package A+ has been | |
186 | selected. | |
187 | ||
188 | * Selecting +Package E+ will select +Package D+, which will select | |
189 | +Package B+, it will not check for the dependencies of +Package B+, | |
190 | so it will not select +Package A+. | |
191 | ||
192 | * Since +Package B+ is selected but +Package A+ is not, this violates | |
3b1df656 | 193 | the dependency of +Package B+ on +Package A+. Therefore, in such a |
6372f4e6 SM |
194 | situation, the transitive dependency has to be added explicitly: |
195 | ||
196 | -------------------------- | |
197 | config BR2_PACKAGE_D | |
198 | bool "Package D" | |
6372f4e6 | 199 | depends on BR2_PACKAGE_A |
39458e33 | 200 | select BR2_PACKAGE_B |
6372f4e6 SM |
201 | |
202 | config BR2_PACKAGE_E | |
203 | bool "Package E" | |
6372f4e6 | 204 | depends on BR2_PACKAGE_A |
39458e33 | 205 | select BR2_PACKAGE_D |
6372f4e6 SM |
206 | -------------------------- |
207 | ||
208 | Overall, for package library dependencies, +select+ should be | |
209 | preferred. | |
210 | ||
ecd23535 | 211 | Note that such dependencies will ensure that the dependency option |
d0afbdad TP |
212 | is also enabled, but not necessarily built before your package. To do |
213 | so, the dependency also needs to be expressed in the +.mk+ file of the | |
214 | package. | |
215 | ||
ecd23535 | 216 | Further formatting details: see xref:writing-rules-config-in[the |
65f66c17 | 217 | coding style]. |
b4783b41 | 218 | |
c3a832a7 | 219 | [[dependencies-target-toolchain-options]] |
86a415df TDS |
220 | ==== Dependencies on target and toolchain options |
221 | ||
c3a832a7 | 222 | Many packages depend on certain options of the toolchain: the choice of |
308ca05f GZ |
223 | C library, C++ support, thread support, RPC support, wchar support, |
224 | or dynamic library support. Some packages can only be built on certain | |
225 | target architectures, or if an MMU is available in the processor. | |
3c33c113 TDS |
226 | |
227 | These dependencies have to be expressed with the appropriate 'depends | |
228 | on' statements in the Config.in file. Additionally, for dependencies on | |
c3a832a7 TDS |
229 | toolchain options, a +comment+ should be displayed when the option is |
230 | not enabled, so that the user knows why the package is not available. | |
231 | Dependencies on target architecture or MMU support should not be | |
232 | made visible in a comment: since it is unlikely that the user can | |
233 | freely choose another target, it makes little sense to show these | |
234 | dependencies explicitly. | |
235 | ||
3c33c113 TDS |
236 | The +comment+ should only be visible if the +config+ option itself would |
237 | be visible when the toolchain option dependencies are met. This means | |
238 | that all other dependencies of the package (including dependencies on | |
239 | target architecture and MMU support) have to be repeated on the | |
240 | +comment+ definition. To keep it clear, the +depends on+ statement for | |
241 | these non-toolchain option should be kept separate from the +depends on+ | |
242 | statement for the toolchain options. | |
243 | If there is a dependency on a config option in that same file (typically | |
244 | the main package) it is preferable to have a global +if ... endif+ | |
245 | construct rather than repeating the +depends on+ statement on the | |
246 | comment and other config options. | |
247 | ||
c3a832a7 | 248 | The general format of a dependency +comment+ for package foo is: |
9d918e11 | 249 | |
c3a832a7 TDS |
250 | -------------------------- |
251 | foo needs a toolchain w/ featA, featB, featC | |
252 | -------------------------- | |
253 | ||
254 | for example: | |
9d918e11 | 255 | |
c3a832a7 | 256 | -------------------------- |
9d188366 | 257 | mpd needs a toolchain w/ C++, threads, wchar |
c3a832a7 | 258 | -------------------------- |
9d918e11 | 259 | |
28163563 | 260 | or |
9d918e11 | 261 | |
28163563 MH |
262 | -------------------------- |
263 | crda needs a toolchain w/ threads | |
264 | -------------------------- | |
c3a832a7 TDS |
265 | |
266 | Note that this text is kept brief on purpose, so that it will fit on a | |
267 | 80-character terminal. | |
268 | ||
269 | The rest of this section enumerates the different target and toolchain | |
270 | options, the corresponding config symbols to depend on, and the text to | |
271 | use in the comment. | |
272 | ||
273 | * Target architecture | |
274 | ** Dependency symbol: +BR2_powerpc+, +BR2_mips+, ... (see +arch/Config.in+) | |
275 | ** Comment string: no comment to be added | |
276 | ||
277 | * MMU support | |
278 | ** Dependency symbol: +BR2_USE_MMU+ | |
279 | ** Comment string: no comment to be added | |
280 | ||
508c3e0c TP |
281 | * Gcc +__sync_*+ built-ins used for atomic operations. They are |
282 | available in variants operating on 1 byte, 2 bytes, 4 bytes and 8 | |
283 | bytes. Since different architectures support atomic operations on | |
284 | different sizes, one dependency symbol is available for each size: | |
285 | ** Dependency symbol: +BR2_TOOLCHAIN_HAS_SYNC_1+ for 1 byte, | |
286 | +BR2_TOOLCHAIN_HAS_SYNC_2+ for 2 bytes, | |
287 | +BR2_TOOLCHAIN_HAS_SYNC_4+ for 4 bytes, +BR2_TOOLCHAIN_HAS_SYNC_8+ | |
288 | for 8 bytes. | |
289 | ** Comment string: no comment to be added | |
290 | ||
291 | * Gcc +__atomic_*+ built-ins used for atomic operations. | |
292 | ** Dependency symbol: +BR2_TOOLCHAIN_HAS_ATOMIC+. | |
293 | ** Comment string: no comment to be added | |
294 | ||
6395bf09 YM |
295 | * Kernel headers |
296 | ** Dependency symbol: +BR2_TOOLCHAIN_HEADERS_AT_LEAST_X_Y+, (replace | |
6e3c9ad5 | 297 | +X_Y+ with the proper version, see +toolchain/Config.in+) |
aa0c8be4 YM |
298 | ** Comment string: +headers >= X.Y+ and/or `headers <= X.Y` (replace |
299 | +X.Y+ with the proper version) | |
6395bf09 | 300 | |
45aaa372 TP |
301 | * GCC version |
302 | ** Dependency symbol: +BR2_TOOLCHAIN_GCC_AT_LEAST_X_Y+, (replace | |
6e3c9ad5 | 303 | +X_Y+ with the proper version, see +toolchain/Config.in+) |
45aaa372 TP |
304 | ** Comment string: +gcc >= X.Y+ and/or `gcc <= X.Y` (replace |
305 | +X.Y+ with the proper version) | |
306 | ||
12825f7a AV |
307 | * Host GCC version |
308 | ** Dependency symbol: +BR2_HOST_GCC_AT_LEAST_X_Y+, (replace | |
309 | +X_Y+ with the proper version, see +Config.in+) | |
310 | ** Comment string: no comment to be added | |
311 | ** Note that it is usually not the package itself that has a minimum | |
312 | host GCC version, but rather a host-package on which it depends. | |
313 | ||
c3a832a7 TDS |
314 | * C library |
315 | ** Dependency symbol: +BR2_TOOLCHAIN_USES_GLIBC+, | |
a0e0bdcd | 316 | +BR2_TOOLCHAIN_USES_MUSL+, +BR2_TOOLCHAIN_USES_UCLIBC+ |
c3a832a7 | 317 | ** Comment string: for the C library, a slightly different comment text |
416fd9cd | 318 | is used: +foo needs a glibc toolchain+, or `foo needs a glibc |
5e3cb357 | 319 | toolchain w/ C++` |
c3a832a7 TDS |
320 | |
321 | * C++ support | |
322 | ** Dependency symbol: +BR2_INSTALL_LIBSTDCPP+ | |
323 | ** Comment string: `C++` | |
324 | ||
dda8eb03 ELB |
325 | * D support |
326 | ** Dependency symbol: +BR2_TOOLCHAIN_HAS_DLANG+ | |
327 | ** Comment string: `Dlang` | |
328 | ||
abfef1ca SM |
329 | * Fortran support |
330 | ** Dependency symbol: +BR2_TOOLCHAIN_HAS_FORTRAN+ | |
331 | ** Comment string: `fortran` | |
332 | ||
c3a832a7 TDS |
333 | * thread support |
334 | ** Dependency symbol: +BR2_TOOLCHAIN_HAS_THREADS+ | |
7586be4a TP |
335 | ** Comment string: +threads+ (unless +BR2_TOOLCHAIN_HAS_THREADS_NPTL+ |
336 | is also needed, in which case, specifying only +NPTL+ is sufficient) | |
337 | ||
338 | * NPTL thread support | |
339 | ** Dependency symbol: +BR2_TOOLCHAIN_HAS_THREADS_NPTL+ | |
340 | ** Comment string: +NPTL+ | |
c3a832a7 TDS |
341 | |
342 | * RPC support | |
343 | ** Dependency symbol: +BR2_TOOLCHAIN_HAS_NATIVE_RPC+ | |
344 | ** Comment string: +RPC+ | |
345 | ||
c3a832a7 TDS |
346 | * wchar support |
347 | ** Dependency symbol: +BR2_USE_WCHAR+ | |
348 | ** Comment string: +wchar+ | |
349 | ||
350 | * dynamic library | |
665e13c8 | 351 | ** Dependency symbol: +!BR2_STATIC_LIBS+ |
c3a832a7 TDS |
352 | ** Comment string: +dynamic library+ |
353 | ||
86a415df TDS |
354 | ==== Dependencies on a Linux kernel built by buildroot |
355 | ||
b47c8cc8 TDS |
356 | Some packages need a Linux kernel to be built by buildroot. These are |
357 | typically kernel modules or firmware. A comment should be added in the | |
358 | Config.in file to express this dependency, similar to dependencies on | |
359 | toolchain options. The general format is: | |
360 | ||
361 | -------------------------- | |
362 | foo needs a Linux kernel to be built | |
363 | -------------------------- | |
364 | ||
365 | If there is a dependency on both toolchain options and the Linux | |
366 | kernel, use this format: | |
9d918e11 | 367 | |
b47c8cc8 TDS |
368 | -------------------------- |
369 | foo needs a toolchain w/ featA, featB, featC and a Linux kernel to be built | |
370 | -------------------------- | |
c3a832a7 | 371 | |
86a415df TDS |
372 | ==== Dependencies on udev /dev management |
373 | ||
6386eda4 | 374 | If a package needs udev /dev management, it should depend on symbol |
fabcb119 | 375 | +BR2_PACKAGE_HAS_UDEV+, and the following comment should be added: |
6386eda4 TDS |
376 | |
377 | -------------------------- | |
378 | foo needs udev /dev management | |
379 | -------------------------- | |
380 | ||
381 | If there is a dependency on both toolchain options and udev /dev | |
382 | management, use this format: | |
383 | ||
384 | -------------------------- | |
385 | foo needs udev /dev management and a toolchain w/ featA, featB, featC | |
386 | -------------------------- | |
387 | ||
07c642b7 YM |
388 | ==== Dependencies on features provided by virtual packages |
389 | ||
390 | Some features can be provided by more than one package, such as the | |
391 | openGL libraries. | |
392 | ||
393 | See xref:virtual-package-tutorial[] for more on the virtual packages. | |
394 | ||
86a415df TDS |
395 | === The +.mk+ file |
396 | ||
a0ad75a1 | 397 | [[adding-packages-mk]] |
41c1cb44 TP |
398 | |
399 | Finally, here's the hardest part. Create a file named +libfoo.mk+. It | |
400 | describes how the package should be downloaded, configured, built, | |
401 | installed, etc. | |
402 | ||
403 | Depending on the package type, the +.mk+ file must be written in a | |
404 | different way, using different infrastructures: | |
405 | ||
bcd0158e TP |
406 | * *Makefiles for generic packages* (not using autotools or CMake): |
407 | These are based on an infrastructure similar to the one used for | |
ecd23535 | 408 | autotools-based packages, but require a little more work from the |
41c1cb44 | 409 | developer. They specify what should be done for the configuration, |
436dc00d | 410 | compilation and installation of the package. This |
41c1cb44 TP |
411 | infrastructure must be used for all packages that do not use the |
412 | autotools as their build system. In the future, other specialized | |
3b1df656 | 413 | infrastructures might be written for other build systems. We cover |
2359e122 AVEM |
414 | them through in a xref:generic-package-tutorial[tutorial] and a |
415 | xref:generic-package-reference[reference]. | |
41c1cb44 TP |
416 | |
417 | * *Makefiles for autotools-based software* (autoconf, automake, etc.): | |
418 | We provide a dedicated infrastructure for such packages, since | |
419 | autotools is a very common build system. This infrastructure 'must' | |
420 | be used for new packages that rely on the autotools as their build | |
2359e122 AVEM |
421 | system. We cover them through a xref:autotools-package-tutorial[tutorial] |
422 | and xref:autotools-package-reference[reference]. | |
41c1cb44 | 423 | |
bcd0158e TP |
424 | * *Makefiles for cmake-based software*: We provide a dedicated |
425 | infrastructure for such packages, as CMake is a more and more | |
426 | commonly used build system and has a standardized behaviour. This | |
427 | infrastructure 'must' be used for new packages that rely on | |
2359e122 AVEM |
428 | CMake. We cover them through a xref:cmake-package-tutorial[tutorial] |
429 | and xref:cmake-package-reference[reference]. | |
bcd0158e | 430 | |
2f886ee3 TP |
431 | * *Makefiles for Python modules*: We have a dedicated infrastructure |
432 | for Python modules that use either the +distutils+ or the | |
433 | +setuptools+ mechanism. We cover them through a | |
434 | xref:python-package-tutorial[tutorial] and a | |
435 | xref:python-package-reference[reference]. | |
436 | ||
437 | * *Makefiles for Lua modules*: We have a dedicated infrastructure for | |
438 | Lua modules available through the LuaRocks web site. We cover them | |
439 | through a xref:luarocks-package-tutorial[tutorial] and a | |
440 | xref:luarocks-package-reference[reference]. | |
441 | ||
1360b6b4 | 442 | Further formatting details: see xref:writing-rules-mk[the writing |
b4783b41 | 443 | rules]. |
05187693 YM |
444 | |
445 | [[adding-packages-hash]] | |
446 | === The +.hash+ file | |
447 | ||
a0c9b36b TP |
448 | When possible, you must add a third file, named +libfoo.hash+, that |
449 | contains the hashes of the downloaded files for the +libfoo+ | |
450 | package. The only reason for not adding a +.hash+ file is when hash | |
451 | checking is not possible due to how the package is downloaded. | |
05187693 | 452 | |
8e293a63 YM |
453 | When a package has a version selection choice, then the hash file may be |
454 | stored in a subdirectory named after the version, e.g. | |
455 | +package/libfoo/1.2.3/libfoo.hash+. This is especially important if the | |
456 | different versions have different licensing terms, but they are stored | |
457 | in the same file. Otherwise, the hash file should stay in the package's | |
458 | directory. | |
459 | ||
05187693 | 460 | The hashes stored in that file are used to validate the integrity of the |
4bd21d3e | 461 | downloaded files and of the license files. |
05187693 YM |
462 | |
463 | The format of this file is one line for each file for which to check the | |
ec060ced | 464 | hash, each line with the following three fields separated by two spaces: |
05187693 YM |
465 | |
466 | * the type of hash, one of: | |
5da82181 | 467 | ** +md5+, +sha1+, +sha224+, +sha256+, +sha384+, +sha512+ |
05187693 | 468 | * the hash of the file: |
74ce748d | 469 | ** for +md5+, 32 hexadecimal characters |
05187693 YM |
470 | ** for +sha1+, 40 hexadecimal characters |
471 | ** for +sha224+, 56 hexadecimal characters | |
472 | ** for +sha256+, 64 hexadecimal characters | |
473 | ** for +sha384+, 96 hexadecimal characters | |
474 | ** for +sha512+, 128 hexadecimal characters | |
4bd21d3e YM |
475 | * the name of the file: |
476 | ** for a source archive: the basename of the file, without any directory | |
477 | component, | |
478 | ** for a license file: the path as it appears in +FOO_LICENSE_FILES+. | |
05187693 YM |
479 | |
480 | Lines starting with a +#+ sign are considered comments, and ignored. Empty | |
481 | lines are ignored. | |
482 | ||
483 | There can be more than one hash for a single file, each on its own line. In | |
484 | this case, all hashes must match. | |
485 | ||
74ce748d | 486 | .Note |
05187693 YM |
487 | Ideally, the hashes stored in this file should match the hashes published by |
488 | upstream, e.g. on their website, in the e-mail announcement... If upstream | |
74ce748d | 489 | provides more than one type of hash (e.g. +sha1+ and +sha512+), then it is |
05187693 | 490 | best to add all those hashes in the +.hash+ file. If upstream does not |
74ce748d YM |
491 | provide any hash, or only provides an +md5+ hash, then compute at least one |
492 | strong hash yourself (preferably +sha256+, but not +md5+), and mention | |
493 | this in a comment line above the hashes. | |
05187693 | 494 | |
4bd21d3e YM |
495 | .Note |
496 | The hashes for license files are used to detect a license change when a | |
6b9c4cd5 PS |
497 | package version is bumped. The hashes are checked during the make legal-info |
498 | target run. For a package with multiple versions (like Qt5), | |
63eeb9a3 YM |
499 | create the hash file in a subdirectory +<packageversion>+ of that package |
500 | (see also xref:patch-apply-order[]). | |
4bd21d3e | 501 | |
05187693 | 502 | The example below defines a +sha1+ and a +sha256+ published by upstream for |
74ce748d YM |
503 | the main +libfoo-1.2.3.tar.bz2+ tarball, an +md5+ from upstream and a |
504 | locally-computed +sha256+ hashes for a binary blob, a +sha256+ for a | |
505 | downloaded patch, and an archive with no hash: | |
05187693 YM |
506 | |
507 | ---- | |
508 | # Hashes from: http://www.foosoftware.org/download/libfoo-1.2.3.tar.bz2.{sha1,sha256}: | |
ec060ced HT |
509 | sha1 486fb55c3efa71148fe07895fd713ea3a5ae343a libfoo-1.2.3.tar.bz2 |
510 | sha256 efc8103cc3bcb06bda6a781532d12701eb081ad83e8f90004b39ab81b65d4369 libfoo-1.2.3.tar.bz2 | |
05187693 | 511 | |
74ce748d | 512 | # md5 from: http://www.foosoftware.org/download/libfoo-1.2.3.tar.bz2.md5, sha256 locally computed: |
ec060ced HT |
513 | md5 2d608f3c318c6b7557d551a5a09314f03452f1a1 libfoo-data.bin |
514 | sha256 01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b libfoo-data.bin | |
74ce748d YM |
515 | |
516 | # Locally computed: | |
ec060ced | 517 | sha256 ff52101fb90bbfc3fe9475e425688c660f46216d7e751c4bbdb1dc85cdccacb9 libfoo-fix-blabla.patch |
1ba85b7f | 518 | |
4bd21d3e | 519 | # Hash for license files: |
ec060ced HT |
520 | sha256 a45a845012742796534f7e91fe623262ccfb99460a2bd04015bd28d66fba95b8 COPYING |
521 | sha256 01b1f9f2c8ee648a7a596a1abe8aa4ed7899b1c9e5551bda06da6e422b04aa55 doc/COPYING.LGPL | |
05187693 YM |
522 | ---- |
523 | ||
524 | If the +.hash+ file is present, and it contains one or more hashes for a | |
525 | downloaded file, the hash(es) computed by Buildroot (after download) must | |
526 | match the hash(es) stored in the +.hash+ file. If one or more hashes do | |
527 | not match, Buildroot considers this an error, deletes the downloaded file, | |
528 | and aborts. | |
529 | ||
530 | If the +.hash+ file is present, but it does not contain a hash for a | |
32753154 YM |
531 | downloaded file, Buildroot considers this an error and aborts. However, |
532 | the downloaded file is left in the download directory since this | |
533 | typically indicates that the +.hash+ file is wrong but the downloaded | |
534 | file is probably OK. | |
05187693 | 535 | |
a0c9b36b TP |
536 | Hashes are currently checked for files fetched from http/ftp servers, |
537 | Git repositories, files copied using scp and local files. Hashes are | |
538 | not checked for other version control systems (such as Subversion, | |
539 | CVS, etc.) because Buildroot currently does not generate reproducible | |
540 | tarballs when source code is fetched from such version control | |
541 | systems. | |
542 | ||
543 | Hashes should only be added in +.hash+ files for files that are | |
544 | guaranteed to be stable. For example, patches auto-generated by Github | |
545 | are not guaranteed to be stable, and therefore their hashes can change | |
546 | over time. Such patches should not be downloaded, and instead be added | |
547 | locally to the package folder. | |
12862225 | 548 | |
05187693 | 549 | If the +.hash+ file is missing, then no check is done at all. |