From 7a7ae700571ab279da31d9ee08caee219815c135 Mon Sep 17 00:00:00 2001 From: Owen-sz Date: Tue, 28 Apr 2026 20:48:34 -0500 Subject: [PATCH 1/5] feat: expand RPM sections page Signed-off-by: Owen-sz --- content/docs/rpm/sections.mdx | 110 +++++++++++++++++++++++++++++----- 1 file changed, 95 insertions(+), 15 deletions(-) diff --git a/content/docs/rpm/sections.mdx b/content/docs/rpm/sections.mdx index ac046a30..6057972a 100644 --- a/content/docs/rpm/sections.mdx +++ b/content/docs/rpm/sections.mdx @@ -22,11 +22,13 @@ Here is a non-exclusive (but nearly exclusive) list of preambles available: Name: pkgname Version: 1.2.3 Release: 1%?dist -Summary: Package summary (usually do not add period at the end) +Summary: Package summary (do not add period at the end) # As opposed to the guidelines given by RPM, we (and also Fedora!) strongly # recommend using SPDX identifiers. License: MIT URL: https://terra.fyralabs.com/ +Source0: Link to download the source code. If more then one link is needed, +specify with Source1:, Source2:, etc. ## terra also enforces the following preamble: @@ -44,6 +46,7 @@ AutoProv: 1 ## these fields are optional +Patch: SourceLicense: BugURL: ModularityLabel: @@ -59,6 +62,8 @@ ExclusiveOS: BuildArch: BuildArchitectures: BuildRequires: +NoSource: +NoPatch: Group: Provides: @@ -78,6 +83,11 @@ RemovePathPostFixes: BuildSystem: BuildOption: + +Icon: (Obsolete) +Buildroot: (Obsolete) +BuildPrereq: (Obsolete) +Prereq: (Obsolete) ``` @@ -217,12 +227,11 @@ Step `Executing(%conf)`. Optional. Since `rpm >= 4.18`. > %configure > ``` -When in doubt, you can always put `%configure{:rpmspec}` and other commands at the start of -`%build{:rpmspec}` instead. +Macros such as `%cmake` and `%meson` should also be placed in this section. ## `%build` -Step `Executing(%build)`. Optional. +Step `Executing(%build)`. If there is nothing to build, you should still declare this step in your spec. > In `%build`, the unpacked (and configured) sources are compiled to binaries. > @@ -254,14 +263,6 @@ install -Dpm755 my_binary -t %{buildroot}/usr/bin/ install -Dpm644 rand_file -t %{buildroot}/usr/share/my_software/ ``` -## `%doc` - -Step `Executing(%doc)`. **Not a section**. See [`%files{:rpmspec}`](#files). - -## `%license` - -Step `Executing(%license)`. **Not a section**. See [`%files{:rpmspec}`](#files). - ## `%check` Step `Executing(%check)`. Optional. @@ -271,6 +272,64 @@ Step `Executing(%check)`. Optional. If you would like to make sure the software actually works properly, you may optionally choose to execute unit tests here. +## Package scripts + +> Package scripts execute before and after the main operation (install/remove etc.) of the package inside a transaction. +> +> Package scripts should only be used for actions that are fundamentally package specific. +> Domain specific registries, databases, caches and such are much better handled centrally +> by file triggers. Similarly, user and group creation should be handled by rpm-sysusers, rather than scripting them. + +### `%pre` +> Executed just before unpacking the contents of the package. +> Non-zero exit prevents the installation of the containing package. + +### `%post` +> Executed just after unpacking the contents of the package. + +### `%preun` +> Executed just before removing the contents of the package. +> Non-zero exit prevents the uninstallation of the containing package. + +### `%postun` +> Executed just after removing the contents of the package. + +### `%verify` + +> Executed when a package is verified using rpm --verify. +> +> Unlike all the other scriptlet types, `%verify` never executes as a part of install/erase etc. operations. + +## Transaction scripts + +> Transaction scripts run before and after all the other package level +> operations (install/remove etc.) in a transaction. +> +> When multiple transaction scripts for a given slot are present in a transaction, +> they are executed in the order of their install/removal order within the transaction. + +### `%pretrans` +> Executed just before an install/update/reinstall transaction on the containing package starts. +> +> No files from the transaction have been installed or removed yet. That is, in a fresh +> installation to an empty system root, there are no files around and no interpreter to run, +> so the only interpreter that can be reliably used in this slot is the embedded rpm-lua(7) interpreter. +> +> Non-zero exit prevents the installation of the containing package. +> +> This is a very special and a dangerous slot, and is best avoided. + +### `%posttrans` +> Executed just after an install/update/reinstall transaction on the containing package finishes. +> +> All files from the transaction have been installed or removed at this point. + +### `%preuntrans` +> Executed just before an uninstall/updated-from transaction on the containing package starts. + +### `%postuntrans` +> Executed just after an uninstall/updated-from transaction on the containing package finishes. + ## `%clean` Step `Executing(%clean)`. Optional. **Obsolete**. @@ -318,13 +377,16 @@ The following is an exhaustive list of file attributes available: ```rpmspec %artifact … -# ╰─ mado: personally never seen this used +# ╰─ denote files that are more like side-effects of packaging than actual content +# the user would be interested in. Such files can be easily filtered out on queries. +%caps +# ╰─ sets the given POSIX.1e draft 15 capabilities on the file %config(…) … # ╰─ exhaustive list: # - config(missingok) # - config(noreplace) %dir … -# ╰─ specify a directory the package owns +# ╰─ explicitly own the directory itself but not it’s contents %doc … # ╰─ store the file into %{_docdir} %docdir @@ -346,13 +408,31 @@ The following is an exhaustive list of file attributes available: # - verify(rdev) # - verify(mtime) # - verify(not ...) +%missingok +# ╰─ mark file presence optional +%readme +# ╰─ Obsolete - use %doc # special: %attr(…) … %defattr(…) ``` -For more information about `%attr{:rpmspec}` and `%defattr{:rpmspec}`, see: http://ftp.rpm.org/max-rpm/s1-rpm-inside-files-list-directives.html +For more information about `%attr{:rpmspec}` and `%defattr{:rpmspec}`, see: https://rpm-software-management.github.io/rpm/manual/spec.html + +## `%changelog` + +Metadata section. Optional, but required in Fedora and Terra + +Specify a change to the spec. + +Must either use `%autochangelog`, or follow this structure: + +``` +* Day Mon DD YYYY Name - version-release +- Change you made +- Another change, if there's enough to justify two lines +``` [expression]: #rpm-expression [RPM manual]: https://github.com/rpm-software-management/rpm/blob/b043604b9eb684dc761aeacf55a784632ca0ebcd/docs/manual/macros.md From d175756d13f53ac5426dfbf95dca52aaccf30207 Mon Sep 17 00:00:00 2001 From: Owen-sz Date: Tue, 28 Apr 2026 21:59:11 -0500 Subject: [PATCH 2/5] add more to RPM sections page Signed-off-by: Owen-sz --- content/docs/rpm/sections.mdx | 156 +++++++++++++++++++--------------- 1 file changed, 89 insertions(+), 67 deletions(-) diff --git a/content/docs/rpm/sections.mdx b/content/docs/rpm/sections.mdx index 6057972a..12f37b2a 100644 --- a/content/docs/rpm/sections.mdx +++ b/content/docs/rpm/sections.mdx @@ -164,15 +164,6 @@ If `subpkg` is given without `-n`, specify the description of the subpackage `%{ Each subpackage requires its own `%description{:rpmspec}` too. -## `%package` - -Not a step. Optional. `%package [-n] subpkg{:rpmspec}` - -Specify the preambles for a subpackage. The name of the subpackage is - -- `subpkg` if `-n` is given; and -- `%{name}-subpkg` otherwise. - ## `%mkbuilddir` Step `Executing(%mkbuilddir)`. Optional. @@ -272,64 +263,6 @@ Step `Executing(%check)`. Optional. If you would like to make sure the software actually works properly, you may optionally choose to execute unit tests here. -## Package scripts - -> Package scripts execute before and after the main operation (install/remove etc.) of the package inside a transaction. -> -> Package scripts should only be used for actions that are fundamentally package specific. -> Domain specific registries, databases, caches and such are much better handled centrally -> by file triggers. Similarly, user and group creation should be handled by rpm-sysusers, rather than scripting them. - -### `%pre` -> Executed just before unpacking the contents of the package. -> Non-zero exit prevents the installation of the containing package. - -### `%post` -> Executed just after unpacking the contents of the package. - -### `%preun` -> Executed just before removing the contents of the package. -> Non-zero exit prevents the uninstallation of the containing package. - -### `%postun` -> Executed just after removing the contents of the package. - -### `%verify` - -> Executed when a package is verified using rpm --verify. -> -> Unlike all the other scriptlet types, `%verify` never executes as a part of install/erase etc. operations. - -## Transaction scripts - -> Transaction scripts run before and after all the other package level -> operations (install/remove etc.) in a transaction. -> -> When multiple transaction scripts for a given slot are present in a transaction, -> they are executed in the order of their install/removal order within the transaction. - -### `%pretrans` -> Executed just before an install/update/reinstall transaction on the containing package starts. -> -> No files from the transaction have been installed or removed yet. That is, in a fresh -> installation to an empty system root, there are no files around and no interpreter to run, -> so the only interpreter that can be reliably used in this slot is the embedded rpm-lua(7) interpreter. -> -> Non-zero exit prevents the installation of the containing package. -> -> This is a very special and a dangerous slot, and is best avoided. - -### `%posttrans` -> Executed just after an install/update/reinstall transaction on the containing package finishes. -> -> All files from the transaction have been installed or removed at this point. - -### `%preuntrans` -> Executed just before an uninstall/updated-from transaction on the containing package starts. - -### `%postuntrans` -> Executed just after an uninstall/updated-from transaction on the containing package finishes. - ## `%clean` Step `Executing(%clean)`. Optional. **Obsolete**. @@ -434,6 +367,95 @@ Must either use `%autochangelog`, or follow this structure: - Another change, if there's enough to justify two lines ``` +## Package scripts + +> Package scripts execute before and after the main operation (install/remove etc.) of the package inside a transaction. +> +> Package scripts should only be used for actions that are fundamentally package specific. +> Domain specific registries, databases, caches and such are much better handled centrally +> by file triggers. Similarly, user and group creation should be handled by rpm-sysusers, rather than scripting them. + +### `%pre` +> Executed just before unpacking the contents of the package. +> Non-zero exit prevents the installation of the containing package. + +### `%post` +> Executed just after unpacking the contents of the package. + +### `%preun` +> Executed just before removing the contents of the package. +> Non-zero exit prevents the uninstallation of the containing package. + +### `%postun` +> Executed just after removing the contents of the package. + +### `%verify` + +> Executed when a package is verified using rpm --verify. +> +> Unlike all the other scriptlet types, `%verify` never executes as a part of install/erase etc. operations. + +## Transaction scripts + +> Transaction scripts run before and after all the other package level +> operations (install/remove etc.) in a transaction. +> +> When multiple transaction scripts for a given slot are present in a transaction, +> they are executed in the order of their install/removal order within the transaction. + +### `%pretrans` +> Executed just before an install/update/reinstall transaction on the containing package starts. +> +> No files from the transaction have been installed or removed yet. That is, in a fresh +> installation to an empty system root, there are no files around and no interpreter to run, +> so the only interpreter that can be reliably used in this slot is the embedded rpm-lua(7) interpreter. +> +> Non-zero exit prevents the installation of the containing package. +> +> This is a very special and a dangerous slot, and is best avoided. + +### `%posttrans` +> Executed just after an install/update/reinstall transaction on the containing package finishes. +> +> All files from the transaction have been installed or removed at this point. + +### `%preuntrans` +> Executed just before an uninstall/updated-from transaction on the containing package starts. + +### `%postuntrans` +> Executed just after an uninstall/updated-from transaction on the containing package finishes. + +## Sub-sections + +These are optional macros that are not their own build steps, but are also not +standalone macros. + +### `%sourcelist` +> List of sources, one per line. Handled like unnumbered Source tags. For clarity, +> mixing Source tags and %sourcelist in one specfile is not recommended. + +### `%patchlist` +Like `%sourcelist`, but for patches. + +### `%package [-n]` + +Not a step. Optional. `%package [-n] subpkg{:rpmspec}` + +Specify the preambles for a subpackage. The name of the subpackage is + +- `subpkg` if `-n` is given; and +- `%{name}-subpkg` otherwise. + +### `%description [-n]` +Used to define a description for a subpackage. +Requires if `%package` is used. + +The `-n` and `` options work the same, however if not defined this will refer to the main package. + +## File Triggers + +For information on file triggers, check out the [RPM documentation](https://rpm-software-management.github.io/rpm/man/rpm-scriptlets.7#FILE_TRIGGERS). + [expression]: #rpm-expression [RPM manual]: https://github.com/rpm-software-management/rpm/blob/b043604b9eb684dc761aeacf55a784632ca0ebcd/docs/manual/macros.md [boolean dependencies]: https://rpm-software-management.github.io/rpm/manual/boolean_dependencies.html From 1ef38435330923576faab33af4dba5de6add919c Mon Sep 17 00:00:00 2001 From: Owen-sz Date: Tue, 28 Apr 2026 22:01:15 -0500 Subject: [PATCH 3/5] minor additions Signed-off-by: Owen-sz --- content/docs/rpm/sections.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/docs/rpm/sections.mdx b/content/docs/rpm/sections.mdx index 12f37b2a..ac2fc849 100644 --- a/content/docs/rpm/sections.mdx +++ b/content/docs/rpm/sections.mdx @@ -314,7 +314,7 @@ The following is an exhaustive list of file attributes available: # the user would be interested in. Such files can be easily filtered out on queries. %caps # ╰─ sets the given POSIX.1e draft 15 capabilities on the file -%config(…) … +%config(…) … (can be used on it's own or with parameters) # ╰─ exhaustive list: # - config(missingok) # - config(noreplace) @@ -340,7 +340,7 @@ The following is an exhaustive list of file attributes available: # - verify(link symlink) ← same # - verify(rdev) # - verify(mtime) -# - verify(not ...) +# - verify(not ...) (don't verify this attribute) %missingok # ╰─ mark file presence optional %readme From 0dfaa5b6f3d116e8d5fe4a5ad73a7821fba0a60f Mon Sep 17 00:00:00 2001 From: Owen-sz Date: Tue, 28 Apr 2026 22:44:05 -0500 Subject: [PATCH 4/5] feat: start work on expanding RPM macros page Signed-off-by: Owen-sz --- content/docs/rpm/macros.mdx | 99 ++++++++++++++++++++++++++++++++++--- 1 file changed, 92 insertions(+), 7 deletions(-) diff --git a/content/docs/rpm/macros.mdx b/content/docs/rpm/macros.mdx index 684a87b6..2e30f7aa 100644 --- a/content/docs/rpm/macros.mdx +++ b/content/docs/rpm/macros.mdx @@ -226,7 +226,7 @@ Double-expand the macro. ```rpmspec title="example.spec" %define nya foo %define meow %{expand:%%nya} - + echo %meow ``` @@ -236,7 +236,7 @@ Double-expand the macro. ``` - + ##### `%{lua:…}` 🛠️ [#lua] @@ -466,6 +466,18 @@ This macro is used in [`%setup …`](#setup) for uncompressing source files. #### Environment info +##### `%?dist` [#?dist] + +Used in the `Release:` tag, expands to the dist tag, which is the builder OS shortened identifer and version. Examples: + +`.fc44` +`.um43` + +Can either be used as `%?dist` or `%dist`, The `?` prefix just means it expands to nothing if the macro is +undefined, which avoids errors when building without a dist tag. + + + ##### `%{getncpus:…}` [#getncpus] When used as `%{getncpus}` with no arguments, expand to the number of available CPU cores. @@ -497,6 +509,22 @@ concerned. It is suspected that the arguments in most cases have no effect to th +##### `%_smp_build_ncpus` [#_smp_build_ncpus] + +Expands to the output of `nproc` (the build host's thread count) + +Example use case: `%make_build GHCJOBS=%{_smp_build_ncpus}` + + + +##### `%_smp_mflags` [#_smp_mflags] + +Expands to `-j${RPM_BUILD_NCPUS}` + +Example use case: `make %{_smp_mflags}` + + + #### Output ##### `%{echo:…}` 🔦 [#echo] @@ -558,7 +586,7 @@ Expand to the path to the source file. This is just a fancy macro that transform
```rpmspec title="example.spec" Source0: https://repos.fyralabs.com/um42/comps.xml - + %prep cat %{S:0} echo %{S:1} @@ -567,14 +595,14 @@ Expand to the path to the source file. This is just a fancy macro that transform
```rpmspec title="expand.spec" Source0: https://repos.fyralabs.com/um42/comps.xml - + %prep cat %{_sourcedir}/comps.xml echo %SOURCE1 ```
- + ##### `%{P:#}` [#P] @@ -623,6 +651,18 @@ Or you can just use `less` instead of `grep`. #### Miscellaneous +##### `%_lib` [#_lib] + +Expands to `lib` (on noarch or 32-bit packages) or `lib64` (on 64-bit packages) + + + +##### `%__ln_s` [#__ln_s] + +Expands to the system's `ln -s` command (should be used when symlinks are needed) + + + ##### `%nil` 🔰 [#nil] Expand to nothing. @@ -763,7 +803,7 @@ what things the binaries are linked to, you may disable that by adding a regex t If you want to disable all automatic `Requires:`, set `AutoReq: 0`. - + ##### `%__requires_exclude_from` 🏷️ [#__requires_exclude_from] @@ -841,6 +881,8 @@ Similar to above, but takes in path to file that contains the regexes. ##### `%__brp_mangle_shebangs_exclude_from_file` 🏷️ [#__brp_mangle_shebangs_exclude_from_file] +Similar to above, but takes a path to a file containing the list of file paths to exclude. + ##### `%__brp_mangle_shebangs` 🏷️ @@ -1125,7 +1167,6 @@ Macros with the '(Terra only)' warning are part of the `anda-srpm-macros` packag /run ⇒ %{_rundir} /usr ⇒ %{_usr} /usr/bin ⇒ %{_bindir} -/usr/sbin ⇒ %{_sbindir} maybe? /usr/src ⇒ %{_usrsrc} /usr/include ⇒ %{_includedir} /usr/lib64 ⇒ %{_libdir} @@ -1264,6 +1305,50 @@ If your language / buildsystem is not listed here, go to https://docs.fedoraproject.org/en-US/packaging-guidelines/ and find them on the navigation rail on the left. +TODO: add macros/sections on these(?): + +- R-rpm-macros +- blender-rpm-macros +- moby-rpm-macros +- pyproject-rpm-macros +- cargo-rpm-macros +- cmake-rpm-macros +- cmake-rpm-macros +- erlang-rpm-macros +- fedora-rpm-macros +- flatpak-rpm-macros +- folly-rpm-macros +- fonts-rpm-macros +- gap-rpm-macros +- ghc-rpm-macros +- go-rpm-macros +- kernel-rpm-macros +- lua-rpm-macros +- magicmirror-rpm-macros +- ocaml-rpm-macros +- python-rpm-macros +- rpmautospec-rpm-macros +- rocm-rpm-macros +- sgx-rpm-macros +- systemd-rpm-macros +- zig-rpm-macros +- cargo-rpm-macros +- epel-rpm-macros +- kde-apps-rpm-macros +- qt6-rpm-macros +- build2-rpm-macros +- build-constraints-rpm-macros +- kf5-rpm-macros +- kf6-rpm-macros +- postgresql-test-rpm-macros +- qt5-rpm-macros +- go-rpm-macros-epel +- python-pyqt6-rpm-macros +- postgresql17-test-rpm-macros +- python-qt5-rpm-macros +- romc-rpm-macros7.2 +- the srpm ones I don't feel like listing rn + #### C and C++ ##### `%configure` [#configure] From 8513ba62713f6462490853d754a43e9b2780988c Mon Sep 17 00:00:00 2001 From: Owen-sz Date: Wed, 29 Apr 2026 23:37:32 -0500 Subject: [PATCH 5/5] add packaged-macros.mdx Signed-off-by: Owen-sz --- content/docs/rpm/macros.mdx | 257 +-------------------- content/docs/rpm/packaged-macros.mdx | 324 +++++++++++++++++++++++++++ 2 files changed, 328 insertions(+), 253 deletions(-) create mode 100644 content/docs/rpm/packaged-macros.mdx diff --git a/content/docs/rpm/macros.mdx b/content/docs/rpm/macros.mdx index 2e30f7aa..4cc6b1ea 100644 --- a/content/docs/rpm/macros.mdx +++ b/content/docs/rpm/macros.mdx @@ -470,8 +470,10 @@ This macro is used in [`%setup …`](#setup) for uncompressing source files. Used in the `Release:` tag, expands to the dist tag, which is the builder OS shortened identifer and version. Examples: -`.fc44` -`.um43` +``` +.fc44 +.um43 +``` Can either be used as `%?dist` or `%dist`, The `?` prefix just means it expands to nothing if the macro is undefined, which avoids errors when building without a dist tag. @@ -1298,254 +1300,3 @@ mkdir -p %{buildroot}%{_datadir}/themes - -### Per Language - -If your language / buildsystem is not listed here, go to -https://docs.fedoraproject.org/en-US/packaging-guidelines/ -and find them on the navigation rail on the left. - -TODO: add macros/sections on these(?): - -- R-rpm-macros -- blender-rpm-macros -- moby-rpm-macros -- pyproject-rpm-macros -- cargo-rpm-macros -- cmake-rpm-macros -- cmake-rpm-macros -- erlang-rpm-macros -- fedora-rpm-macros -- flatpak-rpm-macros -- folly-rpm-macros -- fonts-rpm-macros -- gap-rpm-macros -- ghc-rpm-macros -- go-rpm-macros -- kernel-rpm-macros -- lua-rpm-macros -- magicmirror-rpm-macros -- ocaml-rpm-macros -- python-rpm-macros -- rpmautospec-rpm-macros -- rocm-rpm-macros -- sgx-rpm-macros -- systemd-rpm-macros -- zig-rpm-macros -- cargo-rpm-macros -- epel-rpm-macros -- kde-apps-rpm-macros -- qt6-rpm-macros -- build2-rpm-macros -- build-constraints-rpm-macros -- kf5-rpm-macros -- kf6-rpm-macros -- postgresql-test-rpm-macros -- qt5-rpm-macros -- go-rpm-macros-epel -- python-pyqt6-rpm-macros -- postgresql17-test-rpm-macros -- python-qt5-rpm-macros -- romc-rpm-macros7.2 -- the srpm ones I don't feel like listing rn - -#### C and C++ - -##### `%configure` [#configure] - -Expand to `./configure` with the correct flags and arguments. -If you need to execute `./configure`, in most cases you should use this macro instead. - -In some cases where `./configure` is not directly available, you may need to run -`autoreconf -fi` or `-fiv`. - - - -##### `%make_build` 🔰 [#make_build] - -⇒ `%__make -O -j${RPM_BUILD_NCPUS} V=1 VERBOSE=1{:sh}`, -where `%{__make}` ⇒ `/usr/bin/make`. -Further arguments to `make` can be attached. - - - -##### `%make_install` 🔰 [#make_install] - -⇒ `%__make install DESTDIR=%?buildroot INSTALL="%__install -p"{:sh}`. - - - -##### `%makeinstall` 🚸 [#makeinstall] - -Deprecated. Use [`%make_install`](#make_install) instead. - - - -##### `%cmake` 🔰 [#cmake] - -Expand to `%{__cmake}` (⇒ `/usr/bin/cmake`) with the correct flags, -such as `-B "%__cmake_builddir"{:sh}` (⇒ `-B "redhat-linux-build"{:sh}`). - - - -##### `%cmake_build` 🔰 [#cmake_build] - -⇒ `%__cmake --build "%__cmake_builddir" %?_smp_mflags --verbose{:sh}`. - - - -##### `%cmake_install` 🔰 [#cmake_install] - -⇒ `DESTDIR="%buildroot" %__cmake --install "%__cmake_builddir"{:sh}`. - - - -##### `%meson` 🔰 [#meson] - -≈ `%__meson setup{:sh}` with correct flags. - - - -##### `%meson_build` 🔰 [#meson_build] - -⇒ `%__meson compile -C "%_vpath_builddir" -j %_smp_build_ncpus %{?__meson_verbose:--verbose}{:sh}` - -⇒ `/usr/bin/meson compile -C redhat-linux-build -j 20 --verbose{:sh}` (on my machine). - - - -##### `%meson_install` 🔰 [#meson_install] - -⇒ `DESTDIR=%buildroot %__meson install -C %_vpath_builddir --no-rebuild{:sh}`. -Used in `%install{:rpmspec}`. - - - -##### `%meson_test` 🔰 [#meson_test] - -⇒ `%__meson test -C %_vpath_builddir --no-rebuild %{!?__meson_verbose:--quiet}{:sh}`. -Used in `%check{:rpmspec}`. - - - -##### `%ninja_build` [#ninja_build] - -⇒ `%__ninja %__ninja_common_opts{:sh}` - -⇒ `%__ninja -v -j${RPM_BUILD_NCPUS}{:sh}`. - - - -##### `%ninja_install` [#ninja_install] - -⇒ `DESTDIR=%buildroot %__ninja install %__ninja_common_opts{:sh}`. - - - -##### `%ninja_test` [#ninja_test] - -⇒ `%__ninja test %__ninja_common_opts{:sh}`. - - - -##### `%build_cflags` 🏷️ [#build_cflags] - -Flags to be passed to the C compiler. - -⇒ `%{__build_flags_lang_c} %{?_distro_extra_cflags}` - - - -##### `%_distro_extra_cflags` 🏷️ [#_distro_extra_cflags] - -For example, if the compiler is emitting errors that could be disabled with some -`-Wno-…` flags, you can define this macro with extra flags. - -This macro is not defined by default on Fedora. - - - -##### `%build_cxxflags` 🏷️ [#build_cxxflags] - -Flags to be passed to the C++ compiler. - -⇒ `%{__build_flags_lang_cxx} %{?_distro_extra_cxxflags}` - - - -##### `%_distro_extra_cxxflags` 🏷️ [#_distro_extra_cxxflags] - -For example, if the compiler is emitting errors that could be disabled with some -`-Wno-…` flags, you can define this macro with extra flags. - -This macro is not defined by default on Fedora. - - - -#### D - -##### `%ldc_arches` [#ldc_arches] - - - -##### `%_d_optflags` [#_d_optflags] - - - -#### Java - -https://docs.fedoraproject.org/en-US/java-packaging-howto/ - -#### Nim - -This section is only applicable to Terra (because Fedora does not ship Nim). - -##### `%nim_prep` [#nim_prep] - -Set `mold` as the linker and run `nimble setup -y`. - - - -##### `%nim_build` [#nim_build] - -Same as [`%nim_c`](#nim_c). - - - -##### `%nim_c` [#nim_c] - -⇒ `nim c -d:release -t:"%nim_tflags" -l:"%nim_lflags"{:sh}`. - - - -#### Python - -https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/ - -#### Rust - -https://docs.fedoraproject.org/en-US/packaging-guidelines/Rust/ - -##### `%rustflags_debuginfo` 🏷️ [#rustflags_debuginfo] - -If `gdb` crashes in `find-debuginfo`, you might want to lower the value to `1` or even `0`. - -The default value is `2`. - -```rpmspec title="example.spec" {11} -https://github.com/terrapkg/packages/blob/2df55dad60a58ecf5f8fbe962f877f2834bdfa25/anda/devs/zed/nightly/zed-nightly.spec#L14 - -%bcond_with check - -# Exclude input files from mangling -%global __brp_mangle_shebangs_exclude_from ^/usr/src/.*$ - -%global crate zed -%global app_id dev.zed.Zed-Nightly - -%global rustflags_debuginfo 0 -``` - -[expression]: ./expr - - diff --git a/content/docs/rpm/packaged-macros.mdx b/content/docs/rpm/packaged-macros.mdx new file mode 100644 index 00000000..faade867 --- /dev/null +++ b/content/docs/rpm/packaged-macros.mdx @@ -0,0 +1,324 @@ +--- +title: Macros in Fedora Packages +description: "These macros are not default in RPM, rather they are available in the Fedora package repos." +--- + +import { SearchTerra } from '@/components/mdx/searchterra'; + +## R-rpm-macros + +## blender-rpm-macros + +## moby-rpm-macros + +## pyproject-rpm-macros + +## cargo-rpm-macros + +## cmake-rpm-macros + +## cmake-rpm-macros + +## erlang-rpm-macros + +## fedora-rpm-macros + +## flatpak-rpm-macros + +## folly-rpm-macros + +## fonts-rpm-macros + +## gap-rpm-macros + +## ghc-rpm-macros + +## go-rpm-macros + +## kernel-rpm-macros + +## lua-rpm-macros + +## magicmirror-rpm-macros + +## ocaml-rpm-macros + +## python-rpm-macros + +## rpmautospec-rpm-macros + +## rocm-rpm-macros + +## sgx-rpm-macros + +## systemd-rpm-macros + +## zig-rpm-macros + +## cargo-rpm-macros + +## epel-rpm-macros + +## kde-apps-rpm-macros + +## qt6-rpm-macros + +## build2-rpm-macros + +## build-constraints-rpm-macros + +## kf5-rpm-macros + +## kf6-rpm-macros + +## postgresql-test-rpm-macros + +## qt5-rpm-macros + +## go-rpm-macros-epel + +## python-pyqt6-rpm-macros + +## postgresql17-test-rpm-macros + +## python-qt5-rpm-macros + +## romc-rpm-macros7.2 + +## the srpm ones I don't feel like listing rn + +## Other + +This is a non exhaustive list of macros that non `*-rpm-macros` packages in Fedora provide + +### `%vimfiles_root` 🔢🔦🛠️ [#vimfiles_root] + +Provided by the `vim-filesystem` package. +Expands to `%{_datadir}/vim/vimfiles` + + + +### `%_vpath_srcdir` [#_vpath_srcdir] + +Provided by the `redhat-rpm-config` package. +Expands to `.` + +Yes, it juse expands to `.`. It is described as "directory where CMakeLists.txt/meson.build/etc. are placed." + + + +### `%_vpath_builddir` [#_vpath_builddir] + +Provided by the `redhat-rpm-config` package. +Expands to `%{_vendor}-%{_target_os}-build` + +described as "directory (doesn't need to exist) where all generated build files will be placed" + +## Language Provided Macros + +If your language / buildsystem is not listed here, go to +https://docs.fedoraproject.org/en-US/packaging-guidelines/ +and find them on the navigation rail on the left. + +### C and C++ + +#### `%configure` [#configure] + +Expand to `./configure` with the correct flags and arguments. +If you need to execute `./configure`, in most cases you should use this macro instead. + +In some cases where `./configure` is not directly available, you may need to run +`autoreconf -fi` or `-fiv`. + +You SHOULD use this macro within the `%conf` section. + + + +#### `%make_build` 🔰 [#make_build] + +⇒ `%__make -O -j${RPM_BUILD_NCPUS} V=1 VERBOSE=1{:sh}`, +where `%{__make}` ⇒ `/usr/bin/make`. +Further arguments to `make` can be attached. + + + +#### `%make_install` 🔰 [#make_install] + +⇒ `%__make install DESTDIR=%?buildroot INSTALL="%__install -p"{:sh}`. + + + +#### `%makeinstall` 🚸 [#makeinstall] + +Deprecated. Use [`%make_install`](#make_install) instead. + + + +#### `%cmake` 🔰 [#cmake] + +Expand to `%{__cmake}` (⇒ `/usr/bin/cmake`) with the correct flags, +such as `-B "%__cmake_builddir"{:sh}` (⇒ `-B "redhat-linux-build"{:sh}`). + + + +#### `%cmake_build` 🔰 [#cmake_build] + +⇒ `%__cmake --build "%__cmake_builddir" %?_smp_mflags --verbose{:sh}`. + + + +#### `%cmake_install` 🔰 [#cmake_install] + +⇒ `DESTDIR="%buildroot" %__cmake --install "%__cmake_builddir"{:sh}`. + + + +#### `%meson` 🔰 [#meson] + +≈ `%__meson setup{:sh}` with correct flags. + + + +#### `%meson_build` 🔰 [#meson_build] + +⇒ `%__meson compile -C "%_vpath_builddir" -j %_smp_build_ncpus %{?__meson_verbose:--verbose}{:sh}` + +⇒ `/usr/bin/meson compile -C redhat-linux-build -j 20 --verbose{:sh}` (on my machine). + + + +#### `%meson_install` 🔰 [#meson_install] + +⇒ `DESTDIR=%buildroot %__meson install -C %_vpath_builddir --no-rebuild{:sh}`. +Used in `%install{:rpmspec}`. + + + +#### `%meson_test` 🔰 [#meson_test] + +⇒ `%__meson test -C %_vpath_builddir --no-rebuild %{!?__meson_verbose:--quiet}{:sh}`. +Used in `%check{:rpmspec}`. + + + +#### `%ninja_build` [#ninja_build] + +⇒ `%__ninja %__ninja_common_opts{:sh}` + +⇒ `%__ninja -v -j${RPM_BUILD_NCPUS}{:sh}`. + + + +#### `%ninja_install` [#ninja_install] + +⇒ `DESTDIR=%buildroot %__ninja install %__ninja_common_opts{:sh}`. + + + +#### `%ninja_test` [#ninja_test] + +⇒ `%__ninja test %__ninja_common_opts{:sh}`. + + + +#### `%build_cflags` 🏷️ [#build_cflags] + +Flags to be passed to the C compiler. + +⇒ `%{__build_flags_lang_c} %{?_distro_extra_cflags}` + + + +#### `%_distro_extra_cflags` 🏷️ [#_distro_extra_cflags] + +For example, if the compiler is emitting errors that could be disabled with some +`-Wno-…` flags, you can define this macro with extra flags. + +This macro is not defined by default on Fedora. + + + +#### `%build_cxxflags` 🏷️ [#build_cxxflags] + +Flags to be passed to the C++ compiler. + +⇒ `%{__build_flags_lang_cxx} %{?_distro_extra_cxxflags}` + + + +#### `%_distro_extra_cxxflags` 🏷️ [#_distro_extra_cxxflags] + +For example, if the compiler is emitting errors that could be disabled with some +`-Wno-…` flags, you can define this macro with extra flags. + +This macro is not defined by default on Fedora. + + + +### D + +#### `%ldc_arches` [#ldc_arches] + + + +#### `%_d_optflags` [#_d_optflags] + + + +### Java + +https://docs.fedoraproject.org/en-US/java-packaging-howto/ + +### Nim + +This section is only applicable to Terra (because Fedora does not ship Nim). + +#### `%nim_prep` [#nim_prep] + +Set `mold` as the linker and run `nimble setup -y`. + + + +#### `%nim_build` [#nim_build] + +Same as [`%nim_c`](#nim_c). + + + +#### `%nim_c` [#nim_c] + +⇒ `nim c -d:release -t:"%nim_tflags" -l:"%nim_lflags"{:sh}`. + + + +### Python + +https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/ + +### Rust + +https://docs.fedoraproject.org/en-US/packaging-guidelines/Rust/ + +#### `%rustflags_debuginfo` 🏷️ [#rustflags_debuginfo] + +If `gdb` crashes in `find-debuginfo`, you might want to lower the value to `1` or even `0`. + +The default value is `2`. + +```rpmspec title="example.spec" {11} +https://github.com/terrapkg/packages/blob/2df55dad60a58ecf5f8fbe962f877f2834bdfa25/anda/devs/zed/nightly/zed-nightly.spec#L14 + +%bcond_with check + +# Exclude input files from mangling +%global __brp_mangle_shebangs_exclude_from ^/usr/src/.*$ + +%global crate zed +%global app_id dev.zed.Zed-Nightly + +%global rustflags_debuginfo 0 +``` + +[expression]: ./expr + +