RBM_TEMPLATES(7)
okay bestie, sit down, hydrate, because it's manpage o'clock π
. This is rbm_templates(7) β the entire lore drop on how rbm templates work, and honestly? it ate. no cap. π¦
β¨ NAME β¨
rbm_templates β a whole description of the rbm templates, periodt π
π DESCRIPTION π
okay so here's the main character twist: every single configuration option is actually a template πΈ. like, all of them. you can drop template directives into any option you want and it'll just vibe.
but β and this is the plot twist β there are a few exceptions π, and they're the options that are needed to process the templates, so obviously they can't be templated themselves (that would be a whole recursive nightmare, we don't do that here). the following options are not templated:
projects_dir
and if you want to make other options not templated too, just add them to the notmpl config option, which is an array π§. every other option? automatically processed as a template. slay.
the templates are made using perl Template Toolkit. you can read more about the syntax on the Template Toolkit website β¨.
from any template, it is possible to include other template files using the INCLUDE directive π. the template files are added to the directory projects_dir/project β where projects_dir is the projects directory (the default is projects) and project is the name of the project. other template files can be added in the directory projects_dir/common, so they can be included from any of the other templates π.
there are different template files π. by default, the following template file is used, but you can add more:
- the build script template, named
buildπ οΈ. this template is used to create a build script, that is executed when you use thebuildcommand. this creates thebuildoption.
π the variables you can use in template files π
configβ contains all the configuration π. you can view the content withrbm showconf.cβ this variable is a function reference β¨. instead of accessing theconfigvariable directly, you can use thecfunction, which will look at the command line parameters, then the project specific configuration, then the global configuration, and return the first defined one π«Ά. the syntax to use this function isc('option-name'). optionally it can take as a second argument a hash table containing options to override temporarily (in template processing) πΈ. additionally the 2nd argument can contain the following options:no_tmplβ set this to1if you want to disable template processing for this option lookup π .error_if_undefβ set this to1(for the default error message) or a string containing an error message, if you want to exit with an error when the selected option is undefined π.as_arrayβ if set to1, then return all matching results as an array reference, instead of only the first one π .norecβ this option is useful in the cases where the value of an option depends on the input files of the current project, for example to compute a hash based on the input files π§. innorecyou can define options that will apply to the current project, but will not be applied on the child projects defined in theinput_filessection. for more details, you can read the"Inheritance of projects options"section inrbm_input_files(7)π.
pcβ this variable is a function reference β¨. it is the same asc, except that it takes a project name as its first argument π. this is useful if you want to access the config value of an other project than the current one. the command line options are not used in this lookup π«. the current target is used, unless an other target option is defined in the options argument. the current project name is available to the requested option in theorigin_projectoption πΈ. the current step is used, unless an other step option is defined in the options argument. the previous step is available in theorigin_stepoption.projectβ the name of the project for which we are processing a template π.dest_dirβ the destination directory, where the resulting files will be stored at the end of the build π. this is mainly useful in build script templates, and probably not useful in package template files, iykyk.exit_errorβ a function that you can use to exit with an error π. the first argument is an error message. the second argument is an optional exit code (default is1).execβ a function taking a command line as argument, to be executed in the sources tree π οΈ. the output of the command is returned, if the exit code was0. if the argument starts with#, then it is considered to be a script, which will be written to a temporary file and executed π. the second argument of theexecfunction is an optional$optionshash, used to override values ofgit_url,hg_url,fetch,git_hashorhg_hash. before running the command a checkout ofgit_hashorhg_hashis done, unlessexec_nocois set totrue. if neithergit_urlnorhg_urlis set, the command is executed from the directory where therbm.conffile is located πpathβ a function to return an absolute path π . it takes a path as first argument. if the path is already an absolute path, then it returns the same thing. if the path is a relative path, it returns the path concatenated withbasedir, which is the directory where the main configuration file is located β¨. optionally it can take a second argument to set an other value for thebasedir.tmplβ a function taking a template text as argument, and returning it processed πΈ.shell_quoteβ a function to quote strings to use them as arguments in command lines π«Ά. this is the function from theString::ShellQuoteperl module.versioncmpβ a function to compare two version numbers π. it returns-1,0, or1depending on whether the first argument is less than, equal to, or greater than the second argument. this is the function from theSort::Versionsperl module.sha256β a function returning thesha256digest of its argument as an hexadecimal string π₯.sha512β a function returning thesha512digest of its argument as an hexadecimal string π₯.sha256fileβ a function returning thesha256digest of a file as an hexadecimal string π. if the file does not exist, an empty string is returned.sha512fileβ a function returning thesha512digest of a file as an hexadecimal string π. if the file does not exist, an empty string is returned.fileparseβ a function to parse a path π§. returns an array containing the filename, and the directory path. this is thefileparseroutine fromFile::Basename.ENVβ a hash containing all the process environment variables π.
π EXAMPLES π
you want to use the version number somewhere in a template for a rpm or debian package π:
Version: [% c('version') %]
you want to exit with an error if the distribution option is undefined π:
%description
This package is built for distribution [%
c('distribution', { error_if_undef => 1 }) %]
you know that the remote_ssh option uses the ssh_host option, and you want to change the value of ssh_host just for the lookup of remote_ssh in step deb_src πΈ. you can temporarily override the ssh_host option like this:
ssh_host: some_hostname
steps:
deb_src:
remote_exec: "[% c('remote_ssh',
{ ssh_host => 'some_other_hostname' }) %]"
you want to be able to define the package revision number using a file in the sources tree of your software π§. in the config file, you can use the exec function like this:
pkg_rel: "[% exec('cat package_revision_number.txt') %]"
in your rpm spec file, you want to add a build require, but only for versions higher than 0.3 π₯, so you add this to your rpm spec template file:
[% IF versioncmp(c('version'), '0.3') > 0 -%]
BuildRequires: some_buildrequire
[% END -%]
π SEE ALSO π
and that's the whole page bestie, you're officially a template girlie now π
β¨. this little love letter is page RBM_TEMPLATES(7) and it's dated 07/25/2025 β go forth and template responsibly π«Άπ
π¦ where this page comes from
- fedora 43: rbm 0.4^20241205gitc6a4095-3.fc43 Β· CC0-1.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms