3 SPDX-License-Identifier: MIT
4 SPDX-FileCopyrightText: Copyright The SCons Foundation (https://scons.org)
5 SPDX-FileType: DOCUMENTATION
7 This file is processed by the bin/SConsDoc.py module
11 <!ENTITY % scons SYSTEM '../../../doc/scons.mod'>
13 <!ENTITY % builders-mod SYSTEM '../../../doc/generated/builders.mod'>
15 <!ENTITY % functions-mod SYSTEM '../../../doc/generated/functions.mod'>
17 <!ENTITY % tools-mod SYSTEM '../../../doc/generated/tools.mod'>
19 <!ENTITY % variables-mod SYSTEM '../../../doc/generated/variables.mod'>
23 <sconsdoc xmlns="http://www.scons.org/dbxsd/v1.0"
24 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
25 xsi:schemaLocation="http://www.scons.org/dbxsd/v1.0 http://www.scons.org/dbxsd/v1.0/scons.xsd">
27 <tool name="packaging">
30 Sets construction variables for the &b-link-Package; Builder.
31 If this tool is enabled, the <option>--package-type</option>
32 command-line option is also enabled.
41 <builder name="Package">
44 Builds software distribution packages.
45 A <firstterm>package</firstterm> is a container format which
46 includes files to install along with metadata.
47 Packaging is optional, and must be enabled by specifying
48 the &t-link-packaging; tool. For example:
52 env = Environment(tools=['default', 'packaging'])
56 &SCons; can build packages in a number of well known packaging formats.
57 The target package type may be selected with the
58 the &cv-link-PACKAGETYPE; construction variable
59 or the <option>--package-type</option> command line option.
60 The package type may be a list, in which case &SCons; will attempt
61 to build packages for each type in the list. Example:
65 env.Package(PACKAGETYPE=['src_zip', 'src_targz'], <replaceable>...other args...</replaceable>)
69 The currently supported packagers are:
72 <informaltable rowsep="1" colsep="1" frame="topbot">
75 <row><entry><literal>msi</literal></entry><entry>Microsoft Installer package</entry></row>
76 <row><entry><literal>rpm</literal></entry><entry>RPM Package Manger package</entry></row>
77 <row><entry><literal>ipkg</literal></entry><entry>Itsy Package Management package</entry></row>
78 <row><entry><literal>tarbz2</literal></entry><entry>bzip2-compressed tar file</entry></row>
79 <row><entry><literal>targz</literal></entry><entry>gzip-compressed tar file</entry></row>
80 <row><entry><literal>tarxz</literal></entry><entry>xz-compressed tar file</entry></row>
81 <row><entry><literal>zip</literal></entry><entry>zip file</entry></row>
82 <row><entry><literal>src_tarbz2</literal></entry><entry>bzip2-compressed tar file suitable as source to another packager</entry></row>
83 <row><entry><literal>src_targz</literal></entry><entry>gzip-compressed tar file suitable as source to another packager</entry></row>
84 <row><entry><literal>src_tarxz</literal></entry><entry>xz-compressed tar file suitable as source to another packager</entry></row>
85 <row><entry><literal>src_zip</literal></entry><entry>zip file suitable as source to another packager</entry></row>
91 The file list to include in the package may be specified with
92 the &source; keyword argument. If omitted,
93 the &f-link-FindInstalledFiles; function is called behind the scenes
94 to select all files that have an &b-link-Install;, &b-link-InstallAs;
95 or &b-link-InstallVersionedLib; Builder attached.
96 If the ⌖ keyword argument is omitted, the target name(s)
97 will be deduced from the package type(s).
101 The metadata comes partly from attributes of the files to be packaged,
102 and partly from packaging <firstterm>tags</firstterm>.
103 Tags can be passed as keyword arguments
104 to the &b-Package; builder call,
105 and may also be attached to files
106 (or more accurately, Nodes representing files)
107 with the &f-link-Tag; function.
108 Some package-level tags are mandatory, and will lead to errors if omitted.
109 The mandatory tags vary depending on the package type.
110 <!-- TODO: should document which tags are mandatory for which packager -->
114 While packaging, the builder uses a temporary location named
115 by the value of the &cv-link-PACKAGEROOT; variable -
116 the package sources are copied there before packaging.
124 env = Environment(tools=["default", "packaging"])
125 env.Install("/bin/", "my_program")
132 SUMMARY="balalalalal",
133 DESCRIPTION="this should be really really long",
134 X_RPM_GROUP="Application/fu",
135 SOURCE_URL="https://foo.org/foo-1.2.3.tar.gz",
140 In this example, the target <filename>/bin/my_program</filename>
141 created by the &b-Install; call would not be built by default
142 since it is not under the project top directory.
143 However, since no <parameter>source</parameter>
144 is specified to the &b-Package; builder,
145 it is selected for packaging by the default sources rule.
146 Since packaging is done using &cv-link-PACKAGEROOT;, no write is
147 actually done to the system's <filename>/bin</filename> directory,
148 and the target <emphasis>will</emphasis> be selected since
149 after rebasing to underneath &cv-PACKAGEROOT; it is now under
150 the top directory of the project.
156 <cvar name="ARCHITECTURE">
159 Specifies the system architecture for which
160 the package is being built.
161 The default is the system architecture
162 of the machine on which SCons is running.
163 This is used to fill in the
164 <literal>Architecture:</literal>
166 <filename>control</filename> file,
167 and the <literal>BuildArch:</literal> field
168 in the RPM <filename>.spec</filename> file,
169 as well as forming part of the name of a generated RPM package file.
171 <para>See the &b-link-Package; builder.</para>
175 <cvar name="CHANGE_SPECFILE">
178 A hook for modifying the file that controls the packaging build
179 (the <filename>.spec</filename> for RPM,
180 the <filename>control</filename> for Ipkg,
181 the <filename>.wxs</filename> for MSI).
182 If set, the function will be called
183 after the SCons template for the file has been written.
185 <para>See the &b-link-Package; builder.</para>
189 <cvar name="CHANGELOG">
192 The name of a file containing the change log text
193 to be included in the package.
194 This is included as the
195 <literal>%changelog</literal>
197 <filename>.spec</filename> file.
199 <para>See the &b-link-Package; builder.</para>
203 <cvar name="DESCRIPTION">
206 A long description of the project being packaged.
207 This is included in the relevant section
208 of the file that controls the packaging build.
210 <para>See the &b-link-Package; builder.</para>
214 <cvar name="DESCRIPTION_lang">
217 A language-specific long description for
218 the specified <varname>lang</varname>.
219 This is used to populate a
220 <literal>%description -l</literal>
222 <filename>.spec</filename> file.
224 <para>See the &b-link-Package; builder.</para>
228 <cvar name="LICENSE">
231 The abbreviated name, preferably the SPDX code, of the license under which
232 this project is released (GPL-3.0, LGPL-2.1, BSD-2-Clause etc.).
234 <ulink url="http://www.opensource.org/licenses/alphabetical">
235 http://www.opensource.org/licenses/alphabetical</ulink>
236 for a list of license names and SPDX codes.
238 <para>See the &b-link-Package; builder.</para>
245 Specfies the name of the project to package.
247 <para>See the &b-link-Package; builder.</para>
251 <cvar name="PACKAGEROOT">
254 Specifies the directory where all files in resulting archive will be
255 placed if applicable. The default value is <quote>&cv-NAME;-&cv-VERSION;</quote>.
257 <para>See the &b-link-Package; builder.</para>
261 <cvar name="PACKAGETYPE">
264 Selects the package type to build when using the &b-link-Package;
265 builder. May be a string or list of strings. See the docuentation
266 for the builder for the currently supported types.
270 &cv-PACKAGETYPE; may be overridden with the <option>--package-type</option>
273 <para>See the &b-link-Package; builder.</para>
277 <cvar name="PACKAGEVERSION">
280 The version of the package (not the underlying project).
281 This is currently only used by the rpm packager
282 and should reflect changes in the packaging,
283 not the underlying project code itself.
285 <para>See the &b-link-Package; builder.</para>
289 <cvar name="SOURCE_URL">
294 of the location from which the project was retrieved.
295 This is used to fill in the
296 <literal>Source:</literal>
297 field in the controlling information for Ipkg and RPM packages.
299 <para>See the &b-link-Package; builder.</para>
303 <cvar name="SUMMARY">
306 A short summary of what the project is about.
307 This is used to fill in the
308 <literal>Summary:</literal>
309 field in the controlling information for Ipkg and RPM packages,
311 <literal>Description:</literal>
312 field in MSI packages.
314 <para>See the &b-link-Package; builder.</para>
321 The person or organization who supply the packaged software.
322 This is used to fill in the
323 <literal>Vendor:</literal>
324 field in the controlling information for RPM packages,
326 <literal>Manufacturer:</literal>
327 field in the controlling information for MSI packages.
329 <para>See the &b-link-Package; builder.</para>
333 <cvar name="VERSION">
336 The version of the project, specified as a string.
338 <para>See the &b-link-Package; builder.</para>
343 <cvar name="X_IPK_DEPENDS">
346 This is used to fill in the
347 <literal>Depends:</literal>
348 field in the controlling information for Ipkg packages.
350 <para>See the &b-link-Package; builder.</para>
354 <cvar name="X_IPK_DESCRIPTION">
357 This is used to fill in the
358 <literal>Description:</literal>
359 field in the controlling information for Ipkg packages.
361 <quote>&cv-SUMMARY;\n&cv-DESCRIPTION;</quote>
366 <cvar name="X_IPK_MAINTAINER">
369 This is used to fill in the
370 <literal>Maintainer:</literal>
371 field in the controlling information for Ipkg packages.
376 <cvar name="X_IPK_PRIORITY">
379 This is used to fill in the
380 <literal>Priority:</literal>
381 field in the controlling information for Ipkg packages.
386 <cvar name="X_IPK_SECTION">
389 This is used to fill in the
390 <literal>Section:</literal>
391 field in the controlling information for Ipkg packages.
396 <cvar name="X_MSI_LANGUAGE">
399 This is used to fill in the
400 <literal>Language:</literal>
401 attribute in the controlling information for MSI packages.
403 <para>See the &b-link-Package; builder.</para>
407 <cvar name="X_MSI_LICENSE_TEXT">
410 The text of the software license in RTF format.
411 Carriage return characters will be
412 replaced with the RTF equivalent \\par.
414 <para>See the &b-link-Package; builder.</para>
418 <cvar name="X_MSI_UPGRADE_CODE">
427 <cvar name="X_RPM_AUTOREQPROV">
430 This is used to fill in the
431 <literal>AutoReqProv:</literal>
433 <filename>.spec</filename> file.
435 <para>See the &b-link-Package; builder.</para>
439 <cvar name="X_RPM_BUILD">
442 internal, but overridable
447 <cvar name="X_RPM_BUILDREQUIRES">
450 This is used to fill in the
451 <literal>BuildRequires:</literal>
453 <filename>.spec</filename> file.
454 Note this should only be used on a host managed by rpm as the dependencies will not be resolvable at build time otherwise.
459 <cvar name="X_RPM_BUILDROOT">
462 internal, but overridable
467 <cvar name="X_RPM_CLEAN">
470 internal, but overridable
475 <cvar name="X_RPM_CONFLICTS">
478 This is used to fill in the
479 <literal>Conflicts:</literal>
481 <filename>.spec</filename> file.
486 <cvar name="X_RPM_DEFATTR">
489 This value is used as the default attributes
490 for the files in the RPM package.
492 <quote>(-,root,root)</quote>.
497 <cvar name="X_RPM_DISTRIBUTION">
500 This is used to fill in the
501 <literal>Distribution:</literal>
503 <filename>.spec</filename> file.
508 <cvar name="X_RPM_EPOCH">
511 This is used to fill in the
512 <literal>Epoch:</literal>
514 <filename>.spec</filename> file.
519 <cvar name="X_RPM_EXCLUDEARCH">
522 This is used to fill in the
523 <literal>ExcludeArch:</literal>
525 <filename>.spec</filename> file.
530 <cvar name="X_RPM_EXLUSIVEARCH">
533 This is used to fill in the
534 <literal>ExclusiveArch:</literal>
536 <filename>.spec</filename> file.
541 <cvar name="X_RPM_EXTRADEFS">
544 A list used to supply extra defintions or flags
545 to be added to the RPM <filename>.spec</filename> file.
546 Each item is added as-is with a carriage return appended.
547 This is useful if some specific RPM feature not otherwise
548 anticipated by SCons needs to be turned on or off.
549 Note if this variable is omitted, SCons will by
550 default supply the value
551 <literal>'%global debug_package %{nil}'</literal>
552 to disable debug package generation.
553 To enable debug package generation, include this
554 variable set either to None, or to a custom
555 list that does not include the default line.
558 <emphasis>New in version 3.1.</emphasis>
566 "%define _unpackaged_files_terminate_build 0"
567 "%define _missing_doc_files_terminate_build 0"
576 <cvar name="X_RPM_GROUP">
579 This is used to fill in the
580 <literal>Group:</literal>
582 <filename>.spec</filename> file.
587 <cvar name="X_RPM_GROUP_lang">
590 This is used to fill in the
591 <literal>Group(lang):</literal>
593 <filename>.spec</filename> file.
595 <varname>lang</varname>
597 and should be replaced by
598 the appropriate language code.
603 <cvar name="X_RPM_ICON">
606 This is used to fill in the
607 <literal>Icon:</literal>
609 <filename>.spec</filename> file.
614 <cvar name="X_RPM_INSTALL">
617 internal, but overridable
622 <cvar name="X_RPM_PACKAGER">
625 This is used to fill in the
626 <literal>Packager:</literal>
628 <filename>.spec</filename> file.
633 <cvar name="X_RPM_PROVIDES">
636 This is used to fill in the
637 <literal>Provides:</literal>
639 <filename>.spec</filename> file.
644 <cvar name="X_RPM_POSTINSTALL">
647 This is used to fill in the
648 <literal>%post:</literal>
650 <filename>.spec</filename> file.
655 <cvar name="X_RPM_PREINSTALL">
658 This is used to fill in the
659 <literal>%pre:</literal>
661 <filename>.spec</filename> file.
666 <cvar name="X_RPM_PREFIX">
669 This is used to fill in the
670 <literal>Prefix:</literal>
672 <filename>.spec</filename> file.
677 <cvar name="X_RPM_PREP">
680 internal, but overridable
685 <cvar name="X_RPM_POSTUNINSTALL">
688 This is used to fill in the
689 <literal>%postun:</literal>
691 <filename>.spec</filename> file.
696 <cvar name="X_RPM_PREUNINSTALL">
699 This is used to fill in the
700 <literal>%preun:</literal>
702 <filename>.spec</filename> file.
707 <cvar name="X_RPM_REQUIRES">
710 This is used to fill in the
711 <literal>Requires:</literal>
713 <filename>.spec</filename> file.
718 <cvar name="X_RPM_SERIAL">
721 This is used to fill in the
722 <literal>Serial:</literal>
724 <filename>.spec</filename> file.
729 <cvar name="X_RPM_URL">
732 This is used to fill in the
733 <literal>Url:</literal>
735 <filename>.spec</filename> file.
743 THE FOLLOWING AREN'T CONSTRUCTION VARIABLES,
744 THEY'RE "TAGS" THAT CAN BE ATTACHED
745 TO DIFFERENT FILES OR DIRECTORIES.
746 NOT SURE YET WHAT TO DO ABOUT THESE.
756 <cvar name="CONFIG_NOREPLACE">
772 <cvar name="INSTALL_LOCATION">
775 internal, but overridable, TODO
780 <cvar name="LANG_lang">
788 <cvar name="UNIX_ATTR">
796 <cvar name="X_IPK_POSTINST">
804 <cvar name="X_IPK_POSTRM">
812 <cvar name="X_IPK_PREINST">
820 <cvar name="X_IPK_PRERM">
828 <cvar name="X_MSI_FEATURE">
836 <cvar name="X_MSI_FILEID">
844 <cvar name="X_MSI_LONGNAME">
852 <cvar name="X_MSI_SHORTNAME">
860 <cvar name="X_MSI_VITAL">
868 <cvar name="X_RPM_DIR">
876 <cvar name="X_RPM_DOCDIR">
884 <cvar name="X_RPM_GHOST">
892 <cvar name="X_RPM_VERIFY">
903 <scons_function name="Tag">
904 <arguments signature="global">
909 Annotates file or directory Nodes with
910 information about how the
912 Builder should package those files or directories.
913 All Node-level tags are optional.
921 # makes sure the built library will be installed with 644 file access mode
922 Tag(Library('lib.c'), UNIX_ATTR="0o644")
924 # marks file2.txt to be a documentation file
925 Tag('file2.txt', DOC)
932 <function name="FindSourceFiles">
935 A convenience function which returns all leaves of the build tree.
940 <builder name="FindInstalledFiles">
943 Returns all files "built" by the &b-Install; or &b-InstallAs; builders.