rpm: check argument counts for systemd macros
Invoking %systemd_tmpfiles (in %post) without any arguments, while possible, will cause systemd-tmpfiles to process the entire system configuration, rather than just the newly installed configuration files. In https://github.com/systemd/systemd/pull/12048, it was established that processing everything constitutes unusual practice, and should be flagged as a mistake at build time. Furthermore, invoking %systemd_post without any arguments will cause the underlying `systemctl preset` to outright return an error ("Too few arguments") when run. This can be flagged during build time in the same manner. As I have found no ways to successfully nest %if clauses inside a macro[1], I am helping myself by reusing the recursive variable expansion technique pioneered in [2]. Now, when %systemd_post or %systemd_tmpfiles is incorrectly used, rpm gives accurate line number reporting, too: error: This macro requires some arguments error: line 11: %{systemd_post} error: This macro requires two arguments error: line 13: %{tmpfiles_create_package meh more more} [1] what has been tried: %{expand:%%if "%#" == 0 \\\ %%{error:you have given me %# args} \\\ %%endif} [2] http://git.savannah.gnu.org/cgit/automake.git/commit/?id=e0bd4af16da88e4c2c61bde42675660eff7dff51
Loading
Please register or sign in to comment